Suspend instead of power-off after X minutes *SOLVED*

Booting, installing, newbie
Post Reply
Message
Author
liro

Suspend instead of power-off after X minutes *SOLVED*

#1 Post by liro »

In the Puppy Event Manager, under the "Power" tab, you can set Puppy to power-off your computer after X minutes of no mouse activity.

I'd like to know how you can do the same thing but with Puppy suspending your computer after X minutes, instead of powering it off.

Thanks for any help.
Last edited by liro on Fri 12 Dec 2014, 20:24, edited 1 time in total.

User avatar
nic007
Posts: 3408
Joined: Sun 13 Nov 2011, 12:31
Location: Cradle of Humankind

#2 Post by nic007 »

Code: Select all

hdparm -S 120 /dev/sda
This will suspend after 10 minutes. sda is my hard drive, yours may be different. I made a script and put it in the startup folder. Please note it's a capital S

liro

#3 Post by liro »

Hi nic, thanks for the reply. It looks like that script would enable energy saving spindown on my hard-drive after X minutes, but ideally I'd like to trigger the "suspend.sh" script in my etc/acpi/actions folder, as this would also switch off the backlight on my laptop's LCD. Is there any way I can make that script run automatically after X minutes of mouse inactivity?

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#4 Post by mikeb »

does dpms turn of the backlight as well as the screen as that could be set to whatever you like too. I use that plus hdparm for me laptop/netbook.

Check out the xset help... puppy tends to only use the screen blanking by default. Its done in /root/.xinitrc

Ok its not true suspend but does the job of battery saving.

mike

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#5 Post by SFR »

If the built-in "Power off after X minutes" feature is expendable for you and you just want to replace it with 'Suspend', I suppose it's just a matter of editing the following line in /usr/local/pup_event/frontend_timeout (or /sbin/pup_event_frontend_d in older Pups):

Code: Select all

[ $MOUSECNT -gt $POWERTIMEOUT ] && wmpoweroff &
However, personally I don't like the technique used in that script, because it relies on mouse movements only, so if one's using a keyboard exclusively for a longer period of time, it won't stop the script from triggering shutdown/suspend action.

IMO, a better way would be to use xprintidle (you can obtain compiled, 32bit version from here) along with a simple script like this:

Code: Select all

#!/bin/sh

TIMEOUT=1	# in minutes

TIMEOUT=$((TIMEOUT*60000))

while :; do
  sleep 5
  if [ `xprintidle` -ge $TIMEOUT ]; then
    /etc/acpi/actions/suspend.sh
  fi
done
(just make sure to put xprintidle somewhere in $PATH, e.g. /usr/local/bin/)

Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

User avatar
nic007
Posts: 3408
Joined: Sun 13 Nov 2011, 12:31
Location: Cradle of Humankind

#6 Post by nic007 »

liro wrote:Hi nic, thanks for the reply. It looks like that script would enable energy saving spindown on my hard-drive after X minutes, but ideally I'd like to trigger the "suspend.sh" script in my etc/acpi/actions folder, as this would also switch off the backlight on my laptop's LCD. Is there any way I can make that script run automatically after X minutes of mouse inactivity?
For the screen I add the following line to /etc/X11/xorg.conf in the ServerLayout section - Option "Offtime" "5" which will turn the screen off after 5 minutes of inactivity. Instead of "OffTime" you can also use "StandbyTime" or "SuspendTime"

liro

#7 Post by liro »

Thanks everyone for the replies.

When I first started using Puppy (Slacko) I had a lot of problems getting suspend/sleep to work properly when closing the lid on my laptop (with it "waking up" after suspension and with the LCD backlight), so would prefer to stick with my modified "suspend.sh" which I know fully works.

As such, it looks like SFR's suggestion would be most suitable for me, but a couple of (probably dumb) questions:

1. After putting xprintidle in /usr/local/bin/, where do I put the script that triggers it (in the startup folder?)
2. Is the "sleep 5" bit in that script the number of minutes?

Thanks again.
Last edited by liro on Thu 11 Dec 2014, 05:16, edited 1 time in total.

User avatar
Evil20071
Posts: 489
Joined: Sat 07 Jun 2008, 19:50
Location: Piedmont, SC,.United States
Contact:

#8 Post by Evil20071 »

sleep 5 is the ACPI suspend state used... http://en.wikipedia.org/wiki/Advanced_C ... wer_states Will tell you more about them.
[url=http://totalelectronics.us]TotalElectronics.us[/url]

User avatar
rg66
Posts: 1158
Joined: Mon 23 Jul 2012, 05:53
Location: Vancouver, BC Canada / Entebbe, Uganda Africa!?!

#9 Post by rg66 »

Code: Select all

#!/bin/sh

TIMEOUT=1   # in minutes

TIMEOUT=$((TIMEOUT*60000))

while :; do
  sleep 5
  if [ `xprintidle` -ge $TIMEOUT ]; then
    /etc/acpi/actions/suspend.sh
  fi
done
Xprintidle counts in milliseconds so (1*60000) = 1 min. Change TIMEOUT=1 to however many minutes you want. The while / done part is a loop, the script will check every 5 seconds (sleep 5) until xprintidle has counted greater than or equal to (-ge) the set TIMEOUT then run /etc/acpi/actions/suspend.sh.

You can put the script in /root/Startup to run it at every boot, make sure it's executable (chmod +x /path/scriptname).
X-slacko-5b1 - X-tahr-2.0 - X-precise-2.4
[url=http://smokey01.com/rg66/]X-series repo[/url]

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#10 Post by mikeb »

/usr/local/pup_event/frontend_timeout (or /sbin/pup_event_frontend_d in older Pups):
is this really in puppys now...thanks for the laugh this morning :D more junk in there than ever then....

The code is so good you have to devise a workaround for it!!

oh well ..... I prefer using X...works as its supposed to...and yes too many reports of problems using true suspend functionality.

Mike

liro

#11 Post by liro »

Cheers guys. I followed rg66's instructions and it's working fine.

Post Reply