Announcement

Collapse
No announcement yet.

How can I get shutdown options when I press the power button?

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How can I get shutdown options when I press the power button?

    When I press the power button on my laptop I used to get the option to shutdown, suspend, logout, etc, now when I press it it just shuts down. Its really annoying having to go through the menu to suspend (either to disk or ram).

    'Confirm logout' and 'offer shutdown options' are both checked in session manager settings.

    I have this repo enabled so I could try KDE4.2:
    http://ppa.launchpad.net/kubuntu-experimental/ubuntu

    After much googling I found no solution but I did find that the following script should be called:
    Code:
    #!/bin/sh
    # /etc/acpi/powerbtn.sh
    # Initiates a shutdown when the power putton has been
    # pressed.
    
    # Skip if we just in the middle of resuming.
    test -f /var/lock/acpisleep && exit 0
    
    # If gnome-power-manager, kpowersave or klaptopdaemon are running, let
    # them handle policy This is effectively the same as 'acpi-support's
    # '/usr/share/acpi-support/policy-funcs' file.
    
    if pidof gnome-power-manager kpowersave > /dev/null ||
     (pidof dcopserver > /dev/null && test -x /usr/bin/dcop && /usr/bin/dcop kded kded loadedModules | grep -q klaptopdaemon) ; then
      exit
    fi
    
    # Otherwise, if KDE is found, try to ask it to logout.
    # If KDE is not found, just shutdown now.
    if ps -Af | grep -q '[k]desktop' && pidof dcopserver > /dev/null && test -x /usr/bin/dcop ; then
      KDESES=`pidof dcopserver | wc -w`
      if [ $KDESES -eq 1 ] ; then
        # single KDE session -> ask user
        /usr/bin/dcop --all-sessions --all-users ksmserver ksmserver logout 1 2 0
        exit 0
      else
        # more than one KDE session - just send shutdown signal to all of them
        /usr/bin/dcop --all-sessions --all-users ksmserver ksmserver logout 0 2 0 && exit 0
      fi
    fi
    
    # If all else failed, just initiate a plain shutdown.
    /sbin/shutdown -h now "Power button pressed"

    Can anyone tell if that script is wrong or am I on totally the wrong track?

    Thanks in advance.

    #2
    Re: How can I get shutdown options when I press the power button?

    I might be having the same problem--except the menu entries just don't work. Pressing the power button or issuing one of the various shutdown commands from command line are the only ways to shutdown now.

    I've just been ignoring this for the past 2 months. I remember seeing some other threads and bug reports but no solutions, just developers shrugging and saying, "Yeah, I guess this needs to be fixed some time."

    Comment


      #3
      Re: How can I get shutdown options when I press the power button?

      Never did investigate any further, have just got used to it

      Comment


        #4
        Re: How can I get shutdown options when I press the power button?

        Never used that script. Actually, I didn't know it existed. However, my old warrior does have ACPI issues. So I just select Logout from the K menu and pick Turn Off. It works and works gracefully, the script appears like it could a little less than graceful.
        The next brick house on the left
        Intel i7 11th Gen | 16GB | 1TB | KDE Plasma 5.27.11​| Kubuntu 24.04 | 6.8.0-31-generic



        Comment


          #5
          Re: How can I get shutdown options when I press the power button?

          Glad logout from the menu works for you. I wish it worked for me.

          Comment


            #6
            Re: How can I get shutdown options when I press the power button?

            Originally posted by olimay
            Glad logout from the menu works for you. I wish it worked for me.
            Oh? What happens when you do select logout? Also, what hardware platform are you on?
            The next brick house on the left
            Intel i7 11th Gen | 16GB | 1TB | KDE Plasma 5.27.11​| Kubuntu 24.04 | 6.8.0-31-generic



            Comment


              #7
              Re: How can I get shutdown options when I press the power button?

              Sorry for 3+ months no reply. To answer your question:

              1. the Logout menu item doesn't do anything (besides close the menu.)
              2. my machine is a Sony Vaio VGN-BX640p. Not very happy with it.

              Since my last post, I also became used to the power button shutting off everything.

              But then, I upgraded to Kubuntu 9.04. It didn't help: the power button no longer does anything.

              Code:
              #!/bin/sh
              # /etc/acpi/powerbtn.sh
              # Initiates a shutdown when the power putton has been
              # pressed.
              
              # Skip if we just in the middle of resuming.
              test -f /var/lock/acpisleep && exit 0
              
              # If gnome-power-manager or kded4 are running, let
              # them handle policy This is effectively the same as 'acpi-support's
              # '/usr/share/acpi-support/policy-funcs' file.
              
              if pidof gnome-power-manager kded4 > /dev/null; then
                exit
              fi
              
              # If all else failed, just initiate a plain shutdown.
              /sbin/shutdown -h now "Power button pressed"
              So I guess the problem is with kded4?

              I tried some instructions from another thread:
              Originally posted by Rog131
              With the KDE 4 the dcop was replaced by the qdbus.

              Turning off + 30 sec warning (konsole):
              Code:
              qdbus org.kde.ksmserver /KSMServer org.kde.KSMServerInterface.logout 1 2 2


              and those numbers are working same way as with the dcop (i think ).
              1 2 2 = ShutdownConfirmYes ShutdownTypeHalt ShutdownModeForceNow
              ...which didn't do anything visible to me. And certainly didn't logout or shut down. I guess I'm stuck with commandline shutdowns until I figure out what's wrong with dcop/dbus/qbus etc.

              Comment


                #8
                Re: How can I get shutdown options when I press the power button?

                if you click on the battery in the notification area, a dialog window will pop up...select more options, and from there you can edit what the power button does (per battery profile)...this is on 9.04 though...on 8.10, I had to uninstall the useless kubuntu power manager, and install the stock KDE4.2 power manager...don't remember exactly how I did that, but there is a post on here when I was figuring it out, I'm sure you can search and find it...

                mm0
                Dell Inspiron 1720 Laptop<br />Intel T9300 Core2Duo Processor @ 2.5Ghz<br />4 GB Ram | 1920 X 1200 Resolution<br />2 X 160 GB SATA HD Internal<br />Nvidia GeForce 8600M Graphics Adapter<br />Using Kubuntu 9.10

                Comment

                Working...
                X