From f689686dc550d8e957e97ddadfe34e3b9792837a Mon Sep 17 00:00:00 2001 From: GaspardCulis Date: Wed, 7 Feb 2024 16:22:12 +0100 Subject: [PATCH] eww -> bar: Debloat hypr scripts by merging them --- bar/eww/bar.yuck | 14 ++++++-------- bar/eww/scripts/hypr/get-active-workspace | 6 ------ bar/eww/scripts/hypr/get-window-title | 4 ---- bar/eww/scripts/hypr/get-workspaces | 10 ---------- bar/eww/scripts/hypr/hyprstatus | 22 ++++++++++++++++++++++ 5 files changed, 28 insertions(+), 28 deletions(-) delete mode 100755 bar/eww/scripts/hypr/get-active-workspace delete mode 100755 bar/eww/scripts/hypr/get-window-title delete mode 100755 bar/eww/scripts/hypr/get-workspaces create mode 100755 bar/eww/scripts/hypr/hyprstatus diff --git a/bar/eww/bar.yuck b/bar/eww/bar.yuck index 213b718..9fd0b4b 100644 --- a/bar/eww/bar.yuck +++ b/bar/eww/bar.yuck @@ -13,9 +13,7 @@ (deflisten connectivity :initial '{"status": "down"}' "~/.config/eww/scripts/get-connectivity wlan0") (deflisten bluetoothinfo :initial '{"count": 0}' "~/.config/eww/scripts/get-bluetooth-info") -(deflisten workspaces :initial "[]" "~/.config/eww/scripts/hypr/get-workspaces") -(deflisten current_workspace :initial "{\"id\": 1, \"title\": \"...\"}" "~/.config/eww/scripts/hypr/get-active-workspace") -(deflisten window_title :initial "{\"id\": 1, \"title\": \"...\"}" "~/.config/eww/scripts/hypr/get-window-title") +(deflisten hypr :initial '{"spaces": [], "current": 0, "title": ""}' "~/.config/eww/scripts/hypr/hyprstatus") (deflisten volume :initial "{}" "~/.config/eww/scripts/get-volume") @@ -55,12 +53,12 @@ ) (defwidget workspaces [monitor] - (eventbox :onscroll "bash ~/.config/eww/scripts/hypr/change-active-workspace {} ${current_workspace}" :class "workspaces" + (eventbox :onscroll "bash ~/.config/eww/scripts/hypr/change-active-workspace {} ${hypr.current}" :class "workspaces" (box :space-evenly true - (label :text "${workspaces}${current_workspace}" :visible false) - (for workspace in workspaces + (label :text "${hypr.spaces}${hypr.current}" :visible false) + (for workspace in {hypr.spaces} (eventbox :onclick "hyprctl dispatch workspace ${workspace.id}" :visible "${workspace.monitor == monitor}" - (box :class "workspace-entry ${workspace.id == current_workspace ? "current" : ""}" + (box :class "workspace-entry ${workspace.id == hypr.current ? "current" : ""}" (label :text "${workspace.id}") ) ) @@ -70,7 +68,7 @@ ) (defwidget activewindow [] - (label :text "${window_title ?: "..."}") + (label :text "${hypr.title ?: "..."}") ) (defwidget ram [] diff --git a/bar/eww/scripts/hypr/get-active-workspace b/bar/eww/scripts/hypr/get-active-workspace deleted file mode 100755 index 908c5b0..0000000 --- a/bar/eww/scripts/hypr/get-active-workspace +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/dash - -hyprctl monitors -j | jq '.[] | select(.focused) | .activeWorkspace.id' - -socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | - stdbuf -o0 awk -F '>>|,' -e '/^workspace>>/ {print $2}' -e '/^focusedmon>>/ {print $3}' diff --git a/bar/eww/scripts/hypr/get-window-title b/bar/eww/scripts/hypr/get-window-title deleted file mode 100755 index c5cd70a..0000000 --- a/bar/eww/scripts/hypr/get-window-title +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/dash -hyprctl activewindow -j | jq --raw-output .title -socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | stdbuf -o0 awk -F '>>|,' '/^activewindow>>/{print $3}' - diff --git a/bar/eww/scripts/hypr/get-workspaces b/bar/eww/scripts/hypr/get-workspaces deleted file mode 100755 index 9975b87..0000000 --- a/bar/eww/scripts/hypr/get-workspaces +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/dash - -spaces (){ - hyprctl workspaces -j | jq -c 'map({id: .id, windows: .windows, monitor: .monitorID}) | sort_by(.id)' -} - -spaces -socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | while read -r line; do - spaces -done diff --git a/bar/eww/scripts/hypr/hyprstatus b/bar/eww/scripts/hypr/hyprstatus new file mode 100755 index 0000000..88d5f24 --- /dev/null +++ b/bar/eww/scripts/hypr/hyprstatus @@ -0,0 +1,22 @@ +#!/bin/dash + +spaces (){ + hyprctl workspaces -j | jq -c 'map({id: .id, windows: .windows, monitor: .monitorID}) | sort_by(.id)' +} + +current (){ + hyprctl monitors -j | jq '.[] | select(.focused) | .activeWorkspace.id' +} + +title (){ + hyprctl activewindow -j | jq --raw-output .title +} + +status (){ + echo "{\"spaces\": $(spaces), \"current\": \"$(current)\", \"title\": \"$(title)\"}" +} + +status +socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | while read -r line; do + status +done