diff --git a/bin/omarchy-battery-monitor b/bin/omarchy-battery-monitor index b0da0d9e..6b348b11 100755 --- a/bin/omarchy-battery-monitor +++ b/bin/omarchy-battery-monitor @@ -9,6 +9,7 @@ BATTERY_STATE=$(upower -i $(upower -e | grep 'BAT') | grep -E "state" | awk '{pr send_notification() { notify-send -u critical "󱐋 Time to recharge!" "Battery is down to ${1}%" -i battery-caution -t 30000 + omarchy-hook battery-low "$1" } if [[ -n $BATTERY_LEVEL && $BATTERY_LEVEL =~ ^[0-9]+$ ]]; then diff --git a/config/omarchy/hooks/battery-low.sample b/config/omarchy/hooks/battery-low.sample new file mode 100644 index 00000000..dc3726a9 --- /dev/null +++ b/config/omarchy/hooks/battery-low.sample @@ -0,0 +1,10 @@ +#!/bin/bash + +# This hook is called with the current battery percentage when the low battery +# notification is sent. To put it into use, remove .sample from the name. + +SOUND_FILE="/usr/share/sounds/freedesktop/stereo/dialog-warning.oga" + +if omarchy-cmd-present mpv && [[ -f $SOUND_FILE ]]; then + mpv --no-video "$SOUND_FILE" >/dev/null 2>&1 +fi diff --git a/migrations/1772990935.sh b/migrations/1772990935.sh new file mode 100644 index 00000000..2f3526c2 --- /dev/null +++ b/migrations/1772990935.sh @@ -0,0 +1,7 @@ +echo "Add sample low battery notification hook" + +mkdir -p ~/.config/omarchy/hooks + +if [[ ! -f ~/.config/omarchy/hooks/battery-low.sample ]]; then + cp "$OMARCHY_PATH/config/omarchy/hooks/battery-low.sample" ~/.config/omarchy/hooks/battery-low.sample +fi