Пример #1
0
    def logout(self):
        # IF IS KDE
        if (("KDE_FULL_SESSION" in env) and (env["KDE_FULL_SESSION"] == "true")):
            # KDE4
            if (("KDE_SESSION_VERSION" in env) and (env['KDE_SESSION_VERSION'] == '4')):
                executable = is_in_path("qdbus")
                if not executable:
                    return False

                cmd = [executable, "org.kde.ksmserver", "/KSMServer",
                       "logout", "0", "0", "0"]

                execute_command(cmd)
                return True

            # KDE3
            executable = is_in_path('dcop')
            if not executable:
                return False

            cmd = [executable, "ksmserver", "ksmserver",
                   "logout", "0", "0", "0"]
            execute_command(cmd)
            return True

        elif "GNOME_DESKTOP_SESSION_ID" in env:
            p = is_in_path("gnome-session-save")

            if not p:
                return False

            cmd = [p, "--logout"]
            execute_command(cmd)

        # FIND XFCE4
        if "xfce4" in get_output_of_command("xprop -root _DT_SAVE_MODE"):
            p = is_in_path("xfce4-session-logout")

            if not p:
                return False

            cmd = [p, "--logout"]
            execute_command(cmd)
            
            return True
            
        # BlackBox and fluxbox
        out = get_output_of_command ("xprop -root _BLACKBOX_PID")
        if out:
            print out
            m = re.search(r'\d+', out)

            if m:
                pid = int(m.group())
                oskill(pid)
                return True
            
        #TODO: find session and send logout signal
        pass
Пример #2
0
    def logout(self):
        assert "GDMSESSION" in env, "Session must be specified by environ Variable GDMSESSION"
        session = env["GDMSESSION"]

        # Openbox
        if "openbox" in session.lower():
            p = is_in_path("openbox")

            if not p:
                return False

            cmd = [p, "--exit"]
            execute_command(cmd)

        # Send logout signal to GNOME
        elif "gnome" in session.lower():
            p = is_in_path("gnome-session-save")

            if not p:
                return False

            cmd = [p, "--logout"]
            a = execute_command(cmd)

        if "xfce" in session.lower():
            p = is_in_path("xfce4-session-logout")

            if not p:
                return False

            cmd = [p, "--logout"]
            execute_command(cmd)

            return True

        elif (("fluxbox" in session.lower())
              or ("blackbox" in session.lower())):
            out = get_output_of_command("xprop -root _BLACKBOX_PID")

            if not out:
                return False

            m = re.search(r'\d+', out)

            if not m:
                return False

            pid = int(m.group())
            oskill(pid)

        elif ("kde" in session.lower()):
            # KDE4
            if (("KDE_SESSION_VERSION" in env)
                    and (env['KDE_SESSION_VERSION'] == '4')):
                executable = is_in_path("qdbus")
                if not executable:
                    return False

                cmd = [
                    executable, "org.kde.ksmserver", "/KSMServer", "logout",
                    "0", "0", "0"
                ]

                execute_command(cmd)
                return True

            # KDE3
            executable = is_in_path('dcop')
            if not executable:
                return False

            cmd = [
                executable, "ksmserver", "ksmserver", "logout", "0", "0", "0"
            ]
            execute_command(cmd)
            return True

        #TODO: write for kde, xfce4, and LXDE
        return True
Пример #3
0
    def logout(self):
        # IF IS KDE
        if (("KDE_FULL_SESSION" in env)
                and (env["KDE_FULL_SESSION"] == "true")):
            # KDE4
            if (("KDE_SESSION_VERSION" in env)
                    and (env['KDE_SESSION_VERSION'] == '4')):
                executable = is_in_path("qdbus")
                if not executable:
                    return False

                cmd = [
                    executable, "org.kde.ksmserver", "/KSMServer", "logout",
                    "0", "0", "0"
                ]

                execute_command(cmd)
                return True

            # KDE3
            executable = is_in_path('dcop')
            if not executable:
                return False

            cmd = [
                executable, "ksmserver", "ksmserver", "logout", "0", "0", "0"
            ]
            execute_command(cmd)
            return True

        elif "GNOME_DESKTOP_SESSION_ID" in env:
            p = is_in_path("gnome-session-save")

            if not p:
                return False

            cmd = [p, "--logout"]
            execute_command(cmd)

        # FIND XFCE4
        if "xfce4" in get_output_of_command("xprop -root _DT_SAVE_MODE"):
            p = is_in_path("xfce4-session-logout")

            if not p:
                return False

            cmd = [p, "--logout"]
            execute_command(cmd)

            return True

        # BlackBox and fluxbox
        out = get_output_of_command("xprop -root _BLACKBOX_PID")
        if out:
            print out
            m = re.search(r'\d+', out)

            if m:
                pid = int(m.group())
                oskill(pid)
                return True

        #TODO: find session and send logout signal
        pass
Пример #4
0
    def logout(self):
        assert "GDMSESSION" in env, "Session must be specified by environ Variable GDMSESSION"
        session = env["GDMSESSION"]
        
        # Openbox
        if "openbox" in session.lower():
            p = is_in_path("openbox")
            
            if not p:
                return False
            
            cmd = [p, "--exit"]
            execute_command(cmd)
            
        # Send logout signal to GNOME
        elif "gnome" in session.lower():
            p = is_in_path("gnome-session-save")
            
            if not p:
                return False
            
            cmd = [p, "--logout"]
            a = execute_command(cmd)

        if "xfce" in session.lower():
            p = is_in_path("xfce4-session-logout")

            if not p:
                return False

            cmd = [p, "--logout"]
            execute_command(cmd)
            
            return True
            
        elif (("fluxbox" in session.lower()) or 
              ("blackbox" in session.lower())):
            out = get_output_of_command ("xprop -root _BLACKBOX_PID")

            if not out:
                return False

            m = re.search(r'\d+', out)
            
            if not m:
                return False
            
            pid = int(m.group())
            oskill(pid)
            
        elif ("kde" in session.lower()):
            # KDE4
            if (("KDE_SESSION_VERSION" in env) and (env['KDE_SESSION_VERSION'] == '4')):
                executable = is_in_path("qdbus")
                if not executable:
                    return False

                cmd = [executable, "org.kde.ksmserver", "/KSMServer",
                       "logout", "0", "0", "0"]

                execute_command(cmd)
                return True

            # KDE3
            executable = is_in_path('dcop')
            if not executable:
                return False

            cmd = [executable, "ksmserver", "ksmserver",
                   "logout", "0", "0", "0"]
            execute_command(cmd)
            return True


        #TODO: write for kde, xfce4, and LXDE
        return True