all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Chris Marusich <cmmarusich@gmail.com>
To: Peter Baumgarten <me@peterbaumgarten.com>,
	Timothy Sample <samplet@ngyro.com>
Cc: help-guix@gnu.org
Subject: Re: Lock screen gnome
Date: Sat, 15 Dec 2018 21:05:22 -0800	[thread overview]
Message-ID: <87r2eivz71.fsf@gmail.com> (raw)
In-Reply-To: 875zvvsppt.fsf@ngyro.com

[-- Attachment #1: Type: text/plain, Size: 3507 bytes --]

Hi Peter and Timothy,

Timothy Sample <samplet@ngyro.com> 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))))
              services)))

  (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]
  Version=1.0
  Type=Application
  Name=XScreenSaver
  Comment=Launch XScreenSaver
  Exec=xscreensaver -nosplash
  StartupNotify=false
  Terminal=false
  Hidden=false

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!

Footnotes: 
[1]  https://www.jwz.org/xscreensaver/faq.html#setuid

[2]  https://specifications.freedesktop.org/autostart-spec/0.5/

-- 
Chris

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

  reply	other threads:[~2018-12-16  5:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-14 20:20 Lock screen gnome Peter Baumgarten
2018-12-14 22:33 ` Timothy Sample
2018-12-16  5:05   ` Chris Marusich [this message]
2018-12-16 17:35     ` Peter Baumgarten
2018-12-19 13:52   ` Ludovic Courtès
2018-12-19 19:43     ` Gábor Boskovits
2018-12-20 14:48       ` Timothy Sample

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r2eivz71.fsf@gmail.com \
    --to=cmmarusich@gmail.com \
    --cc=help-guix@gnu.org \
    --cc=me@peterbaumgarten.com \
    --cc=samplet@ngyro.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.