chore: Remove redundancy

This commit is contained in:
Ahmad Ansori Palembani 2025-02-07 07:53:56 +07:00
parent b72e2f7090
commit 12f080999f
Signed by: null2264
GPG key ID: BA64F8B60AF3EFB6
3 changed files with 27 additions and 22 deletions

View file

@ -1,4 +0,0 @@
#!/bin/sh
tmp=/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock
[ -f $tmp ] && echo $tmp || echo $XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock

View file

@ -1,7 +1,17 @@
#!/bin/sh
# REF: https://github.com/Mango0x45/dotfiles/blob/d62026673b0b833f27b85f8a551cb646ae2bd751/.config/eww/scripts/active-workspace-listener
# REF: https://github.com/Mango0x45/dotfiles/blob/c3e4bf8/.config/eww/scripts/active-workspace-listener
readonly IPC=$(./scripts/hypr/hyprland-getsocket)
readonly IPC="$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock"
hyprctl -j activeworkspace | jq -r '.name'
socat -u UNIX-CONNECT:"$IPC" - | sed -n 's/^workspace>>//p'
report() {
hyprctl -j monitors | jq -cr '[.[] | .activeWorkspace.id % 10]'
}
report
socat -u UNIX-CONNECT:"$IPC" - | while read -r _
do
case "${_%>>*}" in
workspace|moveworkspace)
report
esac
done

View file

@ -1,22 +1,21 @@
#!/bin/sh
# REF: https://github.com/Mango0x45/dotfiles/blob/d620266/.config/eww/scripts/workspace-list-listener
# REF: https://github.com/Mango0x45/dotfiles/blob/c3e4bf8/.config/eww/scripts/workspace-list-listener
readonly IPC=$(./scripts/hypr/hyprland-getsocket)
readonly IPC="$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock"
ws="`hyprctl -j workspaces | jq -r 'sort_by(.id) | .[] | .name'`"
jo -a $ws
hyprctl -j workspaces | jq -cr '
[.[].id]
| group_by(. / 10 | floor)
| [.[] | map(. % 10)]
'
socat -u UNIX-CONNECT:"$IPC" - \
| stdbuf -oL grep -E '^(create|destroy)workspace>>' \
| while IFS='>>' read -r e _ n
| while read -r _
do
case "$e" in
c*)
ws="`printf '%s\n%s\n' "$ws" $n | sort -n`"
;;
d*)
ws="`echo "$ws" | grep -v "^$n$"`"
;;
esac
jo -a $ws
hyprctl -j workspaces | jq -cr '
[.[].id]
| group_by(. / 10 | floor)
| [.[] | map(. % 10) | sort_by(.)]
'
done