[MATE] How to properly set up XScreensaver

Write tutorials for Linux Mint here
More tutorials on https://github.com/orgs/linuxmint/discu ... /tutorials and (archive) on https://community.linuxmint.com/tutorial
Forum rules
Don't add support questions to tutorials; start your own topic in the appropriate sub-forum instead. Before you post read forum rules
Post Reply
MintRainbow

[MATE] How to properly set up XScreensaver

Post by MintRainbow »

Edit from original; Terminal commands were italicized before, but are now underlined to differentiate them from italics used for emphasis.
Using Xfce? XScreensaver is the screensaver by default!


No long-winded introduction or rationale, just a simple guide for getting XScreensaver up and running. If you don't know what the hype is about, then there are more than enough articles explaining how to replace your DE's screensaver with XScreensaver. This will be specifically for MATE but can be applied to other DEs as well, with maybe some extra work here or there.

...Okay, I lied a little. It must be said, before anything else that this guide is meant for people who do not want to use symbolic links to spoof xscreensaver so it acts as mate-screensaver. If you're after that and don't mind your fix to be quick and dirty, this will avoid having to modify a bunch of other stuff, but when an upgrade to mate-screensaver is performed, this method may break and you'll have to do it all over again. Not a big deal for most people, but not a sane method either;

Code: Select all

mv /usr/bin/mate-screensaver /usr/bin/.mate-screensaver
mv /usr/bin/mate-screensaver-command /usr/bin/.mate-screensaver-command
mv /usr/bin/mate-screensaver-preferences /usr/bin/.mate-screensaver-preferences
ln -s /usr/bin/xscreensaver /usr/bin/mate-screensaver
ln -s /usr/bin/xscreensaver-command /usr/bin/mate-screensaver-command
ln -s /usr/bin/xscreensaver-demo /usr/bin/mate-screensaver-preferences
That will certainly fix it so xscreensaver is used for everything that expects Mate's screensaver binaries. But the reason this isn't sane is because it compromises the integrity of the installation in ways that may affect users after a system upgrade, if you commit to using Mint for that long. This thread is made for people who want to take a little time to ensure a "Sane" installation of xscreensaver, without needing to directly modify anything provided by the MATE desktop environment. With that out of the way, let's begin.

First, go into Screensaver (mate-screensaver-preferences) and disable it completely. Then, install XScreensaver;

Code: Select all

sudo apt-get install xscreensaver
Open startup settings (mate-session-properties) and disable screensaver. Make a new startup entry that executes xscreensaver -nosplash

You may also execute this command if you want it to run right now, you can tinker with things using xscreensaver-demo

After that, open keyboard shortcuts (mate-keybinding-properties) and disable the default lock screen command by re-assigning it and pressing [Backspace] (⌫ or ⟵). Then make a custom shortcut for [Ctrl] + [Alt] + L to execute xscreensaver-command -lock

Using the above steps, I managed to make xscreensaver run without the need to remove or symbolically link anything. Normally most guides would tell you to remove your old screensaver, but since mint-meta-mate requires mate-screensaver, removing the latter also removes the former, which isn't desirable if you plan to upgrade Mint in the future.

update 02/26/16 There were some wrinkles in my original plans, namely the use of the "Lock screen" shortcut in Mint Menu. Using some advice from Xenopeek's reply in this thread I was able to figure it out. Below are the entire contents of my system_management.py file, which can be found in /usr/lib/linuxmint/mintMenu/plugins. Open that as superuser in whatever editor you use and copy these contents into it;

Code: Select all

#!/usr/bin/python2

######################################################################
# Copy into /usr/lib/linuxmint/mintMenu/plugins/system_management.py #
######################################################################
import gi
gi.require_version("Gtk", "2.0")

from gi.repository import Gtk
import os
import string
import gettext

from easybuttons import *
from execute import Execute
from easygsettings import EasyGSettings

# i18n
gettext.install("mintmenu", "/usr/share/linuxmint/locale")

