From Tacky Penguin, 4 Years ago, written in Plain Text.
Embed
  1. A work around I successfully used in debian, ubuntu and rhel7 is creating a short python script that's started automatically when you log into the gnome session. Note that in rhel7 the key combination to lock is super + l.
  2.  
  3. Create /etc/xdg/autostart/gscreenlock.py like this:
  4.  
  5. #!/usr/bin/python
  6.  
  7. import dbus
  8. import dbus.service
  9. import dbus.glib
  10. import gobject
  11. import os
  12.  
  13. class ScreenDbusObj(dbus.service.Object):
  14.     def __init__(self):
  15.         session_bus = dbus.SessionBus()
  16.         bus_name=dbus.service.BusName("org.gnome.ScreenSaver",bus=session_bus)
  17.         dbus.service.Object.__init__(self,bus_name, '/org/gnome/ScreenSaver')
  18.  
  19.     @dbus.service.method("org.gnome.ScreenSaver")
  20.     def Lock(self):
  21.         os.system( "xscreensaver-command -lock" )
  22.  
  23.  
  24. if __name__ == '__main__':
  25.     object=ScreenDbusObj()
  26.     gobject.MainLoop().run()
  27. Then make it executable:
  28.  
  29. chmod a+rx /etc/xdg/autostart/gscreenlock.py
  30. And edit /etc/xdg/autostart/gscreenlock.desktop like this:
  31.  
  32. [Desktop Entry]
  33. Type=Application
  34. Encoding=UTF-8
  35. Name=gscreenlock
  36. TryExec=/etc/xdg/autostart/gscreenlock.py
  37. Exec=/etc/xdg/autostart/gscreenlock.py
  38. NoDisplay=true
  39. NotShowIn=XFCE;KDE;
  40. Comment=Allows screen locking in gnome
captcha