diff --git a/.config/eww/eww.scss b/.config/eww/eww.scss index f1f033e..99f5f41 100644 --- a/.config/eww/eww.scss +++ b/.config/eww/eww.scss @@ -36,26 +36,38 @@ } } -label { +label, .systray { padding: 6px; } +.workspace { + color: $foreground; + label { + padding: 0 10px; + } +} + +.workspace:hover { + background-color: $hovered; +} + +.workspace.active { + background-color: $selected; +} + scale { padding: 0 4px; -} - -scale slider { - all: unset; -} - -scale trough { - min-height: 6px; - min-width: 60px; -} - -progressbar trough { - border: 2px solid $accent2; - border-radius: 16px; + slider { + all: unset; + } + trough { + min-height: 6px; + min-width: 60px; + } + progressbar trough { + border: 2px solid $accent2; + border-radius: 16px; + } } progress { diff --git a/.config/eww/eww.yuck b/.config/eww/eww.yuck index bec2371..1c42281 100644 --- a/.config/eww/eww.yuck +++ b/.config/eww/eww.yuck @@ -1,4 +1,4 @@ -; Brightness +; Brightness (defpoll brightness :interval "1m" "cat /sys/class/backlight/amdgpu_bl1/brightness") (defvar brightness-icons '["", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]') (defvar brightness-slide false) @@ -15,21 +15,45 @@ ; Window Title (deflisten window-title "hyprctl activewindow -j | jq --raw-output .title; socat -u UNIX-CONNECT:$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | stdbuf -o0 awk -F '>>|,' '/^activewindow>>/{print $3}'") +; Workspaces +(deflisten workspaces "~/.config/eww/scripts/get-workspaces.sh") +(deflisten active-workspace "~/.config/eww/scripts/get-active-workspace.sh") + ; Widgets (defwidget bar-left [] (box :halign "start" :space-evenly false + (workspaces) + (systray :spacing 8 + :icon-size 16 + :class "systray" + ) ) ) +(defwidget workspaces [] + (eventbox :onscroll "~/.config/eww/scripts/change-active-workspace.sh {} ${active-workspace}" + (box :spacing 0 + (for workspace in workspaces + (eventbox :onclick "hyprctl dispatch workspace ${workspace}" + :class "workspace ${workspace == active-workspace ? "active" : ""}" + (label :text "${workspace}") + ) + ) + ) + ) +) + + (defwidget bar-middle [] (label :limit-width 2 :text "${window-title}" ) ) + (defwidget bar-right [] (box :halign "end" :space-evenly false diff --git a/.config/eww/scripts/change-active-workspace b/.config/eww/scripts/change-active-workspace new file mode 100755 index 0000000..3a43646 --- /dev/null +++ b/.config/eww/scripts/change-active-workspace @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +function clamp { + min=$1 + max=$2 + val=$3 + python -c "print(max($min, min($val, $max)))" +} + +direction=$1 +current=$2 +if test "$direction" = "down" +then + target=$(clamp 1 10 $(($current+1))) + echo "jumping to $target" + hyprctl dispatch workspace $target +elif test "$direction" = "up" +then + target=$(clamp 1 10 $(($current-1))) + echo "jumping to $target" + hyprctl dispatch workspace $target +fi diff --git a/.config/eww/scripts/get-active-workspace.sh b/.config/eww/scripts/get-active-workspace.sh new file mode 100755 index 0000000..c80f7f0 --- /dev/null +++ b/.config/eww/scripts/get-active-workspace.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +hyprctl monitors -j | jq '.[] | select(.focused) | .activeWorkspace.id' + +socat -u UNIX-CONNECT:$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | + stdbuf -o0 awk -F '>>|,' -e '/^workspace>>/ {print $2}' -e '/^focusedmon>>/ {print $3}' diff --git a/.config/eww/scripts/get-workspaces.sh b/.config/eww/scripts/get-workspaces.sh new file mode 100755 index 0000000..ae24e98 --- /dev/null +++ b/.config/eww/scripts/get-workspaces.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +hyprctl workspaces -j | jq -c '[.[].id] | map(tostring)' +socat -u UNIX-CONNECT:$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | while read -r line; do + hyprctl workspaces -j | jq -c '[.[].id] | map(tostring)' +done