diff options
Diffstat (limited to 'gen_waybar_confs.sh')
-rwxr-xr-x | gen_waybar_confs.sh | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/gen_waybar_confs.sh b/gen_waybar_confs.sh index 36befae..b13d8d7 100755 --- a/gen_waybar_confs.sh +++ b/gen_waybar_confs.sh @@ -2,9 +2,17 @@ WCLONG="$(crcparse WC)" WC="$(basename "$WCLONG")" +CONFIG="${XDG_CONFIG_HOME:-$HOME/.config}" +if [ ! -f "$CONFIG/waybar/config-$WC" ]; then + printf "$CONFIG/waybar/config-$WC waybar config does not exist!\n" + exit 1 +fi -OUTPUTS="$(wlr-randr | grep -B2 'Enabled: yes' | sed '/^\s\s*/d;/^--/d' | cut -d' ' -f1)" +OUTPUTS="$(wlr-randr | grep -B5 'Enabled: yes' | sed '/^\s\s*/d;/^--/d' | cut -d' ' -f1)" + +[ -n "$OUTPUTS" -a -z "$(find "$CONFIG"/waybar -name "config-$WC-*")" ] && \ + rm -rf "$CONFIG/waybar/config-$WC-*" echo "$OUTPUTS" | while read i; do - sed 's/%%DISPLAY%%/'$i'/' "$XDG_CONFIG_HOME"/waybar/config-$WC > "$XDG_CONFIG_HOME"/waybar/config-$WC-$i + sed 's/%%DISPLAY%%/'$i'/' "$CONFIG"/waybar/config-$WC > "$CONFIG"/waybar/config-$WC-$i done |