summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzachir <zachir@librem.one>2023-02-26 15:24:39 -0600
committerzachir <zachir@librem.one>2023-02-26 15:24:39 -0600
commit20dc0bbfd4f58a0dc00bf41c7285cb7465118806 (patch)
tree1b89276a0ee9a157be4f9d3269280f3a1ddaed8e
parent1e3dabf718834e6cebbb0c48fcff42309eca8f58 (diff)
fix for hyprland
-rwxr-xr-xgen_waybar_confs.sh12
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