You are not logged in.
Hi
I try write script whose have check if laptop is discharged or charged and matches right xautolock options.
If xautolock is running, i want kill him and run again.
But i have a trouble.
This is my script:
check(){
if grep -Fxq "Discharging" /sys/class/power_supply/BAT0/status;
then
echo "BATTERY!" && xautolock -time 10 -locker "systemctl suspend" &
else
echo "AC POWER!" && xautolock -time 30 -locker "systemctl suspend" &
fi
}
#function kill xautolock process if found him, if not run check function
kill_xautolock(){
if [ -n "$(pidof xautolock)" ]
then
killall xautolock && check
else
check
fi
}
while true; do
kill_xautolock
sleep 10
done
I can't kill xautolock by no means. This way not working.
Can anybody help me, because I thinking about it whole day and i don't know what is wrong.
Offline
Why don't you try "xautolock -exit"? Also you kill xautlock every 10 seconds and then restart it, you should kill it only when the discharging status changes.
Last edited by progandy (2012-09-13 13:19:06)
| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |
Offline
This is the point. xautolock don't want be dead with killall command, and even by -exit option... This is what i can't fix.
And you're right i should kill it only when dischargins changed, but i haven't idea how do this...
Offline