From d41ea45326100525fe8130ce2937ba748175f1e7 Mon Sep 17 00:00:00 2001 From: GaspardCulis Date: Fri, 26 Jan 2024 09:58:21 +0100 Subject: [PATCH] eww-bard: Added script --- bin/eww-bard | 46 ++++++++++++++++++++++++++++++++++++++++++++++ sync | 1 + 2 files changed, 47 insertions(+) create mode 100755 bin/eww-bard diff --git a/bin/eww-bard b/bin/eww-bard new file mode 100755 index 0000000..d028560 --- /dev/null +++ b/bin/eww-bard @@ -0,0 +1,46 @@ +#!/bin/dash + +WIDGET_NAME=bar + +mon_count=0 + +# Generates $1 different window names +gen_names () { + end=$(($1-1)) + out="" + for i in $(seq 0 $end); do + out="$out $WIDGET_NAME:$WIDGET_NAME$i" + done + echo $out +} + +# Generates $1 monitor args +gen_args () { + end=$(($1-1)) + out="" + for i in $(seq 0 $end); do + out="$out --arg $WIDGET_NAME$i:monitor=$i" + done + echo $out +} + +update (){ + monitors=$(hyprctl monitors -j) + count=$(echo "$monitors" | jq -c length) + + if [ $mon_count -ne $count ]; then + # Close bars + eww close $(seq -s " " 0 $(($mon_count-1))) + # Open new window count + echo "eww open-many $(gen_names $count) $(gen_args $count)" + eww open-many $(gen_names $count) $(gen_args $count) + # Update mon_count + mon_count=$count + fi +} + +update +socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | while read -r line; do + update +done + diff --git a/sync b/sync index 31600a8..0c853c4 100755 --- a/sync +++ b/sync @@ -68,6 +68,7 @@ synced_files = [ ("bin/mc-key-fix", "~/.local/bin/mc-key-fix"), ("bin/x11-toggle-primary-gpu", "~/.local/bin/x11-toggle-primary-gpu"), ("bin/uwu-launcher", "~/.local/bin/uwu-launcher"), + ("bin/eww-bard", "~/.local/bin/eww-bard"), # Submodules ("Ahurac-dotfiles/bin/ssh-fwd", "~/.local/bin/ssh-fwd"), ]