Paul - The Programmer

simple & stupid
Upgrade from Debian stable to testing
solve the KMS incompatible issue of ATI card

Lock screen with xscreensaver by Gnome menu 'System / Lock Screen'

paul posted @ Wed, 01 Dec 2010 03:28:32 +0800 in about debian with tags XScreensaver lock , 3139 readers

First of all, the xscreensaver should be installed and replace the default gnome-screensaver.

You may follow the instructions from the post :

http://ubuntuforums.org/showthread.php?t=195557

Then, to recover the menu 'System / Lock Screen',  the dbus object org.gnome.ScreenSaver should be created.

I use the below python script to create the org.gnome.ScreenSaver.

#!/usr/bin/python

import dbus
import dbus.service
import dbus.glib
import gobject
import os

class ScreenDbusObj(dbus.service.Object):
    def __init__(self):
        session_bus = dbus.SessionBus()
        bus_name=dbus.service.BusName("org.gnome.ScreenSaver",bus=session_bus)
        dbus.service.Object.__init__(self,bus_name, '/org/gnome/ScreenSaver')

    @dbus.service.method("org.gnome.ScreenSaver")
    def Lock(self):
        os.system( "xscreensaver-command -lock" )


if __name__ == '__main__':
    object=ScreenDbusObj()
    gobject.MainLoop().run()

Keep this script running on the background. The 'Lock Screen' button will call the method Lock and the method Lock will execute the xscreensaver-command -lock.

To automatically start this script, add the command,

i.e. /path-to-the-script/myscreen-dbus.py &

in the System/Preferences/Sessions.

Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 Unported License.
  • No match
  • No match

Login *


loading captcha image...
(type the code from the image)
or Ctrl+Enter