Announcement

Collapse
No announcement yet.

Logout System Script

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

    [KDE] Logout System Script

    Dear Friends

    I am working on a script which logs out the system but I didnot find any command which will logs out a user from system graphically

    How I am Doing. ?

    I used the following commands.
    exit
    gnome-session-quit ( and other gnome commands)
    kill -u username
    etc.

    please guide how could i logout via script keep in mind that Scipt will run on sudo privileges

    thanking you

    #2
    Code:
    sudo service lightdm restart
    maby

    VINNY
    i7 4core HT 8MB L3 2.9GHz
    16GB RAM
    Nvidia GTX 860M 4GB RAM 1152 cuda cores

    Comment


      #3
      You mean just logout without the GUI thingy?

      kdeinit4_shutdown

      works without root requirements.

      Please Read Me

      Comment


        #4
        This works better as root:

        pkill -u <username>

        or

        pkill x

        to kill all users

        Please Read Me

        Comment


          #5
          @ vinnywright error lightdm service not found
          @ oshunluvr After giving you command system give a black screen neither is logout nor it shutdown. It just become black and no mouse/keybord working
          "kill" commands hang the system and nothing appears I want to know when we do logout from start menu which command is executed. please give some other suggestions

          Comment


            #6
            Since you didn't say which command you tried, I can report that here:kdeinit4_shutdown resulted in a dialog stating kdeinit had closed and when I clicked OK I was presented with the log in screen and sudo pkill -u <myusername> gave no errors at all, just went straight to the log in screen.

            Both commands work here, Without more info I can't guess why they didn't for you.

            As far as Vinny's suggestion, if you're not using lightdm that means you've uninstalled it. Again, we can't guess which dm you've replaced it with so you'll have give more info or try gdm or kdm.
            Last edited by oshunluvr; Sep 26, 2014, 02:02 AM.

            Please Read Me

            Comment


              #7
              Since you didn't say which command you tried, I can report that here:kdeinit4_shutdown resulted in a dialog stating kdeinit had closed and when I clicked OK I was presented with the log in screen and sudo pkill -u <myusername> gave no errors at all, just went straight to the log in screen.

              Both commands work here, Without more info I can't guess why they didn't for you.

              Please Read Me

              Comment


                #8
                I'd rather not simply kill the display manager or user processes, as the kde session will not end cleanly (session is not saved, applications are TERMed instead of exited etc.)

                The cleanest way to logout from kde via script would be using a dbus call, something like:
                qdbus org.kde.ksmserver /KSMServer logout 0 0 0
                Where the last three integers define shutdownConfirm, shutdownType and shutdownMode (see http://api.kde.org/4.4-api/kdebase-w...WorkSpace.html), so it's pretty configurable.

                It will work fine if run as a user, but can be a tad tricky to get it to work if you need to run the script as root (or another user), you can try this script:
                Code:
                #!/bin/bash 
                ADDRESS="$(tr '\0' '\n' < /proc/$(ps -Ao %p%c | sed '/ksmserver/!d; s/ *\([0-9]*\) *.*/\1/g')/environ | grep DBUS_SESSION_BUS_ADDRESS |  cut -d"=" -f2-)" 
                qdbus --address "$ADDRESS" org.kde.ksmserver /KSMServer logout 0 2 2
                (from http://ubuntuforums.org/showthread.php?t=2244106 , did not test myself)

                Comment


                  #9
                  The above works for me. I wonder if there's a way to launch the logout GUI popup from a script?

                  Please Read Me

                  Comment


                    #10
                    Originally posted by oshunluvr View Post
                    The above works for me. I wonder if there's a way to launch the logout GUI popup from a script?
                    qdbus org.kde.ksmserver /KSMServer logout 1 -1 -1
                    (like I said, it's pretty configurable)

                    Comment


                      #11
                      Cool thanks!

                      Please Read Me

                      Comment

                      Working...
                      X