5

I have some problem with my Nvidia Graphics and suspending (I can't resume from suspend). So I usually avoid suspending my computer.

But sometimes I accidentally click on Suspend when trying to Shutdown. Which suddenly suspends my computer without giving any warning!. I will have to boot it again (where I get stuck on a blank screen) and long press my power-button and restart my computer.

enter image description here

I get a warning like this before shutting down.

enter image description here

I would like to get a similar warning when I accidentally click on Suspend too.

Zanna
  • 70,465
Severus Tux
  • 9,866
  • There may be other methods to solve your original problem. For example: fixing suspend, making the suspend option to shutdown instead, removing the option from the menu. Are you interested in them too? In particular, I suspect that removing the Suspend entry from the menu is a matter of a couple shell commands. – Sergey Jun 15 '16 at 03:26
  • 1
    @Sergey I have tried a lot to fix the suspend problem, but I could not get it working. Suspend works fine when I switch to Intel graphics using Nvidia-prime. I use suspend when Intel graphics is being used. So , I am searching for a script/any other method to get a warning (simple one, zenity would do) before it suspends. – Severus Tux Jun 15 '16 at 04:01
  • @Sergey But Yes, I am interested in "making the suspend option to shutdown instead". do you know how to do that ? – Severus Tux Jun 15 '16 at 04:59
  • See this question for suggestions how to remove the Suspend option from the menu: http://askubuntu.com/questions/452908/how-to-disable-suspend-in-14-04 – Sergey Jun 15 '16 at 22:36
  • As suggested, I have raised a feature request on launchpad for getting this feature .

    Link : https://bugs.launchpad.net/ubuntu/+source/unity/+bug/1593912

    If you support this feature, please mark as "Yes, it affects me"

    – Severus Tux Jun 18 '16 at 09:02

1 Answers1

5

While modifying the source of the indicator itself ( in my humble opinion ) is the best approach ( and probably the feature request for that is even better approach ) ,one can create custom session control to be placed onto the launcher , which is fairly easy to achieve. That way, we can have suspend options which does ask for user confirmation.

The .desktop file bellow allows mimicking the 3 options from the session indicator in the top panel: Shutdown , Suspend , and Logout. Double clicking on the icon by default will bring up confirmation for shutdown. Right clicking on the entry will bring up the list of other options.

Preferably , you'd want it to be stored in ~/local/share/applications folder and have executable permissions. Naming doesn't matter, personally I named it session-control.desktop

File contents

[Desktop Entry]
Name=Shutdown the System
Comment=Alternative session control , main entry will bring up shutdown or reboot dialog but Suspend and Logout will bring up confirmation dialog.
Terminal=false
Actions=Suspend;Logout
Type=Application
Exec=qdbus com.canonical.Unity /com/canonical/Unity/Session com.canonical.Unity.Session.RequestReboot
Icon=/usr/share/unity-greeter/cof.png

[Desktop Action Suspend]
Name=Suspend the System
Exec=qdbus com.canonical.Unity /com/canonical/Unity/Session com.canonical.Unity.Session.RequestShutdown
Terminal=false

[Desktop Action Logout]
Name=Logout the User
Exec=qdbus com.canonical.Unity /com/canonical/Unity/Session com.canonical.Unity.Session.RequestLogout
Terminal=false

How it looks

Launcher entry

Launcher entry with all options visible

The dialog that comes up if you click on Suspend

Unity's shutdown dialog that comes up when you click on Suspend option, among others Suspend is there on the dialog as well

Sergiy Kolodyazhnyy
  • 105,154
  • 20
  • 279
  • 497