I need to enable power (AC) failure (off-line) and power on (on-line) notifications, like this notification:
I searched and tried to do that, but I didn't find any successful articles. I use these commands to monitor my AC adapter:
acpi- a
echo ac_adapter=$(acpi -a | cut -d' ' -f3 | cut -d- -f1)
But I don't know how to write notification on code.
Can I write a shell script like the following?
#!/bin/bash
power=ac_adapter=$(acpi -a | cut -d' ' -f3 | cut -d- -f1)
s1="$power"
if [ "$s1" = "off-line" ]; then
notify-send --urgency=low "Power Manager" "Power Down" -i battery_low
echo "notification: off" >~/.scripts/notification
else
if [ $s1 = "on-line" ]; then
notify-send --urgency=normal "Power Manager" "Power Up" -i battery_full
fi
fi
./script.sh: line 5: [: ==: unary operator expected
./script.sh: line 7: [: ==: unary operator expected
And i made some changesif [ "$stat" == 'yes' ] elif [ "$stat" == 'no' ]
Is it correct – sameermw Jul 11 '14 at 16:25echo $(upower -i /org/freedesktop/UPower/devices/line_power_ACAD | grep online | awk '{ print $2}')
Any idea Sir? – sameermw Jul 11 '14 at 16:30Device: /org/freedesktop/UPower/devices/battery_BAT0 native-path: BAT0 vendor: Samsung SDI model: DELL JXFRP1C serial: 9489 power supply: yes updated: Fri 11 Jul 2014 09:51:37 PM IST (825 seconds ago) has history: yes has statistics: yes
– sameermw Jul 11 '14 at 16:35Device: /org/freedesktop/UPower/devices/line_power_AC native-path: AC power supply: yes updated: Fri 11 Jul 2014 09:51:15 PM IST (847 seconds ago) has history: no has statistics: no line-power online: yes
– sameermw Jul 11 '14 at 16:35--expire-time=5
But notification never expire, how do i add--expire-time=
option to time out. – sameermw Jul 11 '14 at 16:44