You are not logged in.
Hi again , I was capable to make sleep hooks for systemd to lock screen when suspend/hibernate and for wicd to reconect wifi in same way, but i cant figure out is how to make systemd only suspend when is on battery. Because if I edit /etc/systemd/logind.conf to handle the Lid events always suspend wheterever is on battery or AC, before I was using acpi to handle this, to make clear here is my handler.sh
#!/bin/sh
# Default acpi script that takes an entry for all actions
#minspeed=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq`
#maxspeed=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq`
#setspeed="/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed"
set $*
case "$1" in
button/power)
#echo "PowerButton pressed!">/dev/tty5
case "$2" in
PBTN|PWRF) logger "PowerButton pressed: $2";;
*) logger "ACPI action undefined: $2" ;;
esac
;;
button/sleep)
case "$2" in
SLPB) echo -n mem >/sys/power/state ;;
*) logger "ACPI action undefined: $2" ;;
esac
;;
ac_adapter)
case "$2" in
AC|ACAD|ADP0)
case "$4" in
00000000)
#echo -n $minspeed >$setspeed
#/etc/laptop-mode/laptop-mode start
;;
00000001)
#echo -n $maxspeed >$setspeed
#/etc/laptop-mode/laptop-mode stop
;;
esac
;;
*) logger "ACPI action undefined: $2";;
esac
;;
battery)
case "$2" in
BAT0)
case "$4" in
00000000) #echo "offline" >/dev/tty5
;;
00000001) #echo "online" >/dev/tty5
;;
esac
;;
CPU0)
;;
*) logger "ACPI action undefined: $2" ;;
esac
;;
button/lid)
case "$3" in
close)
#echo "LID closed!">/dev/tty5
STATE=$(cat /proc/sys/vm/dirty_writeback_centisecs)
if [[ $STATE == 60000 ]]
then
#/usr/sbin/pm-suspend
systemctl suspend
fi
;;
open)
#echo "LID opened!">/dev/tty5
;;
esac
;;
*)
logger "ACPI group/action undefined: $1 / $2"
;;
esac
In my laptop dirty_writeback_centisecs= 60000 when is on battery if AC is 500. I read this post where one user make a udev rule to know if system is on AC or battery but I cant how to figure out to use in some way like i was using with acpi.
I was thinking in some sleep hook like this (i will use pseudo code):
#!/bin/sh
if [ $1 == 'pre' ] ; then
STATE=$(cat /proc/sys/vm/dirty_writeback_centisecs)
if [[ $STATE == 60000 ]]
then
systemctl suspend
elif
break suspend (this is i dont know how to implement)
fi
fi
I hope I was clear enough, feel fre to ask any questions. And sorry for my bad english
Offline
You can't do this with systemd AFAIK. What's wrong with acpid? It works, right?
Offline
You can't do this with systemd AFAIK. What's wrong with acpid? It works, right?
Yes it works but if systemd can handle this eventes It would be good to get rid off of acpid because following this post I was capable of getting rid pm-utils .
Guess I'll have to keep using acpi until systemd can handle these events. Thanks.
Offline