inside the mind of a linux admin

Gnome3: replace gnome-screensaver with xscreensaver

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.py

Set the permissions to executable:
chmod +x ~/.local/share/gnome-shell/customExtensions/screenLock.py

Done.

Related Posts

How to revert back to X11 / Xorg from Wayland

Wayland is intended as a “simpler replacement for X”, and is getting quite a bit of hype around the Linux community. So much so, that it’s the default in the latest versions of Fedora, GNOME, KDE and others. While Wayland may be the future, it really is in future. At least for Ubuntu 17.10. The […]

Read More

Touchpad stops working after sleep + resume (Fedora 26 on Dell XPS)

After recently upgrading my Dell XPS 13 w/Touchscreen to Fedora 26, the touchpad suddenly stopped working upon resuming from sleep mode. It was reproduced 100% of the time, and required a complete restart in order to get the touchpad working again. There have been several forum posts and bug reports regarding others experiencing these exact […]

Read More

5 Comments

  • John on Thursday, March 14, 2013

    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?

  • kire on Friday, March 15, 2013

    =]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.

  • John on Friday, March 15, 2013

    Thanks I will give that a try.

  • Giuseppe on Saturday, July 12, 2014

    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

  • Larry on Tuesday, May 12, 2015

    Thanks Giuseppe! That was EXACTLY the command I was looking for to keep this workaround from breaking every few months.

Leave a Reply

Your email address will not be published. Required fields are marked *

Twitter: kireguy

Tweeter button Facebook button Myspace button