LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Suspend/Hibernate at command line as regular user in 13.37: use ConsoleKit? (https://www.linuxquestions.org/questions/slackware-14/suspend-hibernate-at-command-line-as-regular-user-in-13-37-use-consolekit-875614/)

josiah 04-18-2011 06:35 AM

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.

dive 04-18-2011 09:28 AM

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.

rfernandez 04-18-2011 09:34 AM

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


josiah 04-18-2011 04:21 PM

Quote:

Originally Posted by rfernandez (Post 4328055)
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.

bonixavier 04-18-2011 04:46 PM

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.

rfernandez 04-18-2011 06:00 PM

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.

rworkman 04-18-2011 09:42 PM

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


rfernandez 04-18-2011 10:15 PM

Quote:

Originally Posted by rworkman (Post 4328787)
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.

rworkman 04-18-2011 10:25 PM

Quote:

Originally Posted by rfernandez (Post 4328807)
Oops, sorry. I thought he did not want UPower.

Hrm, actually, yeah. I keep forgetting that I'm running future -current :-)
Sorry about that :/

victorsk 10-19-2015 11:30 AM

Quote:

Originally Posted by bonixavier (Post 4328543)
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.


Hi. I know this is an old thread but it's still helpful. It helped me resolve suspend issues in XFCE open-rc system. Thank you.


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