class pluginclass( object ):

    def __init__( self, mintMenuWin, toggleButton, de ):

        self.mintMenuWin = mintMenuWin
        self.toggleButton = toggleButton
        self.de = de


        self.builder = Gtk.Builder()
        self.builder.add_from_file (os.path.join( os.path.dirname( __file__ ), "system_management.glade" ))

        self.systemBtnHolder    = self.builder.get_object( "system_button_holder" )
        self.editableBtnHolder  = self.builder.get_object( "editable_button_holder" )
        self.scrolledWindow = self.builder.get_object( "scrolledwindow2" )

        # These properties are NECESSARY to maintain consistency

        # Set 'window' property for the plugin (Must be the root widget)
        self.window = self.builder.get_object( "mainWindow" )

        # Set 'heading' property for plugin
        self.heading = _("System")

        # This should be the first item added to the window in glade
        self.content_holder = self.builder.get_object( "System" )

        # Items to get custom colors
        self.itemstocolor = [ self.builder.get_object( "viewport2" ) ]

        # Gconf stuff
        self.settings = EasyGSettings( "com.linuxmint.mintmenu.plugins.system_management" )

        self.settings.notifyAdd( "icon-size", self.RegenPlugin )
        self.settings.notifyAdd( "show-control-center", self.RegenPlugin )
        self.settings.notifyAdd( "show-lock-screen", self.RegenPlugin )
        self.settings.notifyAdd( "show-logout", self.RegenPlugin )
        self.settings.notifyAdd( "show-package-manager", self.RegenPlugin )
        self.settings.notifyAdd( "show-software-manager", self.RegenPlugin )
        self.settings.notifyAdd( "show-terminal", self.RegenPlugin )
        self.settings.notifyAdd( "show-quit", self.RegenPlugin )
        self.settings.notifyAdd( "allow-scrollbar", self.RegenPlugin )
        self.settings.notifyAdd( "height", self.changePluginSize )
        self.settings.notifyAdd( "width", self.changePluginSize )
        self.settings.bindGSettingsEntryToVar( "bool", "sticky", self, "sticky" )

        self.GetGSettingsEntries()

        self.content_holder.set_size_request( self.width, self.height )

    def destroy( self ):
        self.settings.notifyRemoveAll()

    def wake (self) :
        pass

    def changePluginSize( self, settings, key, args ):
        self.allowScrollbar = self.settings.get( "bool", "allow-scrollbar")
        if key == "width":
            self.width = settings.get_int(key)
        elif key == "height":
            if (self.allowScrollbar == False):
                self.height = -1
                self.scrolledWindow.set_policy( Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.NEVER )
            else:
                self.scrolledWindow.set_policy( Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC )
                self.height = settings.get_int(key)

        self.content_holder.set_size_request( self.width, self.height )


    def RegenPlugin( self, *args, **kargs ):
        self.GetGSettingsEntries()
        self.ClearAll()
        self.do_standard_items()

    def GetGSettingsEntries( self ):

        self.width = self.settings.get( "int", "width")
        self.allowScrollbar = self.settings.get( "bool", "allow-scrollbar")
        self.scrolledWindow.set_policy( Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC )
        self.height = self.settings.get( "int", "height")
        self.content_holder.set_size_request( self.width, self.height )
        if (self.allowScrollbar == False):
            self.height = -1
            self.scrolledWindow.set_policy( Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.NEVER )
        self.content_holder.set_size_request( self.width, self.height )
        self.iconsize = self.settings.get( "int","icon-size")

        # Check toggles

        self.showSoftwareManager = self.settings.get( "bool", "show-software-manager")
        self.showPackageManager = self.settings.get( "bool", "show-package-manager")
        self.showControlCenter = self.settings.get( "bool", "show-control-center")
        self.showTerminal = self.settings.get( "bool", "show-terminal")
        self.showLockScreen = self.settings.get( "bool", "show-lock-screen")
        self.showLogout = self.settings.get( "bool", "show-logout")
        self.showQuit = self.settings.get( "bool", "show-quit")

        # Hide vertical dotted separator
        self.hideseparator = self.settings.get( "bool", "hide-separator")
        # Plugin icon
        self.icon = self.settings.get( "string", "icon" )
        # Allow plugin to be minimized to the left plugin pane
        self.sticky = self.settings.get( "bool", "sticky")
        self.minimized = self.settings.get( "bool", "minimized")

    def ClearAll(self):
        for child in self.systemBtnHolder.get_children():
            child.destroy()
        for child in self.editableBtnHolder.get_children():
            child.destroy()

    #Add standard items
    def do_standard_items( self ):

        if ( self.showSoftwareManager == True ):
            if os.path.exists("/usr/lib/linuxmint/mintInstall/icon.svg"):
                Button1 = easyButton( "/usr/lib/linuxmint/mintInstall/icon.svg", self.iconsize, [_("Software Manager")], -1, -1 )
                Button1.connect( "clicked", self.ButtonClicked, "gksu mintinstall" )
                Button1.show()
                self.systemBtnHolder.pack_start( Button1, False, False, 0)
                self.mintMenuWin.setTooltip( Button1, _("Browse and install available software") )

        if ( self.showPackageManager == True ):
            Button2 = easyButton( "applications-system", self.iconsize, [_("Package Manager")], -1, -1 )
            Button2.connect( "clicked", self.ButtonClicked, "gksu /usr/sbin/synaptic" )
            Button2.show()
            self.systemBtnHolder.pack_start( Button2, False, False, 0 )
            self.mintMenuWin.setTooltip( Button2, _("Install, remove and upgrade software packages") )

        if ( self.showControlCenter == True ):
            Button3 = easyButton( "gtk-preferences", self.iconsize, [_("Control Center")], -1, -1 )
            if self.de == "xfce":
                Button3.connect( "clicked", self.ButtonClicked, "xfce4-settings-manager" )
            else:
                Button3.connect( "clicked", self.ButtonClicked, "mate-control-center" )
            Button3.show()
            self.systemBtnHolder.pack_start( Button3, False, False, 0 )
            self.mintMenuWin.setTooltip( Button3, _("Configure your system") )

        if ( self.showTerminal == True ):
            Button4 = easyButton( "terminal", self.iconsize, [_("Terminal")], -1, -1 )
            if os.path.exists("/usr/bin/mate-terminal"):
                Button4.connect( "clicked", self.ButtonClicked, "x-terminal-emulator" )
            else:
                Button4.connect( "clicked", self.ButtonClicked, "mate-terminal" )
            Button4.show()
            self.systemBtnHolder.pack_start( Button4, False, False, 0 )
            self.mintMenuWin.setTooltip( Button4, _("Use the command line") )

        if self.de == "xfce":
            Button6 = easyButton( "system-log-out", self.iconsize, [_("Logout")], -1, -1 )
            Button6.connect( "clicked", self.ButtonClicked, "xfce4-session-logout" )
            Button6.show()
            self.systemBtnHolder.pack_start( Button6, False, False, 0 )
            self.mintMenuWin.setTooltip( Button6, _("Log out or switch user") )
        else:
            if ( self.showLockScreen == True ):
                Button5 = easyButton( "system-lock-screen", self.iconsize, [_("Lock Screen")], -1, -1 )
                if os.path.exists("/usr/bin/mate-screensaver-command"):
                    Button5.connect( "clicked", self.ButtonClicked, "xdg-screensaver lock" )
                else:
                    Button5.connect( "clicked", self.ButtonClicked, "mate-screensaver-command -l" )
                Button5.show()
                self.systemBtnHolder.pack_start( Button5, False, False, 0 )
                self.mintMenuWin.setTooltip( Button5, _("Requires password to unlock") )

            if ( self.showLogout == True ):
                Button6 = easyButton( "system-log-out", self.iconsize, [_("Logout")], -1, -1 )
                Button6.connect( "clicked", self.ButtonClicked, "mate-session-save --logout-dialog" )
                Button6.show()
                self.systemBtnHolder.pack_start( Button6, False, False, 0 )
                self.mintMenuWin.setTooltip( Button6, _("Log out or switch user") )

            if ( self.showQuit == True ):
                Button7 = easyButton( "system-shutdown", self.iconsize, [_("Quit")], -1, -1 )
                Button7.connect( "clicked", self.ButtonClicked, "mate-session-save --shutdown-dialog" )
                Button7.show()
                self.systemBtnHolder.pack_start( Button7, False, False, 0 )
                self.mintMenuWin.setTooltip( Button7, _("Shutdown, restart, suspend or hibernate") )

    def ButtonClicked( self, widget, Exec ):
        self.mintMenuWin.hide()
        if Exec:
            Execute( Exec )

    def do_plugin( self ):
        self.do_standard_items()
