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

synergy: How to enable crypto (encryption) and generate SSL certificate

The newer Linux versions of the popular mouse/keyboard sharing application “synergy” now has built in encryption. Here’s how to configure it: Just simply passing the –enable-crypto flag on your synergy server without having a proper SSL certificate will result in the inability to connect to clients and generate an error message similar to this in […]

Read More

Change Number Pad Delete (dot) key from a comma in Ubuntu Linux

I recently purchased a new keyboard and updated to the latest Ubuntu, I’m also an avid user of the number pad for quick input when dealing with spreadsheets or accounting. I found that my num pad’s delete key (“.”) was outputting a comma (“,”) instead. Pretty annoying? I agree, but this can be very easily […]

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 *

This site uses Akismet to reduce spam. Learn how your comment data is processed.