This commit is contained in:
LavaDesu 2024-01-16 01:08:18 +07:00
parent 4667653ed1
commit d149a7704b
8 changed files with 41 additions and 117 deletions

View file

@ -0,0 +1,6 @@
#!/usr/bin/env sh
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,43 +0,0 @@
#!/usr/bin/env sh
# Checks if a list ($1) contains an element ($2)
contains() {
for e in $1; do
[ "$e" -eq "$2" ] && echo 1 && return
done
echo 0
}
print_workspaces() {
buf=""
desktops=$(bspc query -D --names)
focused_desktop=$(bspc query -D -d focused --names)
occupied_desktops=$(bspc query -D -d .occupied --names)
urgent_desktops=$(bspc query -D -d .urgent --names)
for d in $desktops; do
if [ "$(contains "$focused_desktop" "$d")" -eq 1 ]; then
ws=$d
class="focused"
elif [ "$(contains "$occupied_desktops" "$d")" -eq 1 ]; then
ws=$d
class="occupied"
elif [ "$(contains "$urgent_desktops" "$d")" -eq 1 ]; then
ws=$d
class="urgent"
else
ws=$d
class="empty"
fi
buf="$buf (eventbox :cursor \"hand\" (button :class \"$class\" :onclick \"bspc desktop -f $ws\" \"\"))"
done
echo "(box :class \"widget line-workspaces\" :halign \"start\" :valign \"center\" :vexpand true :hexpand true $buf)"
}
# Listen to bspwm changes
print_workspaces
bspc subscribe desktop node_transfer | while read -r _ ; do
print_workspaces
done

View file

@ -1,10 +1,17 @@
#!/usr/bin/env sh
xtitle -s | while read -r line ; do
trunc=$(echo $line | cut -c-85)
if [ -z "$line" ]; then
out () {
if [ -z "$1" ]; then
echo ""
else
echo "(box :class \"widget title\" :halign \"center\" :valign \"center\" :vexpand true :hexpand true (label :text \"${trunc}\"))"
echo "(box :class \"widget title\" :halign \"center\" :valign \"center\" :vexpand true :hexpand true (label :text \"$1\"))"
fi
}
init=$(hyprctl activewindow -j | jq --raw-output .title)
out "$init"
socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | stdbuf -o0 awk -F '>>|,' '/^activewindow>>/{print $3}' | while read -r line ; do
trunc=$(echo $line | cut -c-85)
out "$trunc"
done

View file

@ -1,47 +1,11 @@
#!/usr/bin/env sh
# Checks if a list ($1) contains an element ($2)
contains() {
for e in $1; do
[ "$e" -eq "$2" ] && echo 1 && return
done
echo 0
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)})'
}
print_workspaces() {
buf=""
desktops=$(bspc query -D --names)
focused_desktop=$(bspc query -D -d focused --names)
occupied_desktops=$(bspc query -D -d .occupied --names)
urgent_desktops=$(bspc query -D -d .urgent --names)
for d in $desktops; do
if [ "$(contains "$focused_desktop" "$d")" -eq 1 ]; then
ws=$d
icon=""
class="focused"
elif [ "$(contains "$occupied_desktops" "$d")" -eq 1 ]; then
ws=$d
icon=""
class="occupied"
elif [ "$(contains "$urgent_desktops" "$d")" -eq 1 ]; then
ws=$d
icon=""
class="urgent"
else
ws=$d
icon=""
class="empty"
fi
buf="$buf (eventbox :cursor \"hand\" (button :class \"$class\" :onclick \"bspc desktop -f $ws\" \"$icon\"))"
done
echo "(box :class \"widget workspaces\" :halign \"start\" :valign \"center\" :vexpand true :hexpand true $buf)"
}
# Listen to bspwm changes
print_workspaces
bspc subscribe desktop node_transfer | while read -r _ ; do
print_workspaces
spaces
socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | while read -r line; do
spaces
done