Once finished, log off, then sign back in. This code will fix the script so xdg-screensaver is used in favour of mate-screensaver, and it will also change the default terminal to x-window-terminal in favour of mate-terminal. The latter will affect nothing unless you modify what terminal is used with update-alternatives, while the former will not work with mate-screensaver, unless as root the following is done;

Code: Select all

sudo ln -s /usr/bin/mate-screensaver-command /usr/bin/gnome-screensaver-command
If you find you do not like what XScreensaver has to offer, then simply link mate-screensaver-command as presented above, and no further changes will have to be made unless you intend to install gnome-screensaver, and I think even then if you did, your link would be overwritten with the actual file it's spoofing for xdg-screensaver to perform as intended.

Since the lock screen applet is forever bound to run Mate's binaries, you'll need to add a drawer for the lock screen should you elect to have a panel button and use that instead for the following custom launcher commands;
xscreensaver-command --activate or xdg-screensaver activate for engaging the screensaver
xscreensaver-command --lock or xdg-screensaver lock for locking the screen
xscreensaver-demo for screensaver preferences.

For images, I used the following;
Drawer icon: /usr/share/icons/Mint-X/apps/96/screensaver.svg
Activate: /usr/share/icons/Mint-X/apps/96/screensaver.svg
Lock: Drawer icon
xscreensver-demo: /usr/share/icons/Mint-X/apps/48/xscreensaver-demo.svg*
*: I made a link from /usr/share/pixmaps/xscreensaver.svg into the path above, so it shows the xscreensaver logo.

