You are not logged in.
Hi ! i have i3-gaps on my laptop and i want to make a notification with dunstify when my battery is low.
So i made a systemd script under /etc/systemd/system/low_battery.service like this:
[Unit]
Description=Send alerts on low battery
[Service]
Type=simple
ExecStart=/bin/bash /home/myUser/.config/i3/low_battery_alert.sh>
Environment="DISPLAY=:0.0" "XAUTHORITY=/home/myUser/.Xauthority">
Restart=always
RestartSec=60
[Install]
WantedBy=multi-user.targetI made low_battery_alert.sh like this:
#!/bin/bash
if [ $(cat /sys/class/power_supply/AC0/online) = "0" ] && \
[ $(cat /sys/class/power_supply/BAT0/energy_now) -lt "4000000" ]; then
# Display Notification
if [ $DISPLAY ]; then dunstify -u critical \
-i battery_low \
-t 2000 "Battery Critically Low" "Plug in to AC or Suspend immediately"
# Play Alert Sound
canberra-gtk-play -f "/usr/share/sounds/deepin/stereo/power-plug.wav"
fi
filow_battery_alert.sh works because when my battery is low i hear the sound of canberra-gtk-play,
but there is no notification pop up and i can't understand why.
If i use same command "dunstify -u critical -i battery_low ..." in a terminal i can see notification on the top of my screen.
So i think is relate to something of DISPLAY variable of systemd. Thanks for any help!
Last edited by Anzu (2019-06-06 23:09:16)
Offline
Please edit your post and use [ code ] tags when posting output.
https://wiki.archlinux.org/index.php/Co … s_and_code
https://bbs.archlinux.org/help.php#bbcode
Offline
$DBUS_SESSION_BUS_ADDRESSOffline
$DBUS_SESSION_BUS_ADDRESS
I have tried to search for it on google and found it some solutions, but didn't work for me. So still i have problem to show notification with a daemon
Offline
tried … some … didn't work … have problem
Offline