if __name__ == '__main__':
object=ScreenDbusObj()
gobject.MainLoop().run()
You should 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, you need to add the command, i.e. /path-to-the-script/myscreen-dbus.py & in the System/Preferences/Sessions.
Since you have disabled the gnome-screensaver, the dbus object org.gnome. ScreenSaver is not created while the Gnome starts.
We need to create the dbus object org.gnome. ScreenSaver and implement the Lock method.
I use the below python script to create the org.gnome. ScreenSaver.
----------- myscreen-dbus.py --------
#!/usr/bin/python
import dbus
import dbus.service
import dbus.glib
import gobject
import os
class ScreenDbusObj( dbus.service. Object) :
bus_name= dbus.service. BusName( "org.gnome. ScreenSaver" ,bus=session_ bus)
dbus.service. Object. __init_ _(self, bus_name, '/org/gnome/ ScreenSaver' )
def __init__(self):
session_bus = dbus.SessionBus()
@dbus. service. method( "org.gnome. ScreenSaver" ) command -lock" )
def Lock(self):
os.system( "xscreensaver-
if __name__ == '__main__': ScreenDbusObj( ) MainLoop( ).run()
object=
gobject.
You should 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, you need to add the command, i.e. /path-to- the-script/ myscreen- dbus.py & in the System/ Preferences/ Sessions.
P.S.
You don't need the ScreenSaver .service file