You are not logged in.
Pages: 1
Topic closed
I've similar problem:
(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?
Last edited by renegat (2013-02-01 20:13:43)
Offline
Does litemotive's solution not work? Can't you just combine it with systemctl suspend?
Offline
The only 'solution' given in this thread was to install 'sleepd-git' which is 'Flagged out-of-date (2012-10-29)' and does not work for me (see comments). Or did I miss sth?
Offline
No; you just didn't mention in your first post that sleepd appears to be a dead project...
Offline
That's what I'm using (place it e.g. at the bottom of .xinitrc):
pidof -s xautolock >& /dev/null
if [ $? -ne 0 ]; then
xautolock -time 60 -locker "systemctl suspend" &
fi
:: Registered Linux User No. 223384
:: github
:: infinality-bundle+fonts: good looking fonts made easy
Offline
Looks really fine but the ~/.xinitrc file is a shell script read by xinit and startx, right?
I use LXDM to autologin and start LXDE.
I don't know if .xinitrc will be even read.
Really thought this elementary functionality was already implemented somwhere inside arch or systemd (as it grabs more and more functionality from other programms) and has only to be enabled or set somewhere.
Offline
I'm not quite sure how LXDE organizes autostart applications, but you can simply create a script that's loaded with your DE. (BTW, that's how I do it, without any DE, though: I have a collection of executable bash scripts in my .config/autostart/ directory, with the following in .xinitrc:
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.)
Last edited by bohoomil (2013-02-01 15:03:40)
:: Registered Linux User No. 223384
:: github
:: infinality-bundle+fonts: good looking fonts made easy
Offline
There are methods that work without Xorg, too. For example this autosuspend script i use on my server:
#!/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.)
Offline
Thank you - bohoomils ways work fine now by dropping LXDM and using autologin to virtual console and then autostart X in ~/.bash_profile.
Now the .xinitrc scripts are read.
@teateawhy: This script depends on pm-utils installed which I wanted to prevent.
Offline
@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.
Offline
@teateawhy: Sorry, you are right! Your script uses systemd functionality not pm-utils.
I only checked your given source @ubuntuusers.de which says so and did not recognize your script has been modified.
I'll try your script next days on my server without X.
Thank you.
Offline
I know posting to old threads is discouraged. But I found teateawhys script here some weeks ago, liked it, spend some love to it and made it now public.
Offline
Thanks for sharing something new and potentially related, If you want to discuss the script further, please open a new thread in "Community Contributions" or so.
Closing this old thread.
Offline
Pages: 1
Topic closed