[HOWTO] Suspend or "sleep" a PC

How to do things, solutions, recipes, tutorials
Post Reply
Message
Author
frenchiveruti
Posts: 120
Joined: Wed 15 Feb 2017, 14:00

[HOWTO] Suspend or "sleep" a PC

#1 Post by frenchiveruti »

So, many of the users of puppy linux, use puppy for laptops, those are great suspending because the acpi can read the battery and actually work.
But for PC users like me, the solution is just this command line:

Code: Select all

echo -n mem > /sys/power/state
And that's it!
Why that works? Here's the answer:
https://www.kernel.org/doc/Documentatio ... states.txt

I hope this helps!

Credits to the solution where they should be:
http://www.murga-linux.com/puppy/viewto ... 802#725802

User avatar
Mike Walsh
Posts: 6351
Joined: Sat 28 Jun 2014, 12:42
Location: King's Lynn, UK.

#2 Post by Mike Walsh »

@frenchiveruti:-

Sounds easy enough. Just one question, though; how do you 'wake' it up again? Is it as simple as pressing the power-on button?

Just curious, really. I know with a laptop you'd simply open the lid (I think). Or is that the 'sleep' option?

I get muddled up with the two of them, I confess..! :roll:


Mike. :wink:

slavvo67
Posts: 1610
Joined: Sat 13 Oct 2012, 02:07
Location: The other Mr. 305

#3 Post by slavvo67 »

This works for me. Just move the mouse or touch the keyboard to wake it up.

Code: Select all

sleep 1 && xset dpms force off
BTW, not my own. Someone provided this a while back. I just script it to root/my-applications/bin , make it executable and drag a copy to the desktop. One click and boom....

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

#4 Post by nic007 »

slavvo67 wrote:This works for me. Just move the mouse or touch the keyboard to wake it up.

sleep 1 && xset dpms force off


BTW, not my own. Someone provided this a while back. I just script it to root/my-applications/bin , make it executable and drag a copy to the desktop. One click and boom....
That command only influences the screen as far as I know and does not put your whole system to sleep (standby). To awake from system standby, you need to press the power button.

frenchiveruti
Posts: 120
Joined: Wed 15 Feb 2017, 14:00

#5 Post by frenchiveruti »

Mike Walsh wrote:@frenchiveruti:-

Sounds easy enough. Just one question, though; how do you 'wake' it up again? Is it as simple as pressing the power-on button?

Just curious, really. I know with a laptop you'd simply open the lid (I think). Or is that the 'sleep' option?

I get muddled up with the two of them, I confess..! :roll:


Mike. :wink:
Hey mike, as far as my hardware goes. Just pressing the powerbutton works wonders, even pressing a keyboard key on a PS2 Keyboard works also for waking it up.

User avatar
Mike Walsh
Posts: 6351
Joined: Sat 28 Jun 2014, 12:42
Location: King's Lynn, UK.

#6 Post by Mike Walsh »

@ frenchiveruti:-

Mm. Fair enough! In that case.....thanks for the info. I'll give this a try.

Cheers for the confirmation.


Mike. :wink:

User avatar
fabrice_035
Posts: 765
Joined: Mon 28 Apr 2014, 17:54
Location: Bretagne / France

#7 Post by fabrice_035 »

Hi,

My computer (dell xps 1640) restart immediatly after sleep/hibernate :cry:

Why ?

Regard.

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

#8 Post by nic007 »

fabrice_035 wrote:Hi,

My computer (dell xps 1640) restart immediatly after sleep/hibernate :cry:

Why ?

Regard.
It depends on which sleep mode(s) are available for your system and which you are using. Suspending to RAM does not require a system restart but suspending to HD does.

User avatar
soniabu
Posts: 162
Joined: Thu 01 Feb 2018, 21:24
Location: Paris

Re: [HOWTO] Suspend or "sleep" a PC

#9 Post by soniabu »

frenchiveruti wrote:So, many of the users of puppy linux, use puppy for laptops, those are great suspending because the acpi can read the battery and actually work.
But for PC users like me, the solution is just this command line:

Code: Select all

echo -n mem > /sys/power/state
fantastic !
thx Sonia

