[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Lock screen gnome

From: Peter Baumgarten
Subject: Re: Lock screen gnome
Date: Sun, 16 Dec 2018 12:35:21 -0500
User-agent: Cyrus-JMAP/3.1.5-699-g45da087-fmstable-20181212v1

Thank you both. I'm glad it is not a mistake I did. I would like to fix the GDM bug(s) but right now I do not know scheme nor do I know much about how GDM, X, and Wayland work. I am learning scheme from this book though.

On Sun, Dec 16, 2018, at 5:05 AM, Chris Marusich wrote:
Hi Peter and Timothy,

Timothy Sample <address@hidden> writes:

> [...] If I want to lock and suspend, I use the following rather
> unglamorous command:
>     $ xlock & (sleep 3; loginctl suspend)
> If anyone has any better advice, I would love to hear it!

I do something similar, but with xscreensaver.  I set it up so that my
screen automatically locks after a period of no activity, and also so
that I can manually lock it on demand.  Here's how I do it.

First, in my OS configuration file, I replace all screen lockers in
%desktop-services with a screen locker service that uses xscreensaver:

  (services (cons*
             (screen-locker-service xscreensaver)
             (remove-screen-lockers %desktop-services)))

The procedure remove-screen-lockers is a custom procedure I've defined
in my OS config file.  Here it is:

  (define (remove-services kind-to-remove)
    "Return a procedure that accepts a single argument (a list of
  <service> objects) and returns a new list that contains the same
  elements, but with the specified kind-to-remove removed."
    (lambda (services)
      (remove (match-lambda
              ((? service? s)
               (eq? kind-to-remove (service-kind s))))

  (define remove-screen-lockers
    (remove-services 'screen-locker))

You don't have to remove all the other screen lockers, but I didn't need
them, so I decided to remove them.

This installs specifically the "xscreensaver" program as a setuid-root
program.  This makes it possible to manually start the xscreensaver
program and to configure it (both via the "xscreensaver" program).

Because I also want to be able to manually lock the screen on demand
(via the separate "xscreensaver-command" program), I also install the
xscreensaver package to my system profile by adding it to the "packages"
field of my OS declaration.  You probably don't want to add it to your
user profile, since if you do that, your user profile's "xscreensaver"
program (which is not setuid-root) will take precedence (via the PATH
environment variable) over the setuid-root "xscreensaver" program
installed in /run/setuid-programs.  Although it's technically possible
for xscreensaver to function correctly without being setuid root [1], I
haven't figured out how to do it on GuixSD at this time.

Once the xscreensaver package is installed, I create an alias in my
~/.bashrc that enables me to lock the screen on demand after
xscreensaver has been started.

  alias lk='xscreensaver-command -activate'

Finally, to start xscreensaver automatically when I log into a desktop
session, I create an autostart file [2] named
~/.config/autostart/xscreensaver.desktop with the following contents:

  [Desktop Entry]
  Comment=Launch XScreenSaver
  Exec=xscreensaver -nosplash

Reconfigure your system and reboot to verify that it still boots.  To
lock the screen while logged into GNOME or similar, just open a terminal
(e.g., GNOME Terminal) and run lk.  You can also configure xscreensaver
by running xscreensaver-prefs.  From there, you can configure
xscreenlocker to lock the screen after a certain period of idle time.

Anyway, I hope that helps!




reply via email to

[Prev in Thread] Current Thread [Next in Thread]