After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 170175 - sleep button action will never usefully work
sleep button action will never usefully work
Status: RESOLVED FIXED
Product: gnome-settings-daemon
Classification: Core
Component: general
2.22.x
Other All
: Normal normal
: ---
Assigned To: Control-Center Maintainers
Control-Center Maintainers
: 559572 604330 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2005-03-13 13:31 UTC by Matthew Garrett
Modified: 2009-12-16 07:06 UTC
See Also:
GNOME target: ---
GNOME version: 2.13/2.14


Attachments
Remove sleep keybindings (3.38 KB, patch)
2009-12-15 14:18 UTC, Bastien Nocera
committed Details | Review
Remove sleep key entry (843 bytes, patch)
2009-12-15 14:20 UTC, Bastien Nocera
committed Details | Review

Description Matthew Garrett 2005-03-13 13:31:25 UTC
Please describe the problem:
do_sleep_action is called with apm as the first argument. With no arguments, apm
will either print the battery status to stdout or say "No apm support in
kernel". Since this successfully executes, the fallback (of blanking the screen)
will never be executed.

Steps to reproduce:


Actual results:


Expected results:


Does this happen every time?


Other information:
Comment 1 Sebastien Bacher 2005-12-31 16:07:05 UTC
Thanks for your bug. What would be the correct argument to use? "apm --suspend" probably? Feel free to commit that change
Comment 2 Matthew Garrett 2005-12-31 16:16:47 UTC
apm --suspend would be an improvement, but do we want to look at sending a request to HAL instead? Actually, this probably becomes more complicated with gnome-power-manager being involved...
Comment 3 Sebastien Bacher 2005-12-31 16:55:11 UTC
I would suggest doing the apm change/closing that bug and then open a new enhancement request or start a discussion on the lists about using hal/gnome-power-management
Comment 4 Rodrigo Moya 2006-10-02 09:06:22 UTC
Why not use hal-system-power-suspend script instead? That should work for all systems supported by HAL, not like apm --suspend. Then we can enhance it to use g-p-m dbus interface instead.
Comment 5 Bastien Nocera 2006-10-02 09:23:15 UTC
It should call g-p-m's sleep code via D-Bus. Calling "apm" is a relic from times where we didn't have this opportunity (circa 2001 or something).
Comment 6 Adam Guthrie 2008-05-21 19:23:09 UTC
It looks like g-p-m is already handling when the sleep/hibernate buttons are pressed (see gpm-button.c). So the question is: should the sleep keyboard shortcut handling in g-s-d be removed or should it somehow be reworked to mesh with g-p-s?

Removing the keyboard shortcut config. would prevent people from easily assigning a custom shortcut, but then again, there's not a way to do this for hibernate currently. It seems like this would be the best option, though, as trying to handle the keyboard shortcut in two places doesn't sound very fun.
Comment 7 Richard Hughes 2008-05-27 09:10:26 UTC
The correct thing to do would be to rip out the INPUT layer handling in gpm-button and then let g-s-d handle these. g-s-d shoudl call the g-p-m methods when these buttons are pressed.