User avatar
takenp
Posts: 101
Joined: Wed 05 Aug 2015, 23:27
Location: Moskva
Contact:

#10 Post by takenp »

BTW

I've been using pm-suspend small program from the pm-utils packadge got from Ubuntu's repo. It worked fine. Still thinking what is better? Or may be pm-suspend does all the same? )

==
UPDATE

It does evidently all the same )

Code: Select all

root# cat /usr/lib/pm-utils/pm-functions | grep state

	if grep -q mem /sys/power/state; then
		do_suspend() { echo -n "mem" >/sys/power/state; }
	elif grep -q standby /sys/power/state; then
		do_suspend() { echo -n "standby" >/sys/power/state; }
	grep -q disk /sys/power/state; then
		echo -n "disk" > /sys/power/state
	grep -q disk /sys/power/state && \
LOL

frenchiveruti
Posts: 120
Joined: Wed 15 Feb 2017, 14:00

#11 Post by frenchiveruti »

takenp wrote:BTW

I've been using pm-suspend small program from the pm-utils packadge got from Ubuntu's repo. It worked fine. Still thinking what is better? Or may be pm-suspend does all the same? )

==
UPDATE

It does evidently all the same )

Code: Select all

root# cat /usr/lib/pm-utils/pm-functions | grep state

	if grep -q mem /sys/power/state; then
		do_suspend() { echo -n "mem" >/sys/power/state; }
	elif grep -q standby /sys/power/state; then
		do_suspend() { echo -n "standby" >/sys/power/state; }
	grep -q disk /sys/power/state; then
		echo -n "disk" > /sys/power/state
	grep -q disk /sys/power/state && \
LOL
Yeah! This is for the command line interface purist like me, that don't like to have 200 programs for a simple set of commands.
Glad it works!

User avatar
jplt3
Posts: 118
Joined: Mon 08 Apr 2019, 20:40
Location: Planet Earth

#12 Post by jplt3 »

@frenchiveruti great thanks fantastic

Too bad that we can not wake up the pc with keyboard or mouse ?
JpLt

User avatar
Mike Walsh
Posts: 6351
Joined: Sat 28 Jun 2014, 12:42
Location: King's Lynn, UK.

#13 Post by Mike Walsh »

jplt3 wrote:@frenchiveruti great thanks fantastic

Too bad that we can not wake up the pc with keyboard or mouse ?
@ jplt3:-

If you use the initial command in the first post, that's exactly what happens! In fact, it's a bit of a juggling act if you're using a desktop, and you're trying to carefully switch the mouse off without moving the cursor.....because the slightest cursor movement will "wake" it up again.

I've stuck a wee script with the command in /usr/sbin, and called it simply 'suspend.sh'.

It's also why, although I've integrated "Suspend-to-RAM" into my Pups' Logout GUI - I've replaced the 'Rebuild Menus' entry, 'cos I prefer to run 'fixmenus' & re-start "X" manually - I've also added a key-binding to /etc/xdg/templates/_rox_jwmrc, which lets me run the command via the "Pause/Break" button. Means I can safely switch the mouse off and put it out of the way before suspending via the "Pause" button.....and when I want to resume, I just hit the biggest key I can find. The space bar..!


Mike. :wink:

User avatar
jplt3
Posts: 118
Joined: Mon 08 Apr 2019, 20:40
Location: Planet Earth

#14 Post by jplt3 »

@Mike Walsh

thanks for your explanation.

In my case it does not work maybe i'am using this tiling window manager DWM ?!

Will try with jwm .

i test on

Code: Select all

cat /etc/os-release 
NAME=Puppy
VERSION="8.0"
ID=puppy_bionicpup64
VERSION_ID=8.0
PRETTY_NAME="bionicpup64 8.0"
ANSI_COLOR="0;34"
CPE_NAME="cpe:/o:puppy:puppy_linux:8.0"
HOME_URL="http://puppylinux.com/"
SUPPORT_URL="http://www.murga-linux.com/puppy/index.php"
BUG_REPORT_URL="https://github.com/puppylinux-woof-CE/woof-CE"
JpLt

Post Reply