battery-notify script

This commit is contained in:
teddy 2026-01-08 13:40:02 +01:00
parent 16cf74dffa
commit 5c394bfd80
2 changed files with 22 additions and 1 deletions

10
config
View file

@ -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 \

13
scripts/battery-notify.sh Executable file
View file

@ -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