LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 12-30-2020, 04:22 PM   #1
Tonus
Senior Member
 
Registered: Jan 2007
Location: Paris, France
Distribution: Slackware-15.0
Posts: 1,405
Blog Entries: 3

Rep: Reputation: 514Reputation: 514Reputation: 514Reputation: 514Reputation: 514Reputation: 514
elogind and lock before suspend


Hi all,

Running no power management tool with my WM and was looking for transition from pm-* commands to new elogind ones.

To lock before suspend, elogind uses scripts in /lib{,64}/elogind/system-sleep/

To auto-lock, a simple script like this should do the trick (single user board here, thank you for improvements if you know some)
Code:
username=<YOUR_USERNAME>
userhome=/home/$username
export XAUTHORITY="$userhome/.Xauthority"
export DISPLAY=":0"

            /usr/bin/xautolock -locknow &
            sleep 1s;
I will look for more universal way since telling the username varaiable isn't very reliable...
 
Old 12-30-2020, 04:56 PM   #2
Bindestreck
Member
 
Registered: Jul 2011
Location: Sweden
Distribution: Slackware
Posts: 820

Rep: Reputation: 440Reputation: 440Reputation: 440Reputation: 440Reputation: 440
Hey! This is mine:

Code:
#!/bin/bash

username=alexsson
userhome=/home/$username
export XAUTHORITY="$userhome/.Xauthority"
export DISPLAY=":0.0"
case "${1}" in
    pre)
        su $username -c "/usr/bin/i3lock -B 4 -k --timecolor=ffffff80 --datecolor=ffffff99" &
        sleep 1s;
        ;;
esac
Since, the script itself is executed by "root" (I believe, please correct me if I am wrong), one have to run the lock with a specified username. I would also like to know if it is possible to write a more general script where username is not required.

However, the script just works fine, no issues.
 
1 members found this post helpful.
Old 12-30-2020, 07:15 PM   #3
walecha
Member
 
Registered: Jan 2010
Location: Malang, +62
Distribution: slackware
Posts: 174

Rep: Reputation: 42
I think elogind should locks all running session prior to suspend/hibernate.

But if you want to do that by yourself, then using loginctl is preferred

Code:
loginctl lock-session $XDG_SESSION_ID
 
Old 12-31-2020, 04:29 AM   #4
Tonus
Senior Member
 
Registered: Jan 2007
Location: Paris, France
Distribution: Slackware-15.0
Posts: 1,405

Original Poster
Blog Entries: 3

Rep: Reputation: 514Reputation: 514Reputation: 514Reputation: 514Reputation: 514Reputation: 514
Quote:
Originally Posted by walecha View Post
I think elogind should locks all running session prior to suspend/hibernate.
Does it work for you ? It doesn't here. Neither your loginctl command does.
 
Old 12-31-2020, 04:48 AM   #5
zhl
Member
 
Registered: Oct 2020
Location: Kwangchow
Distribution: Slackware
Posts: 65

Rep: Reputation: Disabled
xss-lock will works correctly since the elogind replacement, see more https://wiki.archlinux.org/index.php..._lock#xss-lock, and the source code at https://bitbucket.org/raymonad/xss-lock. I prefer xss-lock, 'It will not be triggered when looking at videos.'
 
Old 12-31-2020, 04:53 AM   #6
Bindestreck
Member
 
Registered: Jul 2011
Location: Sweden
Distribution: Slackware
Posts: 820

Rep: Reputation: 440Reputation: 440Reputation: 440Reputation: 440Reputation: 440
On Fluxbox, none of the locks gets triggered when suspending. I had to add that script inside system-sleep (I am using i3lock btw).
 
Old 12-31-2020, 05:08 AM   #7
walecha
Member
 
Registered: Jan 2010
Location: Malang, +62
Distribution: slackware
Posts: 174

Rep: Reputation: 42
Quote:
Originally Posted by Tonus View Post
Does it work for you ? It doesn't here. Neither your loginctl command does.
You have to make sure that your login session is registered with elogind

This is my login session in my other slackware PC (via ssh):
Code:
[17:56:39] ~
 $ loginctl
SESSION  UID USER    SEAT  TTY
    c15    0 root    seat0 tty1
    c21 1000 walecha seat0 tty8  <- this my desktop session
    c24 1000 walecha       pts/2 <- this is my ssh login

3 sessions listed.

[18:05:40] ~
 $ loginctl unlock-session c21; sleep 3; loginctl show-session c21 | grep LockedHint
LockedHint=no


[18:06:01] ~
 $ loginctl lock-session c21; sleep 3; loginctl show-session c21 | grep LockedHint
LockedHint=yes
If I want to lock all login session then I just login as root and run:
Code:
# loginctl lock-sessions
 
Old 12-31-2020, 05:13 AM   #8
Bindestreck
Member
 
Registered: Jul 2011
Location: Sweden
Distribution: Slackware
Posts: 820

Rep: Reputation: 440Reputation: 440Reputation: 440Reputation: 440Reputation: 440
Do you know where I can find more information regarding elogind? I want to know how to change the "lock"-app, how to "register" e.t.c. The documentation seems to be difficult to find.
 
Old 12-31-2020, 06:49 AM   #9
walecha
Member
 
Registered: Jan 2010
Location: Malang, +62
Distribution: slackware
Posts: 174

Rep: Reputation: 42
What is your i3 version?

I take a look in the SBo/desktop/i3lock for 14.2 and it is patched to disable pam support, see here.

In current which is using pam, to use elogind, the program must be linked to pam libraries.

IMHO, if you are using SBo 14.2 to build i3 for using in current, I think it's better to use the last available version of i3* so the SlackBuild needs some modification and don't disable pam support.

And maybe using xss-lock as locker:
Here is the snippet from i3 4.19 ${HOME}/.config/i3/config:
Code:
# xss-lock grabs a logind suspend inhibit lock and will use i3lock to lock the
# screen before suspend. Use loginctl lock-session to lock your screen.
exec --no-startup-id xss-lock --transfer-sleep-lock -- i3lock --nofork

Last edited by walecha; 12-31-2020 at 07:41 AM. Reason: xss-lock
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Plasma 5.12 + Wayland + elogind: blank screen after login TKH Gentoo 0 09-23-2018 07:49 PM
How do I get elogind to work with OpenRC? KiwixingDaily Arch 1 03-12-2017 01:34 AM
deian yum lock [ ERR] Reading state information E: Could not get lock /var/lock/aptit jayakumar01 Linux - Server 1 12-05-2011 11:26 AM
lock screen before suspend with power button BCarey Slackware 13 11-27-2007 11:04 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 03:56 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration