diff --git a/migrations/1776674079.sh b/migrations/1776674079.sh new file mode 100644 index 00000000..6d233599 --- /dev/null +++ b/migrations/1776674079.sh @@ -0,0 +1,10 @@ +echo "Pin waybar battery module to BAT0 to prevent crash on HID battery disconnect" + +CONFIG_FILE=~/.config/waybar/config.jsonc + +if [[ -f "$CONFIG_FILE" ]] \ + && ! grep -Eq '"bat"[[:space:]]*:' "$CONFIG_FILE" \ + && grep -Eq '"battery"[[:space:]]*:[[:space:]]*\{' "$CONFIG_FILE"; then + sed -i -E '/"battery"[[:space:]]*:[[:space:]]*\{/a\ "bat": "BAT0",' "$CONFIG_FILE" + omarchy-restart-waybar +fi