Bug fixes from quality and security audits: - moonarch-capsnote: use value[0] instead of value[2] - moonarch-btnote: guard empty PER_INT before integer comparison - moonarch-clipboard + niri config: use XDG_RUNTIME_DIR instead of UID 1000 - moonarch-waybar-hidpp: use charging icon when charging - moonarch-waybar-gpustat: find gpu_busy_percent dynamically across hwmon* - post-install/transform: use systemctl --user cat for service detection - post-install/transform: install paru from [extra] instead of AUR clone Replace wlogout with moonset in niri keybind and waybar on-click. Remove moonarch-session (dead code, replaced by moonset) and wlogout layout config.
20 lines
728 B
Bash
Executable File
20 lines
728 B
Bash
Executable File
#!/bin/bash
|
|
# ABOUTME: Checks Bluetooth devices for low battery and sends a notification.
|
|
# ABOUTME: Can be run periodically via timer or cron.
|
|
|
|
NOTIFY_AT_PERCENTAGE=70
|
|
ICON="battery-empty"
|
|
|
|
for d in $(upower -e); do
|
|
DEVICE_DATA=$(upower -i "$d")
|
|
PERCENTAGE=$(echo $DEVICE_DATA | grep -Po '(?<=(percentage: )).*(?= icon)')
|
|
PER_INT=$(echo "${PERCENTAGE//%}")
|
|
DEVICE_NAME=$(echo $DEVICE_DATA | grep -Po '(?<=(model: )).*(?= serial)')
|
|
|
|
if [ -n "$DEVICE_NAME" ] && [ -n "$PER_INT" ] && [ "$PER_INT" -lt "$NOTIFY_AT_PERCENTAGE" ]; then
|
|
notify-send -t 5000 -e "Low battery $DEVICE_NAME $PER_INT%" -i "$ICON" \
|
|
-h string:x-canonical-private-synchronous:battery \
|
|
-h int:value:"$PER_INT" -u critical
|
|
fi
|
|
done
|