How to make my SW12.1 go automatically in suspend state?
SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'll add to the query. Recently I saw some screen captures showing Suspend-to-RAM and Suspend-to-Disk options in the KDE shutdown dialog box. No such thing on my Slackware 12.1/KDE 3.5.9 box. Is there something that needs to be added? Kernel config? Third-party package?
Thanks. My box is a desktop model, not a laptop. KLaptop does not work here (no battery, no ac adapter, etc.) When I select the shutdown button, or press Ctrl-Alt-Del, the shutdown dialog box should provide the options to suspend to disk and suspend to ram, but does not.
Are there certain power management kernel modules that must be loaded to change the appearance of the shutdown dialog box? Or are the photos I have seen something unique to other distros but not available directly in Slackware?
Make sure you're in the power group. Other than that, you can make menu items yourself if you want. Still not automatic, but it makes it easy to do. My Suspend menu item (in KDE) runs the following command:
Code:
kdesu "/usr/bin/echo mem > /sys/power/state"
Of course, I have to enter the root password here. I could have rigged up a sudo entry, but the permissions on /sys/power/state would prevent writing to it, so they would have to be changed. This is doable, but I was lazy and I don't suspend much so I didn't put in the effort. Nonetheless, that is one option if adding yourself to the power group and booting into runlevel 4 does not provide the correct functionality (I don't boot into runlevel 4 so I don't know if it works or not).
Of course, I have to enter the root password here.
This is why pressing the power button is a much easier way to go into slumber - and it secures against mishaps resulting from someone accidently pressing it.
Quote:
My box is a desktop model, not a laptop
So you cannot use low batteries as an "event" to trigger hibernate
I want to make my pc go automatically in suspend state after some time.
Acpid needs an event to monitor. Everything it sees is logged in /var/log/acpid.
If you have your screen blanking after a certain time, then see if anything is written in log file regarding it - and then monitor for it in /etc/acpi/acpi_handler.sh as per the script above
ACPID is a completely flexible and expandable mechanism for delivering ACPI events from the kernel to user-space.
ACPID used to try to handle events internally. Rather than try to climb an ever-growing mountain, ACPID now lets YOU define what events to handle. Any event that publishes itself to /proc/acpi/event can be handled.
ACPID reads a set of configuration files which define event->action pairs. This is how you make it do stuff.
I have a usb mouse but I use a usb2ps2 converter. Any way I don't see a line for the "mouse" interrupts so I tried "-i 1" just to see if it worked. Nothing happened.
Did I use the sleepd program correctly?
I have seen somewhere in KDE the suspend and hibernate choices in log out dialog - may be is SLAX : confused:
I have been pondering some of the responses in this thread.
I downloaded build scripts for kpowersave and kshutdown and installed the packages. Okay tools but not what I wanted. I also prefer universal solutions that apply to all runlevels or desktop environments.
I next opened konsole. As root I ran echo mem > /sys/power/state. My box and monitor immediately went into suspend to ram state. Simple and straightforward. While in S2 state my box and monitor consumed only 8 watts of energy from the normal 82 watts (LCD monitor uses 22 watts). Not bad.
I waited several seconds and pressed the power button on the computer case. The system restored perfectly and much quicker than the normal boot process. For this experiment I was in runlevel 4.
T3slider seems to have a good idea as far as a direct approach to achieve S2 suspend to ram state.
Yet after completing this experiment I realized that forcing my box into suspend to ram might not be a great idea.
First, being Slackware this is a multi-user box. What happens if I suspend to ram and another person is logged in? I tried just that and found no immediate issues. Both desktops restored without a hitch.
Second, I run all of my important cron tasks in the afternoon because I power off my box when I quit for the day. I suspected that placing my box into suspend mode would mean my cron jobs wouldn't run.
My "hourly" rsnapshot backups occur at 52 minutes past the hour, every three hours. As a simple test, I waited until 50 minutes past the hour for the next three-hour period and then from the command line performed a suspend to ram. I waited until 55 minutes past the hour and pressed the power button.
As expected no backup had occurred. I then proceeded to manually run the backup but rsnapshot responded that a pid file already existed. Apparently about 20 or 30 seconds after the system restored to normal state, cron somehow picked up the missing pieces and ran the backup.
As a second test, I created a crontab entry to touch a new file. I then repeated the suspend to ram, waited 8 minutes, and then restored my session. Cron again performed the "missed" task about 20 or 30 seconds after restoring to normal state.
Is this normal or expected? How much of a delay is needed before cron skips any missed tasks? If I understand correctly, suspend to ram (S2) means the CPU is not operating. So how does cron run these missed tasks?
I changed /sys/power/state group to ´power´ and added write permission to group, is this the right way to achieve passwordless suspend with "echo mem > /sys/power/state" command?
It works rather fine with my desktop computer, two minor things i´ve noticed were: lost compiz menu shadows after resume and my computer hangs while restarting from the resumed state just after the ´now restarting´ last bits of shutdown log.
Resuming is actually very appealing, just few seconds and desktop is up and running. It also wakes up on keyboard key press. I´ve been expecting a lot of work to get this to work with slackware, what a nice surprise !
This way, there is no pause in time with the suspend feature, else it wakes up at the same time as it was suspended...
Aha! That would explain why cron still ran after I suspended to ram.
Quote:
Don't forget to run /sbin/hwclock --systohc before you put computer in suspend state and run /sbin/hwclock --hctosys after it wakes up
Okay, I run a simple two-line shell script to perform the former:
/sbin/hwclock --localtime --systohc
/usr/bin/echo mem > /sys/power/state
Resuming from a suspend to ram requires pressing the case power button. From there the system restoration is automatic. Where then should the command to reset the clock be run (/sbin/hwclock --localtime --hctosys)? I found an example with harryhaller's hibernate.sh script. The command goes in the same script. Basically, what I did not realize is that once the suspend command is given, the shell script suspends at that point. Okay, that deserves a Homer Simpson "Doh!"
This discussion prompts two more questions. Yesterday I ran echo mem > /sys/power/state from the command line with no X running. Pressing the case power button restored the system, but I never received any video signal. My monitor power light kept blinking as though the monitor had remained in DPMS mode. I performed a traditional three-finger salute and heard the box reboot and then all was well again. What happened to the video signal? Seems somebody recently experienced the same thing but now I can't find the thread.
Second question: now that I (Doh!) know how to programmatically and methodically suspend and restore, how do I query cron to run any missed cron jobs that were scheduled to run during the suspend period?
For the crontab jobs, an idea could be: save system time in bios time, set the system time some minutes or seconds before the cron jobs, let it execute its jobs then reset your system time from bios time...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.