After that, you should have everything you could possibly want to execute xscreensaver, without ever having to touch mate's screensaver binaries directly.
Last edited by MintRainbow on Sat Feb 27, 2016 10:15 pm, edited 22 times in total.
MintRainbow

Re: [MATE] Things to do after installing XScreensaver

Post by MintRainbow »

My OP missed a step. Not sure if you need to, but I added a step to disable the old screensaver first through mate-screensaver-preferences before anything else. I also botced up xscreensaver-command. My keyboard sucks.
MintRainbow

Re: [MATE] How to properly set up XScreensaver

Post by MintRainbow »

Added information about spoofing gnome-screensaver when the system_management.py file in the updated OP is in use, giving people an easy means to fix the screensaver command stuff when "Lock Screen" is clicked on from Mint Menu both while XScreensaver is installed and after XScreensaver has been removed, with the default screensaver Mate provides put back into use.

Also, thanks for that information Xenopeek, came in handy.
MintRainbow

Re: [MATE] How to properly set up XScreensaver

Post by MintRainbow »

Added what I did to make a pseudo-applet using a drawer applet and some tinkering.
User avatar
RobertLM78
Level 3
Level 3
Posts: 183
Joined: Sat Apr 28, 2012 4:19 am
Location: US

Re: [MATE] How to properly set up XScreensaver

Post by RobertLM78 »

Awesome! I swear there is a memory leak the the mate-screensaver. Hopefully this will resolve the issue. Thanks for posting...! 8)
Gateway DX4860, Sapphire Radeon HD 5450, 8 GB RAM, Mint 17.3 64-bit (Rosa), MATE
AMD Ryzen 3-3100, AMD Radeon RX 570, 16 GB RAM, Mint 21 (Vanessa), MATE
Post Reply

Return to “Tutorials”