eww -> bar: Debloat hypr scripts by merging them

This commit is contained in:
GaspardCulis 2024-02-07 16:22:12 +01:00
parent 6de642f4a2
commit f689686dc5
5 changed files with 28 additions and 28 deletions

View file

@ -13,9 +13,7 @@
(deflisten connectivity :initial '{"status": "down"}' "~/.config/eww/scripts/get-connectivity wlan0") (deflisten connectivity :initial '{"status": "down"}' "~/.config/eww/scripts/get-connectivity wlan0")
(deflisten bluetoothinfo :initial '{"count": 0}' "~/.config/eww/scripts/get-bluetooth-info") (deflisten bluetoothinfo :initial '{"count": 0}' "~/.config/eww/scripts/get-bluetooth-info")
(deflisten workspaces :initial "[]" "~/.config/eww/scripts/hypr/get-workspaces") (deflisten hypr :initial '{"spaces": [], "current": 0, "title": ""}' "~/.config/eww/scripts/hypr/hyprstatus")
(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 volume :initial "{}" "~/.config/eww/scripts/get-volume") (deflisten volume :initial "{}" "~/.config/eww/scripts/get-volume")
@ -55,12 +53,12 @@
) )
(defwidget workspaces [monitor] (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 (box :space-evenly true
(label :text "${workspaces}${current_workspace}" :visible false) (label :text "${hypr.spaces}${hypr.current}" :visible false)
(for workspace in workspaces (for workspace in {hypr.spaces}
(eventbox :onclick "hyprctl dispatch workspace ${workspace.id}" :visible "${workspace.monitor == monitor}" (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}") (label :text "${workspace.id}")
) )
) )
@ -70,7 +68,7 @@
) )
(defwidget activewindow [] (defwidget activewindow []
(label :text "${window_title ?: "..."}") (label :text "${hypr.title ?: "..."}")
) )
(defwidget ram [] (defwidget ram []

View file

@ -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}'

View file

@ -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}'

View file

@ -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

22
bar/eww/scripts/hypr/hyprstatus Executable file
View file

@ -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