summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyren223 <Kyren223@proton.me>2024-11-21 13:02:36 +0200
committerKyren223 <Kyren223@proton.me>2024-11-21 13:02:36 +0200
commitd2608358a289343cba5d7a43b3b636cffd8cbd99 (patch)
tree33be929ac474280196d333ea7092fca62bcb6987
parent60596c6680ac49951828031fb72746656558a940 (diff)
Made battery notifications work
-rw-r--r--.zshrc4
-rwxr-xr-xscripts/battery_notifier.sh16
2 files changed, 8 insertions, 12 deletions
diff --git a/.zshrc b/.zshrc
index f8699e6..af12135 100644
--- a/.zshrc
+++ b/.zshrc
@@ -94,6 +94,10 @@ eval $(keychain --quiet --eval --timeout 300 ~/.ssh/id_ed25519)
# Open tmux if it's not open
if [ -z "$TMUX" ]; then
tmux a || tmux
+ # HACK: Send a notification so systemd notification will work
+ # Using tmux to only run this at startup
+ # I guess this works because it initializes some stuff?
+ notify-send --urgency=normal --expire-time=1 " "
fi
END_TIME=$(date +%s.%4N)
diff --git a/scripts/battery_notifier.sh b/scripts/battery_notifier.sh
index 17e77f8..96043c8 100755
--- a/scripts/battery_notifier.sh
+++ b/scripts/battery_notifier.sh
@@ -1,22 +1,14 @@
set -eu
export DISPLAY=:0.0
-export XAUTHORIRTY=/home/kyren/.Xauthority
-
-
-echo "$DISPLAY, $XAUTHORIRTY" >> "$HOME/Desktop/debug.log"
+export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus
battery_level=$(cat /sys/class/power_supply/BAT0/capacity)
battery_status=$(cat /sys/class/power_supply/BAT0/status)
-echo "$battery_level% $battery_status" >> "$HOME/Desktop/debug.log"
-
-/etc/profiles/per-user/kyren/bin/notify-send --urgency=normal \
- --app-name="Battery Notifier" \
- --expire-time=5000 \
- "Battery at $battery_level%, unplug!" >> "$HOME/Desktop/debug.log" 2>&1
+echo "Battery: $battery_level% $battery_status" >> "$HOME/Desktop/debug.log"
if [ "$battery_status" = "Charging" ] && [ "$battery_level" -ge 80 ]; then
- touch "$HOME/Desktop/WHY"
- /etc/profiles/per-user/kyren/bin/notify-send --urgency=normal \
+ echo "Notification sent" >> "$HOME/Desktop/debug.log"
+ /etc/profiles/per-user/kyren/bin/notify-send --urgency=normal \
--app-name="Battery Notifier" \
--expire-time=5000 \
"Battery at $battery_level%, unplug!" >> "$HOME/Desktop/debug.log" 2>&1