M .config/x11/xprofile => .config/x11/xprofile +1 -1
@@ 15,7 15,7 @@ else
xrandr --dpi 128 # Desktop 1440p scaled
fi
~/.screenlayout/main.sh # Set up monitor layout
-setxkbmap -option caps:none # Completely disable Caps Lock
+setxkbmap -option caps:super # Caps Lock acts as Super
xrdb -merge ${XDG_CONFIG_HOME:-$HOME/.config}/x11/xresources # Load base Xresources
# HiDPI: on laptops tell Xft apps (st, dmenu, dwm bar) the real DPI and scale
# the cursor. Merged after the base so it wins.
M .local/bin/statusbar/sb-battery => .local/bin/statusbar/sb-battery +20 -2
@@ 16,8 16,10 @@ case $BLOCK_BUTTON in
6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
-# Loop through all attached batteries and format the info
-for battery in /sys/class/power_supply/BAT?*; do
+# Loop through all attached batteries and format the info. Match by type
+# rather than a BAT?* name glob so Asahi's "macsmc-battery" is picked up too.
+for battery in /sys/class/power_supply/*; do
+ [ -r "$battery/type" ] && [ "$(cat "$battery/type")" = "Battery" ] || continue
# If non-first battery, print a space separator.
[ -n "${capacity+x}" ] && printf " "
# Sets up the status and capacity
@@ 50,6 52,22 @@ for battery in /sys/class/power_supply/BAT?*; do
esac
# Will make a warn variable if discharging and low
[ "$charging_status" = "Discharging" ] && [ "$capacity" -le 25 ] && warn=""
+ # Low-battery notifications to dunst at 20/10/5%. State file avoids
+ # re-notifying every refresh; only fires once per band while discharging.
+ statefile="${XDG_CACHE_HOME:-$HOME/.cache}/sb-battery-band"
+ if [ "$capacity" -le 5 ]; then band=5
+ elif [ "$capacity" -le 10 ]; then band=10
+ elif [ "$capacity" -le 20 ]; then band=20
+ else band=0; fi
+ prevband=$(cat "$statefile" 2>/dev/null) || prevband=0
+ if [ "$charging_status" = "Discharging" ] && [ "$band" -ne 0 ] && [ "$band" != "$prevband" ]; then
+ case "$band" in
+ 5) notify-send -u critical " Battery critical" "$capacity% remaining -- plug in now" ;;
+ 10) notify-send -u critical " Battery very low" "$capacity% remaining" ;;
+ 20) notify-send -u normal " Battery low" "$capacity% remaining" ;;
+ esac
+ fi
+ printf '%s' "$band" > "$statefile" 2>/dev/null
# Prints the info
printf "%s%s %d%%" "$status" "$warn" "$capacity"; unset warn
done && printf "\\n"