From 8a833d1eb6f9d8663534c1a494ef4ed3ed5ea241 Mon Sep 17 00:00:00 2001 From: soraefir Date: Tue, 21 Nov 2023 16:52:35 +0100 Subject: [PATCH] Redesign Eww bars --- modules/home/wayland/apps/dunst/default.nix | 8 +- .../home/wayland/apps/eww/bar/css/_clock.scss | 54 +++++++++++ .../home/wayland/apps/eww/bar/css/_net.scss | 8 ++ .../home/wayland/apps/eww/bar/css/_sys.scss | 31 ++++++ modules/home/wayland/apps/eww/bar/eww.scss | 96 +++++++++++++++++++ modules/home/wayland/apps/eww/bar/eww.yuck | 56 +++++++++++ .../wayland/apps/eww/bar/modules/clock.yuck | 31 ++++++ .../wayland/apps/eww/bar/modules/net.yuck | 16 ++++ .../wayland/apps/eww/bar/modules/sys.yuck | 38 ++++++++ .../apps/eww/bar/modules/workspaces.yuck | 16 ++++ .../home/wayland/apps/eww/bar/scripts/net/net | 72 ++++++++++++++ .../wayland/apps/eww/bar/scripts/sys/battery | 61 ++++++++++++ .../home/wayland/apps/eww/bar/scripts/sys/cpu | 1 + .../home/wayland/apps/eww/bar/scripts/sys/gpu | 3 + .../eww/{scripts => bar/scripts/sys}/memory | 0 .../scripts/unused}/brightness | 0 .../scripts/unused}/flightmode | 0 .../{scripts => bar/scripts/unused}/powermode | 0 .../{scripts => bar/scripts/unused}/volume | 0 .../wayland/apps/eww/bar/scripts/workspaces | 86 +++++++++++++++++ .../apps/eww/bar/windows/calendar.yuck | 14 +++ .../apps/eww/{ => bar_old}/css/_calendar.scss | 0 .../apps/eww/{ => bar_old}/css/_sidebar.scss | 0 .../apps/eww/{ => bar_old}/css/_system.scss | 0 .../wayland/apps/eww/{ => bar_old}/eww.scss | 0 .../wayland/apps/eww/{ => bar_old}/eww.yuck | 0 .../apps/eww/{ => bar_old}/modules/clock.yuck | 0 .../apps/eww/{ => bar_old}/modules/net.yuck | 0 .../apps/eww/{ => bar_old}/modules/sys.yuck | 0 .../eww/{ => bar_old}/modules/variables.yuck | 0 .../eww/{ => bar_old}/modules/workspaces.yuck | 0 .../apps/eww/bar_old/scripts/brightness | 30 ++++++ .../apps/eww/bar_old/scripts/flightmode | 23 +++++ .../apps/eww/{ => bar_old}/scripts/net | 0 .../apps/eww/bar_old/scripts/powermode | 20 ++++ .../{scripts => bar_old/scripts/sys}/battery | 2 +- .../apps/eww/bar_old/scripts/sys/memory | 14 +++ .../apps/eww/bar_old/scripts/sys/volume | 64 +++++++++++++ .../apps/eww/{ => bar_old}/scripts/workspaces | 0 .../eww/{ => bar_old}/windows/calendar.yuck | 0 .../eww/{ => bar_old}/windows/system.yuck | 0 modules/home/wayland/apps/eww/default.nix | 8 +- modules/home/wayland/apps/waybar/default.nix | 31 +++--- modules/home/wayland/apps/waylock/default.nix | 11 ++- modules/home/wayland/apps/wofi/default.nix | 8 +- modules/home/wayland/hyprland/config.nix | 12 +-- modules/shared/colors/default.nix | 8 +- 47 files changed, 785 insertions(+), 37 deletions(-) create mode 100644 modules/home/wayland/apps/eww/bar/css/_clock.scss create mode 100644 modules/home/wayland/apps/eww/bar/css/_net.scss create mode 100644 modules/home/wayland/apps/eww/bar/css/_sys.scss create mode 100644 modules/home/wayland/apps/eww/bar/eww.scss create mode 100644 modules/home/wayland/apps/eww/bar/eww.yuck create mode 100644 modules/home/wayland/apps/eww/bar/modules/clock.yuck create mode 100644 modules/home/wayland/apps/eww/bar/modules/net.yuck create mode 100644 modules/home/wayland/apps/eww/bar/modules/sys.yuck create mode 100644 modules/home/wayland/apps/eww/bar/modules/workspaces.yuck create mode 100755 modules/home/wayland/apps/eww/bar/scripts/net/net create mode 100755 modules/home/wayland/apps/eww/bar/scripts/sys/battery create mode 100755 modules/home/wayland/apps/eww/bar/scripts/sys/cpu create mode 100755 modules/home/wayland/apps/eww/bar/scripts/sys/gpu rename modules/home/wayland/apps/eww/{scripts => bar/scripts/sys}/memory (100%) rename modules/home/wayland/apps/eww/{scripts => bar/scripts/unused}/brightness (100%) rename modules/home/wayland/apps/eww/{scripts => bar/scripts/unused}/flightmode (100%) rename modules/home/wayland/apps/eww/{scripts => bar/scripts/unused}/powermode (100%) rename modules/home/wayland/apps/eww/{scripts => bar/scripts/unused}/volume (100%) create mode 100755 modules/home/wayland/apps/eww/bar/scripts/workspaces create mode 100755 modules/home/wayland/apps/eww/bar/windows/calendar.yuck rename modules/home/wayland/apps/eww/{ => bar_old}/css/_calendar.scss (100%) rename modules/home/wayland/apps/eww/{ => bar_old}/css/_sidebar.scss (100%) rename modules/home/wayland/apps/eww/{ => bar_old}/css/_system.scss (100%) rename modules/home/wayland/apps/eww/{ => bar_old}/eww.scss (100%) rename modules/home/wayland/apps/eww/{ => bar_old}/eww.yuck (100%) rename modules/home/wayland/apps/eww/{ => bar_old}/modules/clock.yuck (100%) rename modules/home/wayland/apps/eww/{ => bar_old}/modules/net.yuck (100%) rename modules/home/wayland/apps/eww/{ => bar_old}/modules/sys.yuck (100%) rename modules/home/wayland/apps/eww/{ => bar_old}/modules/variables.yuck (100%) rename modules/home/wayland/apps/eww/{ => bar_old}/modules/workspaces.yuck (100%) create mode 100755 modules/home/wayland/apps/eww/bar_old/scripts/brightness create mode 100755 modules/home/wayland/apps/eww/bar_old/scripts/flightmode rename modules/home/wayland/apps/eww/{ => bar_old}/scripts/net (100%) create mode 100755 modules/home/wayland/apps/eww/bar_old/scripts/powermode rename modules/home/wayland/apps/eww/{scripts => bar_old/scripts/sys}/battery (93%) create mode 100755 modules/home/wayland/apps/eww/bar_old/scripts/sys/memory create mode 100755 modules/home/wayland/apps/eww/bar_old/scripts/sys/volume rename modules/home/wayland/apps/eww/{ => bar_old}/scripts/workspaces (100%) rename modules/home/wayland/apps/eww/{ => bar_old}/windows/calendar.yuck (100%) rename modules/home/wayland/apps/eww/{ => bar_old}/windows/system.yuck (100%) diff --git a/modules/home/wayland/apps/dunst/default.nix b/modules/home/wayland/apps/dunst/default.nix index 886f469..491a0ad 100755 --- a/modules/home/wayland/apps/dunst/default.nix +++ b/modules/home/wayland/apps/dunst/default.nix @@ -12,7 +12,7 @@ width = "400"; scale = "0"; origin = "top-right"; - offset = "4x40"; + offset = "${config.colorScheme.colors.gaps-bar}x${config.colorScheme.colors.gaps-screen}"; notification_limit = "0"; progress_bar = "true"; progress_bar_height = "10"; @@ -44,8 +44,8 @@ max_icon_size = 64; icon_path = - "/usr/share/icons/gnome/128x128/status/:/usr/share/icons/gnome/128x128/devices/"; - icon_theme = "Papirus, Adwaita"; + "${pkgs.tela-circle-icon-theme}/share/icons/Tela-circle-dark/32/status:${pkgs.tela-circle-icon-theme}/share/icons/Tela-circle-dark/32/device "; + icon_theme = "Tela-circle-dark"; enable_recursive_icon_lookup = "true"; sticky_history = "yes"; @@ -56,7 +56,7 @@ always_run_script = "true"; title = "Dunst"; class = "Dunst"; - corner_radius = "10"; + corner_radius = "${config.colorScheme.colors.border-radius}"; ignore_dbusclose = "false"; layer = "top"; force_xwayland = "true"; diff --git a/modules/home/wayland/apps/eww/bar/css/_clock.scss b/modules/home/wayland/apps/eww/bar/css/_clock.scss new file mode 100644 index 0000000..1878671 --- /dev/null +++ b/modules/home/wayland/apps/eww/bar/css/_clock.scss @@ -0,0 +1,54 @@ +.calendar-win { + @include window; + background-color: $bg; + color: $fg; + padding: .2em; +} + +calendar { + padding: 5pt; + + :selected { + color: $base0C; + } + + .header { + color: $base05; + } + + .highlight { + color: $base0C; + font-weight: bold; + } + + .button { + color: $base0C; + } + + :indeterminate { + color: $base03; + } +} + + +.hour, .month { + font-weight: bolder; +} + +.minute, .month { + margin-top: -4pt; +} + +.minute, .hour, .day, .month { + font-size: 20pt; +} + +.date { + color: $base0C; + background-color: $base01; + border-radius: $border-radius; +} + +.datetime { + padding: $border-width; +} \ No newline at end of file diff --git a/modules/home/wayland/apps/eww/bar/css/_net.scss b/modules/home/wayland/apps/eww/bar/css/_net.scss new file mode 100644 index 0000000..516d914 --- /dev/null +++ b/modules/home/wayland/apps/eww/bar/css/_net.scss @@ -0,0 +1,8 @@ + +.net { + color: $base07; +} + +.blt { + color: $base0C; +} \ No newline at end of file diff --git a/modules/home/wayland/apps/eww/bar/css/_sys.scss b/modules/home/wayland/apps/eww/bar/css/_sys.scss new file mode 100644 index 0000000..574633a --- /dev/null +++ b/modules/home/wayland/apps/eww/bar/css/_sys.scss @@ -0,0 +1,31 @@ + +.cpubar { +color: $base0C; +} + +.gpubar { +color: $base0E; +} + +.membar { +color: $base08; +} + +.batbar { +color: $base0B; +} + +.cpubar, +.gpubar, +.membar, +.batbar { + background-color: $bg; + margin: $gaps-window 0; +} + + +.icon-text { +padding: 5pt; +font-size: 5pt; +font-weight: 900; +} diff --git a/modules/home/wayland/apps/eww/bar/eww.scss b/modules/home/wayland/apps/eww/bar/eww.scss new file mode 100644 index 0000000..328ac8a --- /dev/null +++ b/modules/home/wayland/apps/eww/bar/eww.scss @@ -0,0 +1,96 @@ +@import 'css/colors'; + +@mixin rounding { + border-radius: $border-radius; +} + +@mixin window { + border: $border-width solid $base04; + margin: $gaps-screen $gaps-screen $gaps-screen; + @include rounding; +} + + +@import 'css/sys'; +@import 'css/net'; +@import 'css/clock'; + +* { + all: unset; + font-family: "IBM Plex Mono"; + transition: 200ms ease; +} + +.bar { + color: $fg; + + label { + font-size: 1.2rem; + } +} + +tooltip { + background: $base01; + border: $border-width solid $base04; + border-radius: $border-radius; + + label { + font-size: 1rem; + } +} + +.icon, +.icon label { font-family: Material Design Icons; } + +.ws { + border-radius: $border-radius; + margin: $gaps-window; +} + +.focused { + background-color: $bg; + border-radius: 1rem; + margin: .3rem; + padding: .25rem; +} + +.module { + background: $base01; + border-radius: $border-radius; + border-color: $base03; + border-style: solid; + border-width: $border-width; + border-right-style: none; + border-bottom-right-radius: 0; + border-top-right-radius: 0; + padding: 0 $gaps-window; + margin: $gaps-screen 0; +} + +scale trough { + background-color: $bg1; + border-radius: 24px; + margin: 0 1rem; + min-height: 10px; + min-width: 70px; +} + +.grey { + background-color: $base02; +} + +.red { + background-color: $base0F; +} + +.orange { + background-color: $base08; +} + +.green { + background-color: $base0B; +} + +.blue { + background-color: $base0C; +} \ No newline at end of file diff --git a/modules/home/wayland/apps/eww/bar/eww.yuck b/modules/home/wayland/apps/eww/bar/eww.yuck new file mode 100644 index 0000000..4d8b121 --- /dev/null +++ b/modules/home/wayland/apps/eww/bar/eww.yuck @@ -0,0 +1,56 @@ +(include "./modules/workspaces.yuck") + + +(include "./modules/sys.yuck") +(include "./modules/net.yuck") +(include "./modules/clock.yuck") + +(include "./windows/calendar.yuck") + + +(defwidget left [] + (box + :space-evenly false + :orientation "v" + :halign "end" + :valign "start" + (workspaces))) + +(defwidget right [] + (box + :space-evenly false + :orientation "v" + :halign "end" + :valign "end" + (sys) + (net) + (clock))) + +(defwidget center [] + (box + :space-evenly false + :orientation "v" + :halign "end" + :valign "center" + )) + +(defwidget bar-box [] + (centerbox + :orientation "v" + :class "bar" + (left) + (center) + (right))) + + +(defwindow bar + :monitor 0 + :geometry (geometry + :x "0%" + :y "0%" + :width "20px" + :height "100%" + :anchor "right center") + :stacking "fg" + :exclusive true + (bar-box)) diff --git a/modules/home/wayland/apps/eww/bar/modules/clock.yuck b/modules/home/wayland/apps/eww/bar/modules/clock.yuck new file mode 100644 index 0000000..35f11a4 --- /dev/null +++ b/modules/home/wayland/apps/eww/bar/modules/clock.yuck @@ -0,0 +1,31 @@ +(defvar date_rev false) + +(defwidget clock [] + (box + :class "module datetime" + (eventbox + :onhover "${EWW_CMD} update date_rev=true" + :onhoverlost "${EWW_CMD} update date_rev=false" + (overlay + (box + :orientation "v" + (button + :class "hour" hour) + (button + :class "minute" minute)) + (revealer + :reveal date_rev + (box + :class "date" + :orientation "v" + (button + :onclick "${EWW_CMD} open --toggle calendar" + :class "day" day) + (button + :onclick "${EWW_CMD} open --toggle calendar" + :class "month" month))))))) + +(defpoll hour :interval "15s" "date '+%H'") +(defpoll minute :interval "15s" "date '+%M'") +(defpoll day :interval "15s" "date '+%d'") +(defpoll month :interval "15s" "date '+%m'") \ No newline at end of file diff --git a/modules/home/wayland/apps/eww/bar/modules/net.yuck b/modules/home/wayland/apps/eww/bar/modules/net.yuck new file mode 100644 index 0000000..215416c --- /dev/null +++ b/modules/home/wayland/apps/eww/bar/modules/net.yuck @@ -0,0 +1,16 @@ +(deflisten net "scripts/net/net") + +(defwidget net [] + (box + :class "module" + :orientation "v" + (button + :class "net" + :tooltip {net.name} + {net.icon}) + + (button + :class "blt" + (label :class "icon-text" :text "B")) + ) +) \ No newline at end of file diff --git a/modules/home/wayland/apps/eww/bar/modules/sys.yuck b/modules/home/wayland/apps/eww/bar/modules/sys.yuck new file mode 100644 index 0000000..a57ddc6 --- /dev/null +++ b/modules/home/wayland/apps/eww/bar/modules/sys.yuck @@ -0,0 +1,38 @@ +(deflisten cpu "scripts/sys/cpu") +(deflisten gpu "scripts/sys/gpu") +(deflisten memory "scripts/sys/memory") + +(deflisten battery "scripts/sys/battery") + +(defwidget sys [] + (box + :class "module" + :orientation "v" + (circular-progress + :value {EWW_CPU.avg} + :class "cpubar" + :thickness 6 + (label :class "icon-text" :text "C")) + + (circular-progress + :value {gpu.devices[0].GRBM2.CommandProcessor-Graphics.value} + :class "gpubar" + :thickness 6 + (label :class "icon-text" :text "G")) + + (circular-progress + :value {memory.percent} + :class "membar" + :thickness 6 + (label :class "icon-text" :text "M")) + + (circular-progress + :value {battery.percentage} + :class "batbar" + :visible {battery.visible} + :style "color: ${battery.color};" + :thickness 6 + (label :class "icon-text" :text "B")) + + ) +) diff --git a/modules/home/wayland/apps/eww/bar/modules/workspaces.yuck b/modules/home/wayland/apps/eww/bar/modules/workspaces.yuck new file mode 100644 index 0000000..604370f --- /dev/null +++ b/modules/home/wayland/apps/eww/bar/modules/workspaces.yuck @@ -0,0 +1,16 @@ +(deflisten workspace "scripts/workspaces") + +(defwidget workspaces [] + (eventbox + :onscroll "echo {} | sed -e \"s/up/-1/g\" -e \"s/down/+1/g\" | xargs hyprctl dispatch workspace" + (box + :class "module workspaces" + :orientation "v" + (for ws in workspace + (button + :onclick "hyprctl dispatch workspace ${ws.number}" + :class "ws icon ${ws.color}" + ; :tooltip {ws.tooltip} + (box + :class `${ws.focused ? "focused" : ""}` + :height 3)))))) diff --git a/modules/home/wayland/apps/eww/bar/scripts/net/net b/modules/home/wayland/apps/eww/bar/scripts/net/net new file mode 100755 index 0000000..23a8380 --- /dev/null +++ b/modules/home/wayland/apps/eww/bar/scripts/net/net @@ -0,0 +1,72 @@ +#!/usr/bin/env bash + +function get_time_ms { + date -u +%s%3N +} + +icons=("󰤯" "󰤟" "󰤢" "󰤥" "󰤨") + +function toggle() { + status=$(rfkill | grep wlan | awk '{print $4}') + + if [ "$status" = "unblocked" ]; then + rfkill block wlan + else + rfkill unblock wlan + fi +} + +function gen_wifi() { + signal=$(cat /proc/net/wireless | head -n3 | tail -n1 | awk '{print $3}') + level=$(awk -v n="$signal" 'BEGIN{print int((n-1)/20)}') + if [ "$level" -gt 4 ]; then + level=4 + fi + + icon=${icons[$level]} + ip="-" + class="net-connected" + name=$(wpa_cli status | grep \^ssid= | sed 's/ssid=//g') +} + +function gen_ethernet() { + icon="󰈀" + class="net-connected" + ip="" + name=Wired +} + +function make_content() { + local ethernet wifi + ethernet=$(ip link | rg "^[0-9]+: en[po]+" | head -n1 | sed 's/[a-zA-Z0-9_,><:\ -]*state //g' | sed 's/ mode [a-zA-Z0-9 ]*//g') + wifi=$(wpa_cli status | rg "^wpa_state=" | sed 's/wpa_state=//g') + + # test ethernet first + if [[ $ethernet == "UP" ]]; then + gen_ethernet + elif [[ $wifi == "COMPLETED" ]]; then + gen_wifi + else + icon="󰤮" + ip="-" + class="net-disconnected" + name="Disconnected" + fi + + echo '{"icon": "'$icon'", "name": "'$name'", "ip": "'$ip'", "class": "'$class'"}' +} + +if [ "$1" = "toggle" ]; then + toggle +else + last_time=$(get_time_ms) + make_content + ip monitor | while read -r _; do + current_time=$(get_time_ms) + delta=$((current_time - last_time)) + if [[ $delta -gt 50 ]]; then + make_content + last_time=$(get_time_ms) + fi + done +fi diff --git a/modules/home/wayland/apps/eww/bar/scripts/sys/battery b/modules/home/wayland/apps/eww/bar/scripts/sys/battery new file mode 100755 index 0000000..09249a0 --- /dev/null +++ b/modules/home/wayland/apps/eww/bar/scripts/sys/battery @@ -0,0 +1,61 @@ +#!/usr/bin/env bash + +icons=("󰂎" "󰁺" "󰁻" "󰁼" "󰁽" "󰁾" "󰁿" "󰂀" "󰂁" "󰂂" "󰁹") +num_icons=$(awk -v n="${#icons[@]}" 'BEGIN{print 100 / n}') +BATTERY="/sys/class/power_supply/BAT0" + +geticon() { + level=$(awk -v n="$CAPACITY" -v c="$num_icons" 'BEGIN{print int(n/c-1)}') + echo "${icons[$level]}" +} + +status() { + if [ "$STATE" = "Charging" ]; then + echo -n "charging" + + if [ "$RATE" -gt 0 ]; then + echo ", $(gettime) left" + else + echo "" + fi + elif [ "$STATE" = "Discharging" ]; then + echo "$(gettime)h left" + else + echo "fully charged" + fi +} + +color() { + [ "$CAPACITY" -le 20 ] && echo '#f38ba8' || echo '#a6e3a1' +} + +wattage() { + awk -v rate="$RATE" -v uw="1000000" 'BEGIN{print sprintf("%.1f W", rate/uw)}' +} + +gettime() { + FULL=$(cat $BATTERY/energy_full) + NOW=$(cat $BATTERY/energy_now) + + if [ "$RATE" -gt 0 ]; then + if [ "$STATE" = "Discharging" ]; then + EX="$NOW / $RATE" + else + EX="($FULL - $NOW) / $RATE" + fi + date -u -d@"$(awk -v ex="$EX" 'BEGIN{print ex * 3600}')" +%H:%M + fi +} + +if [ -d "$BATTERY" ]; then + while true; do + RATE=$(cat $BATTERY/power_now) + CAPACITY=$(cat $BATTERY/capacity) + STATE=$(cat $BATTERY/status) + + echo '{ "visible": true, "icon": "'$(geticon)'", "percentage": '$CAPACITY', "wattage": "'$(wattage)'", "status": "'$(status)'", "color": "'$(color)'" }' + sleep 15 + done +else + echo '{ "visible": false, "icon": "", "percentage": 0, "wattage": "", "status": "", "color": "#a6e3a1" }' +fi diff --git a/modules/home/wayland/apps/eww/bar/scripts/sys/cpu b/modules/home/wayland/apps/eww/bar/scripts/sys/cpu new file mode 100755 index 0000000..f1f641a --- /dev/null +++ b/modules/home/wayland/apps/eww/bar/scripts/sys/cpu @@ -0,0 +1 @@ +#!/usr/bin/env bash diff --git a/modules/home/wayland/apps/eww/bar/scripts/sys/gpu b/modules/home/wayland/apps/eww/bar/scripts/sys/gpu new file mode 100755 index 0000000..427a240 --- /dev/null +++ b/modules/home/wayland/apps/eww/bar/scripts/sys/gpu @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +amdgpu_top -J -s 5000 | sed 's/ //g' \ No newline at end of file diff --git a/modules/home/wayland/apps/eww/scripts/memory b/modules/home/wayland/apps/eww/bar/scripts/sys/memory similarity index 100% rename from modules/home/wayland/apps/eww/scripts/memory rename to modules/home/wayland/apps/eww/bar/scripts/sys/memory diff --git a/modules/home/wayland/apps/eww/scripts/brightness b/modules/home/wayland/apps/eww/bar/scripts/unused/brightness similarity index 100% rename from modules/home/wayland/apps/eww/scripts/brightness rename to modules/home/wayland/apps/eww/bar/scripts/unused/brightness diff --git a/modules/home/wayland/apps/eww/scripts/flightmode b/modules/home/wayland/apps/eww/bar/scripts/unused/flightmode similarity index 100% rename from modules/home/wayland/apps/eww/scripts/flightmode rename to modules/home/wayland/apps/eww/bar/scripts/unused/flightmode diff --git a/modules/home/wayland/apps/eww/scripts/powermode b/modules/home/wayland/apps/eww/bar/scripts/unused/powermode similarity index 100% rename from modules/home/wayland/apps/eww/scripts/powermode rename to modules/home/wayland/apps/eww/bar/scripts/unused/powermode diff --git a/modules/home/wayland/apps/eww/scripts/volume b/modules/home/wayland/apps/eww/bar/scripts/unused/volume similarity index 100% rename from modules/home/wayland/apps/eww/scripts/volume rename to modules/home/wayland/apps/eww/bar/scripts/unused/volume diff --git a/modules/home/wayland/apps/eww/bar/scripts/workspaces b/modules/home/wayland/apps/eww/bar/scripts/workspaces new file mode 100755 index 0000000..359a7f1 --- /dev/null +++ b/modules/home/wayland/apps/eww/bar/scripts/workspaces @@ -0,0 +1,86 @@ +#!/usr/bin/env bash + +colors=("blue" "blue" "green" "red") +empty="grey" + +# get initial focused workspace +focusedws=$(hyprctl -j monitors | jaq -r '.[] | select(.focused == true) | .activeWorkspace.id') + +declare -A o=([1]=0 [2]=0 [3]=0 [4]=0 [5]=0 [6]=0 [7]=0 [8]=0 [9]=0 [10]=0) +declare -A monitormap +declare -A workspaces + +# set color for each workspace +status() { + if [ "${o[$1]}" -eq 1 ]; then + mon=${monitormap[${workspaces[$1]}]} + echo -n "${colors[$mon]}" + else + echo -n "$empty" + fi +} + +# handle workspace create/destroy +workspace_event() { + while read -r k v; do workspaces[$k]="$v"; done < <(hyprctl -j workspaces | jaq -jr '.[] | .id, " ", .monitor, "\n"') +} +# handle monitor (dis)connects +monitor_event() { + while read -r k v; do monitormap["$k"]=$v; done < <(hyprctl -j monitors | jaq -jr '.[] | .name, " ", .id, "\n"') +} + +# get all apps titles in a workspace +applist() { + ws="$1" + + apps=$(hyprctl -j clients | jaq -jr '.[] | select(.workspace.id == '"$ws"') | .title + "\\n"') + echo -En "${apps%"\n"}" +} + +# generate the json for eww +generate() { + echo -n '[' + + for i in {1..10}; do + echo -n ''"$([ "$i" -eq 1 ] || echo ,)" '{"number": "'"$i"'", "color": "'"$(status "$i")"'", "focused": '"$([ "$focusedws" = "$i" ] && echo "true" || echo "false")"'}' #, "tooltip": "'$(applist "$i")'" }' + done + + echo ']' +} + +# setup + +# add monitors +monitor_event + +# add workspaces +workspace_event + +# check occupied workspaces +for num in "${!workspaces[@]}"; do + o[$num]=1 +done +# generate initial widget +generate + +# main loop +socat -u UNIX-CONNECT:/tmp/hypr/"$HYPRLAND_INSTANCE_SIGNATURE"/.socket2.sock - | rg --line-buffered "workspace|mon(itor)?" | while read -r line; do + case ${line%>>*} in + "workspace") + focusedws=${line#*>>} + ;; + "focusedmon") + focusedws=${line#*,} + ;; + "createworkspace") + o[${line#*>>}]=1 + ;; + "destroyworkspace") + o[${line#*>>}]=0 + ;; + "monitor"*) + monitor_event + ;; + esac + generate +done \ No newline at end of file diff --git a/modules/home/wayland/apps/eww/bar/windows/calendar.yuck b/modules/home/wayland/apps/eww/bar/windows/calendar.yuck new file mode 100755 index 0000000..23bb5e8 --- /dev/null +++ b/modules/home/wayland/apps/eww/bar/windows/calendar.yuck @@ -0,0 +1,14 @@ +(defwidget calendar-win [] + (box + :class "calendar-win" + (calendar))) + +(defwindow calendar + :monitor 0 + :geometry (geometry + :x "0%" + :y "0%" + :anchor "bottom right" + :width "0px" + :height "0px") + (calendar-win)) \ No newline at end of file diff --git a/modules/home/wayland/apps/eww/css/_calendar.scss b/modules/home/wayland/apps/eww/bar_old/css/_calendar.scss similarity index 100% rename from modules/home/wayland/apps/eww/css/_calendar.scss rename to modules/home/wayland/apps/eww/bar_old/css/_calendar.scss diff --git a/modules/home/wayland/apps/eww/css/_sidebar.scss b/modules/home/wayland/apps/eww/bar_old/css/_sidebar.scss similarity index 100% rename from modules/home/wayland/apps/eww/css/_sidebar.scss rename to modules/home/wayland/apps/eww/bar_old/css/_sidebar.scss diff --git a/modules/home/wayland/apps/eww/css/_system.scss b/modules/home/wayland/apps/eww/bar_old/css/_system.scss similarity index 100% rename from modules/home/wayland/apps/eww/css/_system.scss rename to modules/home/wayland/apps/eww/bar_old/css/_system.scss diff --git a/modules/home/wayland/apps/eww/eww.scss b/modules/home/wayland/apps/eww/bar_old/eww.scss similarity index 100% rename from modules/home/wayland/apps/eww/eww.scss rename to modules/home/wayland/apps/eww/bar_old/eww.scss diff --git a/modules/home/wayland/apps/eww/eww.yuck b/modules/home/wayland/apps/eww/bar_old/eww.yuck similarity index 100% rename from modules/home/wayland/apps/eww/eww.yuck rename to modules/home/wayland/apps/eww/bar_old/eww.yuck diff --git a/modules/home/wayland/apps/eww/modules/clock.yuck b/modules/home/wayland/apps/eww/bar_old/modules/clock.yuck similarity index 100% rename from modules/home/wayland/apps/eww/modules/clock.yuck rename to modules/home/wayland/apps/eww/bar_old/modules/clock.yuck diff --git a/modules/home/wayland/apps/eww/modules/net.yuck b/modules/home/wayland/apps/eww/bar_old/modules/net.yuck similarity index 100% rename from modules/home/wayland/apps/eww/modules/net.yuck rename to modules/home/wayland/apps/eww/bar_old/modules/net.yuck diff --git a/modules/home/wayland/apps/eww/modules/sys.yuck b/modules/home/wayland/apps/eww/bar_old/modules/sys.yuck similarity index 100% rename from modules/home/wayland/apps/eww/modules/sys.yuck rename to modules/home/wayland/apps/eww/bar_old/modules/sys.yuck diff --git a/modules/home/wayland/apps/eww/modules/variables.yuck b/modules/home/wayland/apps/eww/bar_old/modules/variables.yuck similarity index 100% rename from modules/home/wayland/apps/eww/modules/variables.yuck rename to modules/home/wayland/apps/eww/bar_old/modules/variables.yuck diff --git a/modules/home/wayland/apps/eww/modules/workspaces.yuck b/modules/home/wayland/apps/eww/bar_old/modules/workspaces.yuck similarity index 100% rename from modules/home/wayland/apps/eww/modules/workspaces.yuck rename to modules/home/wayland/apps/eww/bar_old/modules/workspaces.yuck diff --git a/modules/home/wayland/apps/eww/bar_old/scripts/brightness b/modules/home/wayland/apps/eww/bar_old/scripts/brightness new file mode 100755 index 0000000..6270197 --- /dev/null +++ b/modules/home/wayland/apps/eww/bar_old/scripts/brightness @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +function get_time_ms { + date -u +%s%3N +} + +icons=("󰛩" "󱩒" "󰛨") + +gen_output() { + icon="${icons[$(awk -v n="$(brillo)" 'BEGIN{print int(n/34)}')]}" + prcnt=$(brillo | xargs printf "%.*f\n" "0") + echo '{"percent": '$prcnt', "icon": "'$icon'"}' +} + +if [[ $(brillo 2>/dev/stdout 1>/dev/null | head -n1 | awk '{print $1}') == "No" ]]; then + echo '{"percent": 100, "icon": "󰛨"}' +elif [ "$1" = "" ]; then + # initial + last_time=$(get_time_ms) + gen_output + + udevadm monitor | rg --line-buffered "backlight" | while read -r _; do + current_time=$(get_time_ms) + delta=$((current_time - last_time)) + if [[ $delta -gt 50 ]]; then + gen_output + last_time=$(get_time_ms) + fi + done +fi \ No newline at end of file diff --git a/modules/home/wayland/apps/eww/bar_old/scripts/flightmode b/modules/home/wayland/apps/eww/bar_old/scripts/flightmode new file mode 100755 index 0000000..59e18c5 --- /dev/null +++ b/modules/home/wayland/apps/eww/bar_old/scripts/flightmode @@ -0,0 +1,23 @@ +#!/bin/sh + +icon() { + [ "$STATUS" = "no" ] && echo "󰀞" || echo "󰀝" +} + +toggle() { + if [ "$STATUS" = "no" ]; then + rfkill block all + else + rfkill unblock all + fi +} + +if [ "$1" = "toggle" ]; then + toggle +else + icon + rfkill event | while read -r _; do + STATUS="$(rfkill list | sed -n 2p | awk '{print $3}')" + icon + done +fi \ No newline at end of file diff --git a/modules/home/wayland/apps/eww/scripts/net b/modules/home/wayland/apps/eww/bar_old/scripts/net similarity index 100% rename from modules/home/wayland/apps/eww/scripts/net rename to modules/home/wayland/apps/eww/bar_old/scripts/net diff --git a/modules/home/wayland/apps/eww/bar_old/scripts/powermode b/modules/home/wayland/apps/eww/bar_old/scripts/powermode new file mode 100755 index 0000000..31710ef --- /dev/null +++ b/modules/home/wayland/apps/eww/bar_old/scripts/powermode @@ -0,0 +1,20 @@ +#!/bin/sh + +icon() { + [ "$STATUS" = "no" ] && echo "󰌪" || echo "󱐋" +} + +toggle() { + if [ "$STATUS" = "no" ]; then + echo "" + else + echo "" + fi +} + +if [ "$1" = "toggle" ]; then + toggle + icon +else + icon +fi \ No newline at end of file diff --git a/modules/home/wayland/apps/eww/scripts/battery b/modules/home/wayland/apps/eww/bar_old/scripts/sys/battery similarity index 93% rename from modules/home/wayland/apps/eww/scripts/battery rename to modules/home/wayland/apps/eww/bar_old/scripts/sys/battery index 29a369e..7855013 100755 --- a/modules/home/wayland/apps/eww/scripts/battery +++ b/modules/home/wayland/apps/eww/bar_old/scripts/sys/battery @@ -57,5 +57,5 @@ if [ -d "$BATTERY" ]; then sleep 5 done else - echo '{ "icon": "", "percentage": 0, "wattage": "", "status": "", "color": "#a6e3a1" }' + echo '{ "icon": "", "percentage": 0.0, "wattage": "", "status": "", "color": "#a6e3a1" }' fi diff --git a/modules/home/wayland/apps/eww/bar_old/scripts/sys/memory b/modules/home/wayland/apps/eww/bar_old/scripts/sys/memory new file mode 100755 index 0000000..89085b3 --- /dev/null +++ b/modules/home/wayland/apps/eww/bar_old/scripts/sys/memory @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +total="$(free --si | rg Mem | awk '{print $2}')" + +human() { + awk -v mem="$1" 'BEGIN{print sprintf("%.1f%s", mem/1000/(mem > 1000000 ? 1000 : 1), mem > 1000000 ? "G" : "M")}' +} + +free --si -s 3 | rg --line-buffered Mem | while read -r line; do + used=$(echo "$line" | awk '{print $3}') + perc=$(awk -v used="$used" -v total="$total" 'BEGIN{print sprintf("%.f", used/total*100)}') + + echo '{"total": "'$(human "$total")'", "used": "'$(human "$used")'", "percent": '$perc'}' +done \ No newline at end of file diff --git a/modules/home/wayland/apps/eww/bar_old/scripts/sys/volume b/modules/home/wayland/apps/eww/bar_old/scripts/sys/volume new file mode 100755 index 0000000..dcafe42 --- /dev/null +++ b/modules/home/wayland/apps/eww/bar_old/scripts/sys/volume @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +function get_time_ms { + date -u +%s%3N +} + +volicons=("󰕿" "󰖀" "󰕾") + +vol() { + wpctl get-volume @DEFAULT_AUDIO_"$1"@ | awk '{print int($2*100)}' +} +ismuted() { + wpctl get-volume @DEFAULT_AUDIO_"$1"@ | rg -qi muted + echo -n $? +} +setvol() { + wpctl set-volume @DEFAULT_AUDIO_"$1"@ "$(awk -v n="$2" 'BEGIN{print (n / 100)}')" +} +setmute() { + wpctl set-mute @DEFAULT_AUDIO_"$1"@ toggle +} + +gen_output() { + percent="$(vol "SINK")" + lvl=$(awk -v n="$percent" 'BEGIN{print int(n/34)}') + ismuted=$(ismuted "SINK") + + if [ "$ismuted" = 1 ]; then + icon="${volicons[$lvl]}" + else + icon="󰝟" + fi + + echo '{"icon": "'$icon'", "percent": '$(vol "SINK")', "microphone": '$(vol "SOURCE")'}' +} + +if [ "$1" = "mute" ]; then + if [ "$2" != "SOURCE" ] && [ "$2" != "SINK" ]; then + echo "Can only mute SINK or SOURCE" + exit 1 + fi + setmute "$2" +elif [ "$1" = "setvol" ]; then + if [ "$2" != "SOURCE" ] && [ "$2" != "SINK" ]; then + echo "Can only set volume for SINK or SOURCE" + exit 1 + elif [ "$3" -lt 0 ] || [ "$3" -gt 100 ]; then + echo "Volume must be between 0 and 100" + exit 1 + fi + setvol "$2" "$3" +else + last_time=$(get_time_ms) + gen_output + + pw-cli -m 2>/dev/null | rg --line-buffered "PipeWire:Interface:Client" | while read -r event; do + current_time=$(get_time_ms) + delta=$((current_time - last_time)) + if [[ $delta -gt 50 ]]; then + gen_output + last_time=$(get_time_ms) + fi + done +fi diff --git a/modules/home/wayland/apps/eww/scripts/workspaces b/modules/home/wayland/apps/eww/bar_old/scripts/workspaces similarity index 100% rename from modules/home/wayland/apps/eww/scripts/workspaces rename to modules/home/wayland/apps/eww/bar_old/scripts/workspaces diff --git a/modules/home/wayland/apps/eww/windows/calendar.yuck b/modules/home/wayland/apps/eww/bar_old/windows/calendar.yuck similarity index 100% rename from modules/home/wayland/apps/eww/windows/calendar.yuck rename to modules/home/wayland/apps/eww/bar_old/windows/calendar.yuck diff --git a/modules/home/wayland/apps/eww/windows/system.yuck b/modules/home/wayland/apps/eww/bar_old/windows/system.yuck similarity index 100% rename from modules/home/wayland/apps/eww/windows/system.yuck rename to modules/home/wayland/apps/eww/bar_old/windows/system.yuck diff --git a/modules/home/wayland/apps/eww/default.nix b/modules/home/wayland/apps/eww/default.nix index 7dbf908..9c03759 100755 --- a/modules/home/wayland/apps/eww/default.nix +++ b/modules/home/wayland/apps/eww/default.nix @@ -8,7 +8,7 @@ filter = name: _type: let baseName = baseNameOf (toString name); in !(lib.hasSuffix ".nix" baseName) && (baseName != "_colors.scss"); - src = lib.cleanSource ./.; + src = lib.cleanSource ./bar/.; }; recursive = true; @@ -38,6 +38,12 @@ $bg: $base00; $bg1: $base01; $border: $base03; + + $border-radius: ${config.colorScheme.colors.border-radius}px; + $border-width: ${config.colorScheme.colors.border-width}px; + + $gaps-screen: ${config.colorScheme.colors.gaps-screen}px; + $gaps-window: ${config.colorScheme.colors.gaps-window}px; ''; }; } diff --git a/modules/home/wayland/apps/waybar/default.nix b/modules/home/wayland/apps/waybar/default.nix index fb1aed7..18450b4 100644 --- a/modules/home/wayland/apps/waybar/default.nix +++ b/modules/home/wayland/apps/waybar/default.nix @@ -23,21 +23,23 @@ in { style = '' * { border: none; - border-radius: ${config.colorScheme.colors.radius}; + border-radius: ${config.colorScheme.colors.border-radius}pt; font-family:'Monospace','Material Design Icons','Openmoji'; font-size: 13pt; color: #${config.colorScheme.colors.base07}; } window#waybar { - background: transparent; + background: transparent; + padding-top: ${config.colorScheme.colors.gaps-screen}pt; + padding-bottom: ${config.colorScheme.colors.gaps-screen}pt; } tooltip { background: #${config.colorScheme.colors.base01}; - border-radius: ${config.colorScheme.colors.radius}; - border-color: #${config.colorScheme.colors.base04}; - border-width: 2px; + border-radius: ${config.colorScheme.colors.border-radius}pt; + border-color: #${config.colorScheme.colors.base03}; + border-width: ${config.colorScheme.colors.border-width}pt; border-style: solid; font-size: 13pt; } @@ -47,15 +49,8 @@ in { } #workspaces { - background: #${config.colorScheme.colors.base01}; font-size: 64pt; - margin-top: 6pt; - margin-bottom: 10pt; - border-top-right-radius: 0px; - border-bottom-right-radius: 0px; - border-top: 2px solid #${config.colorScheme.colors.base04}; - border-left: 2px solid #${config.colorScheme.colors.base04}; - border-bottom: 2px solid #${config.colorScheme.colors.base04}; + } #workspaces button { @@ -79,6 +74,7 @@ in { color: #${config.colorScheme.colors.base04}; } + #workspaces, #network, #pulseaudio, #backlight, #battery, @@ -88,21 +84,22 @@ in { #clock, #clock.date, #clock.time { background: #${config.colorScheme.colors.base01}; - margin-bottom: 4pt; + margin-bottom: ${config.colorScheme.colors.gaps-window}pt; padding-top: 2px; padding-left: 2px; padding-bottom: 2px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; - border-top: 2px solid #${config.colorScheme.colors.base04}; - border-left: 2px solid #${config.colorScheme.colors.base04}; - border-bottom: 2px solid #${config.colorScheme.colors.base04}; + border-top: ${config.colorScheme.colors.border-width}px solid #${config.colorScheme.colors.base03}; + border-left: ${config.colorScheme.colors.border-width}px solid #${config.colorScheme.colors.base03}; + border-bottom: ${config.colorScheme.colors.border-width}px solid #${config.colorScheme.colors.base03}; } #custom-powermenu { margin-bottom: 0pt; border-bottom-left-radius: 0px; border-bottom: none; + padding-bottom: 0px; } ''; settings = [{ diff --git a/modules/home/wayland/apps/waylock/default.nix b/modules/home/wayland/apps/waylock/default.nix index d23ce74..73d9caf 100755 --- a/modules/home/wayland/apps/waylock/default.nix +++ b/modules/home/wayland/apps/waylock/default.nix @@ -60,8 +60,10 @@ } button { - border-radius:7px; - border: 2px solid #${config.colorscheme.colors.base03}; + border-radius:${config.colorscheme.colors.border-radius}px; + border-width: ${config.colorscheme.colors.border-width}px; + border-style: solid; + border-color: #${config.colorscheme.colors.base04}; color: #${config.colorscheme.colors.base07}; padding: 20px; background-color: alpha(#${config.colorscheme.colors.base00},0.8); @@ -74,7 +76,10 @@ button:focus { background-color: alpha(#${config.colorscheme.colors.base02},1.0); - border: 2px solid #${config.colorscheme.colors.base05}; + border-radius:${config.colorscheme.colors.border-radius}px; + border-width: ${config.colorscheme.colors.border-width}px; + border-color: #${config.colorscheme.colors.base04}; + border-style: solid; } ''; diff --git a/modules/home/wayland/apps/wofi/default.nix b/modules/home/wayland/apps/wofi/default.nix index a773f24..0da6658 100755 --- a/modules/home/wayland/apps/wofi/default.nix +++ b/modules/home/wayland/apps/wofi/default.nix @@ -23,7 +23,7 @@ xdg.configFile."wofi/style.css".text = '' window { margin: 0px; - border-radius:7px; + border-radius: ${config.colorscheme.colors.border-radius}px; background-color: #${config.colorscheme.colors.base00}; } @@ -51,8 +51,10 @@ #outer-box { margin: 0px; padding: 3px; - border-radius: 7px; - border: 2px solid #${config.colorscheme.colors.base03}; + border-radius: ${config.colorscheme.colors.border-radius}px; + border-width: ${config.colorscheme.colors.border-width}px; + border-color: #${config.colorscheme.colors.base04}; + border-style: solid; } #text:selected { diff --git a/modules/home/wayland/hyprland/config.nix b/modules/home/wayland/hyprland/config.nix index 6971376..6cd4d05 100755 --- a/modules/home/wayland/hyprland/config.nix +++ b/modules/home/wayland/hyprland/config.nix @@ -33,18 +33,18 @@ } general { - gaps_in = 4 - gaps_out = 8 - border_size = 2 + gaps_in = ${config.colorScheme.colors.gaps-window} + gaps_out = ${config.colorScheme.colors.gaps-screen} + border_size = ${config.colorScheme.colors.border-width} - # col.active_border = rgb(${config.colorScheme.colors.base05}) - # col.inactive_border = rgb(${config.colorScheme.colors.base03}) + col.active_border = rgb(${config.colorScheme.colors.base04}) + col.inactive_border = rgb(${config.colorScheme.colors.base03}) layout = dwindle } decoration { - rounding = 4 + rounding = ${config.colorScheme.colors.border-radius} blur { enabled = true diff --git a/modules/shared/colors/default.nix b/modules/shared/colors/default.nix index c3ba5ef..10d764b 100755 --- a/modules/shared/colors/default.nix +++ b/modules/shared/colors/default.nix @@ -1,5 +1,9 @@ -{ ... }: { +{ config, ... }: { imports = [ ./sorahiro_soft.nix ]; - colorScheme.colors.radius = "#8px"; + colorScheme.colors.border-radius = "#8"; + colorScheme.colors.border-width = "#2"; + colorScheme.colors.gaps-screen = "#8"; + colorScheme.colors.gaps-window = "#4"; + colorScheme.colors.gaps-bar = "#32"; }