GNOME 3’s “screensaver” leaves much to be desired, and if you’re an old school X user like myself, you probably just want the good ole’ screensaver back. Here’s how to install it using the following commands (this will also remove gnome-screensaver):
sudo apt-get remove gnome-screensaver
sudo apt-get install xscreensaver xscreensaver-gl-extra xscreensaver-data-extra
Then search for “Screensaver” in the menu and tweak its settings to your needs.
To add Xscreensaver to startup, open Startup Applications and add “xscreensaver -nosplash”.
Let’s also make the lock screen work (CTRL + ALT + L):
sudo ln -s /usr/bin/xscreensaver-command /usr/bin/gnome-screensaver-command
However, that still leaves the menu. Since that is looking for a dbus entry, we will have to create our own…(That part i kinda had to figure out on my own)
Create a script called screenLock.py with the following code in it
#!/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()
You can place the file anywhere, but for the sake of direction, here’s a good spot:
Create the directory:
mkdir -p ~/.local/share/gnome-shell/customExtensions/Then open the new file in your favorite editor, eg:
vim ~/.local/share/gnome-shell/customExtensions/screenLock.pySet the permissions to executable:
chmod +x ~/.local/share/gnome-shell/customExtensions/screenLock.py
Done.
Tweet
When I try to run this I get the following
session_bus = dbus.SessionBus()
^
IndentationError: expected an indented block
Any ideas what may be the issue?
=]MARKED AS SPAM BY SLIDE2COMMENT[=
Looks like the formatting of the code wasn’t copied over. You should be able to resolve by indenting the lines referenced in the error.
Thanks I will give that a try.
You forgot this command in order to prevent any gnome-screensaver install from overwriting your script:
# dpkg-divert –divert /usr/bin/gnome-screensaver-command.gnome –rename /usr/bin/gnome-screensaver-command
Thanks Giuseppe! That was EXACTLY the command I was looking for to keep this workaround from breaking every few months.