Made battery notifications work
This commit is contained in:
4
.zshrc
4
.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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user