LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 04-18-2011, 07:35 AM   #1
josiah
Member
 
Registered: May 2004
Distribution: Slackware
Posts: 46

Rep: Reputation: 23
Suspend/Hibernate at command line as regular user in 13.37: use ConsoleKit?


Using the most recent -current/13.37, I'm curious if there is a New Right Way to suspend as a regular user from the command line, now that we've got PolicyKit/ConsoleKit running the show. I've seen some things (e.g., on the Archlinux wiki) that seem to come close, but require UPower. For some reason I can't wrap my head around the PolicyKit documentation well enough to figure this out.

My old solution was to add a line to /etc/sudoers giving anyone in the power group access to pm-suspend, pm-hibernate, and shutdown, and this is probably what I'll end up doing with 13.37.
 
Old 04-18-2011, 10:28 AM   #2
dive
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Slackware
Posts: 3,211

Rep: Reputation: 293Reputation: 293Reputation: 293
I made a script to do it some time ago and don't see any reason to change it. I made an entry in /etc/acpi/ to hibernate when I hit the power button on my thinkpad.

Code:
sync
echo "7 blink" > /proc/acpi/ibm/led
echo -n shutdown > /sys/power/disk
echo -n disk > /sys/power/state
Is the work bits.
 
Old 04-18-2011, 10:34 AM   #3
rfernandez
Member
 
Registered: Mar 2010
Location: Brazil
Distribution: Slackware64
Posts: 264

Rep: Reputation: 40
I guess that what you're seeking has to do with dbus-send. I'm guessing, from forum searches, that this is the command line

Code:
dbus-send --system --print-reply --dest=org.freedesktop.Hal \
 /org/freedesktop/Hal/devices/computer \
 org.freedesktop.Hal.Device.SystemPowerManagement.Suspend
 
Old 04-18-2011, 05:21 PM   #4
josiah
Member
 
Registered: May 2004
Distribution: Slackware
Posts: 46

Original Poster
Rep: Reputation: 23
Quote:
Originally Posted by rfernandez View Post
I guess that what you're seeking has to do with dbus-send. I'm guessing, from forum searches, that this is the command line

Code:
dbus-send --system --print-reply --dest=org.freedesktop.Hal \
 /org/freedesktop/Hal/devices/computer \
 org.freedesktop.Hal.Device.SystemPowerManagement.Suspend
I've found several strings like these, and they all seem very distribution-specific—and version-specific. Run as root and as user, this command produces:

Code:
$ dbus-send --system --print-reply --dest=org.freedesktop.Hal \
>  /org/freedesktop/Hal/devices/computer \
>  org.freedesktop.Hal.Device.SystemPowerManagement.Suspend
Error org.freedesktop.DBus.Error.UnknownMethod: Method "Suspend" with signature "" on interface "org.freedesktop.Hal.Device.SystemPowerManagement" doesn't exist
I think the solution has something to do with /usr/share/dbus-1/interfaces/org.freedesktop.PowerManagement.xml but I'm not sure how to put it all together.
 
Old 04-18-2011, 05:46 PM   #5
bonixavier
Member
 
Registered: Sep 2010
Distribution: Slackware
Posts: 320

Rep: Reputation: 62
Add the following line to your sudoers file:
Code:
%users ALL=(ALL) NOPASSWD: /usr/sbin/pm-suspend
Then, when you want to suspend the computer, you type:
Code:
sudo /usr/sbin/pm-suspend
You could add /usr/sbin to your PATH, then you'd just have to type sudo pm-suspend.

Edit: I didn't read the OP carefully enough. Sorry.

Last edited by bonixavier; 04-18-2011 at 05:48 PM.
 
Old 04-18-2011, 07:00 PM   #6
rfernandez
Member
 
Registered: Mar 2010
Location: Brazil
Distribution: Slackware64
Posts: 264

Rep: Reputation: 40
What about

Code:
dbus-send --system --dest=org.freedesktop.Hal --type=method_call \
--print-reply /org/freedesktop/Hal/devices/computer \ org.freedesktop.Hal.Device.SystemPowerManagement.Suspend int32:0
(just added int32:0). Sorry, I'm just guessing. Usually I just use the suspend button over powermanager preferences on the system tray, or type pm-suspend on the CLI to do that.
 
Old 04-18-2011, 10:42 PM   #7
rworkman
Slackware Contributor
 
Registered: Oct 2004
Location: Tuscaloosa, Alabama (USA)
Distribution: Slackware
Posts: 1,944

Rep: Reputation: Disabled
I believe you are wanting this:
Code:
dbus-send \
  --system \
  --dest=org.freedesktop.UPower \
  --type=method_call \
  --print-reply \
  /org/freedesktop/UPower \
  org.freedesktop.UPower.Suspend
 
Old 04-18-2011, 11:15 PM   #8
rfernandez
Member
 
Registered: Mar 2010
Location: Brazil
Distribution: Slackware64
Posts: 264

Rep: Reputation: 40
Quote:
Originally Posted by rworkman View Post
I believe you are wanting this:
Code:
dbus-send \
  --system \
  --dest=org.freedesktop.UPower \
  --type=method_call \
  --print-reply \
  /org/freedesktop/UPower \
  org.freedesktop.UPower.Suspend
Oops, sorry. I thought he did not want UPower.
 
Old 04-18-2011, 11:25 PM   #9
rworkman
Slackware Contributor
 
Registered: Oct 2004
Location: Tuscaloosa, Alabama (USA)
Distribution: Slackware
Posts: 1,944

Rep: Reputation: Disabled
Quote:
Originally Posted by rfernandez View Post
Oops, sorry. I thought he did not want UPower.
Hrm, actually, yeah. I keep forgetting that I'm running future -current :-)
Sorry about that :/
 
  


Reply

Tags
command line, policykit, power, suspend


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
problems with Suspend, hibernate, and switch user marozsas Linux - Hardware 1 03-29-2010 10:55 AM
how to detect system power event(user trigger),suspend,hibernate,resume...? minge.zu Linux - Desktop 1 02-11-2009 09:19 PM
Searching for regular expression in command line Jean Of mArc Programming 9 08-11-2008 09:01 PM
How to call Hibernate from command line hacker supreme Linux - Software 4 09-28-2007 07:53 PM
hibernate pc from command line alaios Linux - General 3 08-21-2005 12:56 PM


All times are GMT -5. The time now is 08:08 PM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration