adding better workspaces to eww

This commit is contained in:
Chris Cochrun 2023-08-30 15:28:21 -05:00
parent f7394076c1
commit d34f4ab2b4
9 changed files with 55 additions and 33 deletions

View file

@ -306,6 +306,10 @@ tooltip label {
background-color: rgba(00, 00, 00, 0.0);
}
.works:hover {
background-color: $base0D;
}
.empty_workspace {
color: $base03;
}

View file

@ -21,6 +21,9 @@
(deflisten workspace "scripts/workspace")
(deflisten appname "scripts/appname")
(deflisten workspaces :initial "[]" "bash ~/.config/eww/scripts/get-workspaces")
(deflisten current_workspace :initial "1" "bash ~/.config/eww/scripts/get-active-workspace")
(defvar vol_reveal false)
(defvar br_reveal false)
(defvar music_reveal false)
@ -39,12 +42,10 @@
:class "works"
:orientation "h"
:spacing 5
:space-evenly "false"
:space-evenly "true"
:valign "center"
(button :onclick "hyprctl dispatch workspace 1" :class "0$o1$f1" "")
(button :onclick "hyprctl dispatch workspace 2" :class "0$o2$f2" "")
(button :onclick "hyprctl dispatch workspace 3" :class "0$o3$f3" "󰍨")
(button :onclick "hyprctl dispatch workspace 4" :class "0$o4$f4" "󰈙"))))
(for workspace in workspaces
(button :onclick "hyprctl dispatch workspace ${workspace.id}" :class "works ${workspace.id == current_workspace ? "current" : ""} ${workspace.windows > 0 ? "occupied" : "empty"}" "${workspace.name}")))))
@ -256,7 +257,7 @@
:valign "center"
:class "left_modules"
:spacing 8
;; (workspaces)
(workspaces)
(appnames)))
(defwidget center []
(box

View file

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

View file

@ -0,0 +1,5 @@
#!/usr/bin/env bash
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

@ -0,0 +1,11 @@
#!/usr/bin/env bash
spaces (){
WORKSPACE_WINDOWS=$(hyprctl workspaces -j | jq 'map({key: .id | tostring, value: .windows}) | from_entries')
seq 1 10 | jq --argjson windows "${WORKSPACE_WINDOWS}" --slurp -Mc 'map(tostring) | map({id: ., windows: ($windows[.]//0)})'
}
spaces
socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | while read -r line; do
spaces
done