I'll rip out the code from g-p-m now.
Comment 8 Richard Hughes 2008-05-27 10:06:55 UTC
Or maybe not. This needs discussion me thinks.
Comment 9 Jens Granseuer 2008-11-06 17:57:29 UTC
*** Bug 559572 has been marked as a duplicate of this bug. ***
Comment 10 Lin Ma 2008-11-07 03:25:22 UTC
(In reply to comment #7)
> The correct thing to do would be to rip out the INPUT layer handling in
> gpm-button and then let g-s-d handle these. g-s-d shoudl call the g-p-m methods
> when these buttons are pressed.
> 
> I'll rip out the code from g-p-m now.
> 

I think it's the right way. It will be really good if desktop applications get general input from X server whatever it's an ACPI input, keyboard input or any others on kernel layer. So it will be good if g-s-d maintains powerkey and make it configurable. So I think the solution is to move the code handling HAL poweroff related namespaces into g-s-d for compatibility. And let g-s-d call g-p-m methods.
Comment 11 Wang Xin 2008-11-07 06:44:00 UTC
(In reply to comment #8)
> Or maybe not. This needs discussion me thinks.
> 

At least we can move the code handing key press event from keyboard to g-s-d. As for lid_open, lid_down and power_button, I am sure if there is any benefits from moving them to g-s-d. 
Comment 12 Jens Granseuer 2009-12-13 09:58:52 UTC
*** Bug 604330 has been marked as a duplicate of this bug. ***
Comment 13 lexual 2009-12-14 00:29:55 UTC
Can anyone give an update at where this bug is at?

Would be great to close for 2.30.

Would hate to see this bug live to see its 5th birthday.
Comment 14 Wang Xin 2009-12-14 03:30:49 UTC
Now do_sleep_action runs "gnome-session-save --shutdown-dialog". This is not a perfect solution but is workable.
Comment 15 Jens Granseuer 2009-12-14 12:24:46 UTC
At least in upstream code it actually doesn't. Should it?
Comment 16 snarkmaster 2009-12-14 14:21:19 UTC
This bug's description is quite misleading. My computer has a suspend key, which is configured in g-p-m. That works. 

In Keyboard Shortcuts, there's another Suspend action. This one fails to work.

Whether I press the Suspend key, or go to the power-down menu, and choose suspend, the effect is the same: the screen is locked, the computer suspends.

This is trivial to replicate with DBus:

dbus-send --session --dest=org.gnome.ScreenSaver --type=method_call /org/gnome/ScreenSaver org.gnome.ScreenSaver.Lock
dbus-send --print-reply --system --dest=org.freedesktop.DeviceKit.Power /org/freedesktop/DeviceKit/Power org.freedesktop.DeviceKit.Power.Suspend

The problem with binding these two commands to the Suspend action is that the dbus call for suspending has changed in the past, and will likely change more. Also, It's kind of a nuisance to represent the combined lock-suspend action in two places in the GNOME codebase.
Comment 17 Wang Xin 2009-12-15 09:22:12 UTC
(In reply to comment #15)
> At least in upstream code it actually doesn't. Should it?

Oops, my mistake. I checked my modified copy of code.
Comment 18 Bastien Nocera 2009-12-15 14:18:44 UTC
Created attachment 149770 [details] [review]
Remove sleep keybindings

Running "apm" -> bad

It's also pretty useless because the sleep button is already
handled through other means in gnome-power-manager, etc.
Comment 19 Bastien Nocera 2009-12-15 14:19:10 UTC
Comment on attachment 149770 [details] [review]
Remove sleep keybindings

Attachment 149770 [details] pushed as d6c3573 - Remove sleep keybindings
Comment 20 Bastien Nocera 2009-12-15 14:20:30 UTC
Created attachment 149771 [details] [review]
Remove sleep key entry
Comment 21 Bastien Nocera 2009-12-15 14:22:03 UTC
Removed in master for gnome-settings-daemon and gnome-control-center.
Comment 22 snarkmaster 2009-12-15 22:20:47 UTC
I disagree -- having a customizable keybinding for the sleep action is not at all useless. For instance, my MacBook does not have a sleep button. I still want a keyboard shortcut for putting it to sleep.

I do agree with calling apm == bad.

~a
Comment 23 Bastien Nocera 2009-12-16 00:54:22 UTC
(In reply to comment #22)
> I disagree -- having a customizable keybinding for the sleep action is not at
> all useless. For instance, my MacBook does not have a sleep button. I still
> want a keyboard shortcut for putting it to sleep.

It has a power button that'll pop up a window asking you whether you want to suspend, or go directly to suspend depending on your settings in gnome-power-manager. There's no point in making this configurable in the control-center.

If you want to call another program, you can add a custom keybinding.
Comment 24 snarkmaster 2009-12-16 03:27:17 UTC
Ah, we hit the eternal configurability vs simplicity debate. Okay, let's have us crazy folks use custom keybindings. 

I just hate the fact that in order to get this functionality that way, one needs a 260-character script (above). Imagine how much the user has to want it to figure out how to do this -- somebody who doesn't hack on GNOME/DBUS will need at least 30 minutes to set this up.
Comment 25 lexual 2009-12-16 04:37:54 UTC
Should there be separate bug opened requesting a small command line option to suspend the system.

e.g. 
gnome-power-manager --suspend
gnome-session --suspend
(whatever the appropriate command would be)

Also, due to the suspend command being removed from gnome-power-manager systray icon, it does leave one less avenue for user to swiftly suspend their system.
Comment 26 snarkmaster 2009-12-16 05:07:58 UTC
Lex, that sounds like a great idea! Would you file it for the application that's most appropriate -- I have no idea about GNOME's architecture.
Comment 27 Wang Xin 2009-12-16 07:06:52 UTC
(In reply to comment #25)
> Should there be separate bug opened requesting a small command line option to
> suspend the system.
> 
> e.g. 
> gnome-power-manager --suspend
> gnome-session --suspend
> (whatever the appropriate command would be)
> 
> Also, due to the suspend command being removed from gnome-power-manager systray
> icon, it does leave one less avenue for user to swiftly suspend their system.

Or you can just use dbus-send to send Susppend command to devicekit-power.