Closing this old thread.
]]>@teateawhy: This script depends on pm-utils installed which I wanted to prevent.
No this script does NOT depend on pm-utils, i changed it to use systemctl instead 3 months ago. The script runs on my server that does not have pm-utils.
$ pacman -Q pm-utils
error: package 'pm-utils' was not found
Please read my first post again.
]]>#!/bin/bash
# Source the configuration file
. /etc/autosuspend.conf
# Log system notice
logit()
{
logger -p local0.notice -s -- AutoSuspend: $*
return 0
}
# Look for other CLIENTS in the network
IsOnline()
{
for i in $*; do
ping $i -c1
if [ "$?" == "0" ]; then
logit "CLIENT $i is still active, auto suspend terminated"
return 1
fi
done
return 0
}
IsRunning()
{
for i in $*; do
if [[ `pgrep -c $i` > 0 ]] ; then
logit "PROCESS $i still active, auto suspend terminated"
return 1
fi
done
return 0
}
IsDaemonActive()
{
for i in $*; do
if [[ `pgrep -c $i` > 1 ]] ; then
logit "DAEMON $i still active, auto suspend terminated"
return 1
fi
done
return 0
}
IsBusy()
{
# Samba
if [ "$SAMBANETWORK" ]; then
if [ `/usr/bin/smbstatus | grep $SAMBANETWORK | wc -l ` != "0" ]; then
logit "SAMBA connected, auto suspend terminated"
return 1
fi
fi
#daemons that always have one process running
IsDaemonActive $DAEMONS
if [ "$?" == "1" ]; then
return 1
fi
#backuppc, wget, wsus, ....
IsRunning $APPLICATIONS
if [ "$?" == "1" ]; then
return 1
fi
# No Suspend if there are any users logged in
if [[ `who | wc -l` > 0 ]];then
logit "USERS still connected, auto suspend terminated";
return 1
fi
IsOnline $CLIENTS
if [ "$?" == "1" ]; then
return 1
fi
return 0
}
IDLE_FILE="/var/spool/autosuspend_idle_marker"
OFFFILE="/var/spool/autosuspend_off"
# turns off the auto suspend
if [ -e $OFFFILE ]; then
logit "auto suspend is turned off by existents of $OFFFILE"
exit 0
fi
if [ "$AUTO_SUSPEND" = "no" ]; then
logit "auto suspend is turned off in configuration file /etc/autosuspend.conf"
elif [ "$AUTO_SUSPEND" = "yes" ]; then
# Check if system is busy now.
IsBusy
if [ "$?" == "0" ]; then
# Idle now. Has the system been idle on the previous check?
if [ -e $IDLE_FILE ]; then
# Suspend now.
logit "AUTO SUSPEND CAUSED"
rm -f $IDLE_FILE
systemctl suspend
exit 0
else
# Mark system as idle for the next check.
touch $IDLE_FILE
logit "marked as idle for next check"
exit 0
fi
else
# Busy now. Mark system as busy for the next check.
rm -f $IDLE_FILE
logit "marked as busy for the next check"
exit 0
fi
exit 0
else
logit "misconfiguration. Check /etc/autosuspend.conf"
fi
exit 1
Source:
http://wiki.ubuntuusers.de/Skripte/AutoSuspend
(German with code commented in english.)
if [ -d $HOME/.config/autostart ]; then
for c in $HOME/.config/autostart/* ; do
[ -x "$c" ] && . "$c"
done
unset c
fi
I believe that it shouldn't be difficult for you to create a 'suspend.desktop' file there as well and run it without any reference to .xinitrc.)
]]>pidof -s xautolock >& /dev/null
if [ $? -ne 0 ]; then
xautolock -time 60 -locker "systemctl suspend" &
fi
(Solved) Simple auto-suspend script?
I'm looking for a simple solution to auto-suspend (ram/disk) a system after a certain time of inactivity. I can find surprisingly little info for this for linux (or perhaps i'm not looking in the right places), while windows for instance has this built in for years already.'
In this thread I could not find any comprehensible solution for me.
pm_utils article says: 'This article or section is out of date.' and refers to systemd.
systemd article does not answer the question, how to auto(!) suspend the system in any way.
Also tried laptop-mode-tools which are producing strange errors as described here and only react on acpi events during uptime (settings are ignored on boot till I manually restart laptop-mode or initiate an acpi event).
Hibernation and suspend work without problems when manual acticated.
It's 'only' the question, how to autosuspend after a specified time of inactivity.
Isn't there a simple, an easy way (kiss?) to tell the system to suspend after a while without having to install a complete 'power management framework'. Perhaps some hidden *.conf or *.cfg somwhere in the depths of systemd or arch?
Any ideas?
]]>