LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 09-17-2008, 07:26 AM   #1
kairen
Member
 
Registered: Oct 2006
Location: Bulgaria
Distribution: Slackware64 14.1, CentOS 7
Posts: 108

Rep: Reputation: 15
How to make my SW12.1 go automatically in suspend state?


Hi,
I want to make my pc go automatically in suspend state after some time. I tried Kpowersave but with no luck - it reported some errors.

I googled and found a script to suspend the pc and it worked fine but I need to automate the process .

Any ideas are welcomed.
 
Old 09-18-2008, 01:37 PM   #2
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.1
Posts: 3,482

Rep: Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546
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?
 
Old 09-18-2008, 01:59 PM   #3
harryhaller
Member
 
Registered: Sep 2004
Distribution: Slackware-14.2
Posts: 468

Rep: Reputation: Disabled
Mini_HOW_TO_Hibernate_and_resume_0

Any help?

Also a post I wrote may help you - though I do not hibernate/suspend automatically.
 
Old 09-18-2008, 09:18 PM   #4
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.1
Posts: 3,482

Rep: Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546
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?
 
Old 09-18-2008, 09:47 PM   #5
T3slider
Senior Member
 
Registered: Jul 2007
Distribution: Slackware64-14.1
Posts: 2,367

Rep: Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843
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).
 
Old 09-19-2008, 02:59 AM   #6
harryhaller
Member
 
Registered: Sep 2004
Distribution: Slackware-14.2
Posts: 468

Rep: Reputation: Disabled
Quote:
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
 
Old 09-19-2008, 03:59 AM   #7
harryhaller
Member
 
Registered: Sep 2004
Distribution: Slackware-14.2
Posts: 468

Rep: Reputation: Disabled
Quote:
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

I haven't tried this though.

Please report back when you succeed!
 
Old 09-19-2008, 04:09 AM   #8
harryhaller
Member
 
Registered: Sep 2004
Distribution: Slackware-14.2
Posts: 468

Rep: Reputation: Disabled
Quote:
ACPID description

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.
From here

This refers to the same version of acpid installed in Slackware 12.1.
 
Old 09-19-2008, 06:03 AM   #9
harryhaller
Member
 
Registered: Sep 2004
Distribution: Slackware-14.2
Posts: 468

Rep: Reputation: Disabled
this looks interesting:

sleepd:

Quote:
sleepd is a daemon to to put a laptop to sleep if it is not being used or if the battery is low.

It supports HAL, APM, and ACPI, although external programs must be used to actually put the system to sleep]
I would imagine this would work for a desktop as well. I will report back.

Here are the downloads:
http://ftp.univ-pau.fr/linux/mirrors...main/s/sleepd/

And here is a Slackware package for Slackware 10.2:
http://www.linuxpackages.net/pkg_details.php?id=8655

Last edited by harryhaller; 09-19-2008 at 06:43 AM. Reason: Download links
 
Old 09-19-2008, 04:15 PM   #10
kairen
Member
 
Registered: Oct 2006
Location: Bulgaria
Distribution: Slackware64 14.1, CentOS 7
Posts: 108

Original Poster
Rep: Reputation: 15
I tried sleepd with:
> sleepd -u 60 -i 1

as my /proc/interrupts file looks like:

CPU0 CPU1
0: 85 0 IO-APIC-edge timer
1: 3241 0 IO-APIC-edge i8042
6: 5 0 IO-APIC-edge floppy
7: 173220 0 IO-APIC-edge parport0
8: 1 0 IO-APIC-edge rtc
9: 0 0 IO-APIC-fasteoi acpi
12: 238732 0 IO-APIC-edge i8042
14: 157903 0 IO-APIC-edge ide0
16: 5 0 IO-APIC-fasteoi ohci1394, ehci_hcd:usb1, uhci_hcd:usb2
17: 1255634 0 IO-APIC-fasteoi uhci_hcd:usb5, HDA Intel, radeon@pci:0000:01:00.0
18: 0 0 IO-APIC-fasteoi uhci_hcd:usb4
19: 1011839 0 IO-APIC-fasteoi libata, uhci_hcd:usb3, eth0
20: 0 0 IO-APIC-fasteoi eth1
NMI: 0 0
LOC: 917235 2171935
ERR: 0
MIS: 0


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:
 
Old 09-25-2008, 10:42 PM   #11
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.1
Posts: 3,482

Rep: Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546
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?
 
Old 09-28-2008, 07:24 AM   #12
veeall
Member
 
Registered: May 2007
Location: Estonia
Distribution: Slackware64-current
Posts: 298

Rep: Reputation: 56
Hi!

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 !

Thanks, T3slider and others!
 
Old 09-28-2008, 08:27 AM   #13
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
Don't forget to run /sbin/hwclock --systohc before you put computer in suspend state and run /sbin/hwclock --hctosys after it wakes up

Basically, that sets bios hardware time to system time before sleeping and set system time to bios time when it wakes up.

This way, there is no pause in time whith the suspend feature, else it wakes up at the same time as it was suspended...

Last edited by keefaz; 09-28-2008 at 08:33 AM.
 
Old 09-28-2008, 05:43 PM   #14
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.1
Posts: 3,482

Rep: Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546
Quote:
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?
 
Old 09-28-2008, 05:58 PM   #15
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
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...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: State by state, Microsoft responds to creeping threat LXer Syndicated Linux News 0 05-01-2007 07:16 AM
How To Make update2date Automatically Update JustinK101 Linux - Software 2 03-09-2007 06:29 PM
make xmms play CD automatically grapier Linux - Software 8 08-25-2006 02:20 AM
Make Samba start automatically? anti.corp Arch 2 02-12-2006 11:59 AM
How do I automatically make a ssh key? cereal83 Linux - Security 11 09-20-2005 02:16 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 09:29 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration