From 27d14261fbb59286f46cb056f02c3a42289907ba Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Tue, 20 May 2025 14:50:05 +0200 Subject: [PATCH] adds waybar reload on config change --- .config/hypr/config/autostart.conf | 2 +- .config/hypr/scripts/launch-waybar.sh | 33 +++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100755 .config/hypr/scripts/launch-waybar.sh diff --git a/.config/hypr/config/autostart.conf b/.config/hypr/config/autostart.conf index 4f0909a..5e72d3b 100644 --- a/.config/hypr/config/autostart.conf +++ b/.config/hypr/config/autostart.conf @@ -6,7 +6,7 @@ source = ~/.config/hypr/config/defaults.conf # Autostart wiki https://wiki.hyprland.org/0.45.0/Configuring/Keywords/#executing # -exec-once = waybar & +exec-once = /home/michaelb/.config/hypr/scripts/launch-waybar.sh & exec-once = blueman-applet & exec-once = fcitx5 -d & exec-once = mako & diff --git a/.config/hypr/scripts/launch-waybar.sh b/.config/hypr/scripts/launch-waybar.sh new file mode 100755 index 0000000..7d125a5 --- /dev/null +++ b/.config/hypr/scripts/launch-waybar.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# start waybar if not started +if ! pgrep -x "waybar" > /dev/null; then + waybar & +fi + +# current checksums +current_checksum_config=$(md5sum ~/.config/waybar/config) +current_checksum_style=$(md5sum ~/.config/waybar/style.css) +current_checksum_colors=$(md5sum ~/.config/waybar/colors-wallust.css) + +# loop forever +while true; do + # new checksums + new_checksum_config=$(md5sum ~/.config/waybar/config) + new_checksum_style=$(md5sum ~/.config/waybar/style.css) + new_checksum_colors==$(md5sum ~/.config/waybar/colors-wallust.css) + + # if checksums are different + if [ "$current_checksum_config" != "$new_checksum_config" ] || [ "$current_checksum_style" != "$new_checksum_style" ] || [ "$current_checksum_colors" != "$new_checksum_colors" ]; then + # kill waybar + killall waybar + + # start waybar + waybar & + + # update checksums + current_checksum_config=$new_checksum_config + current_checksum_style=$new_checksum_style + current_checksum_colors=$new_checksum_colors + fi +done \ No newline at end of file