From 5c394bfd80f27aa1d92124b884966e8875fed43b Mon Sep 17 00:00:00 2001 From: teddy Date: Thu, 8 Jan 2026 13:40:02 +0100 Subject: [PATCH] battery-notify script --- config | 10 +++++++++- scripts/battery-notify.sh | 13 +++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100755 scripts/battery-notify.sh diff --git a/config b/config index 5ed0bbb..740d048 100644 --- a/config +++ b/config @@ -38,11 +38,17 @@ set $menu wofi --show drun include /etc/sway/config-vars.d/* -### Output configuration (monitors) +### Output configuration (monitors) work output HDMI-A-1 resolution 2560x1440 position 0,0 output DP-6 resolution 2560x1440 position 2560,0 output DP-7 resolution 1440x2560 position 5120,0 transform 270 output eDP-1 resolution 1920x1200 position 7680,0 + +# Home setup +# output DP-3 resolution 1920x1080 position 0,0 +# output HDMI-A-1 resolution 3440x1440 position 1920,0 + + output * bg /home/tor/Pictures/background/useThis.jpg fill # Laptop lid switch @@ -86,6 +92,8 @@ exec mako exec dbus-update-activation-environment --all exec gnome-keyring-daemon --start --components=pkcs11,secrets,ssh exec wl-paste --watch cliphist store +exec --no-startup-id mako +exec --no-startup-id while true; do ~/.config/sway/scripts/battery-notify.sh; sleep 300; done ### Idle configuration (from your swaylock setup) exec swayidle -w \ diff --git a/scripts/battery-notify.sh b/scripts/battery-notify.sh new file mode 100755 index 0000000..02dfb85 --- /dev/null +++ b/scripts/battery-notify.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +battery_level=$(cat /sys/class/power_supply/BAT0/capacity) +battery_status=$(cat /sys/class/power_supply/BAT0/status) + +# Only warn when discharging (not plugged in) +if [[ $battery_status == "Discharging" ]]; then + if [[ $battery_level -le 15 ]]; then + notify-send -u critical "⚠️ Battery Critical" "Only ${battery_level}% remaining! Plug in NOW!" + elif [[ $battery_level -le 30 ]]; then + notify-send -u normal "🔋 Battery Low" "Battery at ${battery_level}%. Consider plugging in soon." + fi +fi