You are not logged in.
I'm trying to make Slock to be activated when the laptop wakes from sleep, but so far no results.
1. First I followed steps from here https://wiki.archlinux.org/title/Slock#Lock_on_suspend
2. Then I tried:
Install xfce4-power-manager and activate it on .xinitrc
I set enable screensaver on lockscreen and no effect, so I uninstalled.
Looking at xset q I saw that I have:
DPMS (Energy Star):
Standby: 600 Suspend: 0 Off: 600
DPMS is Enabled
3. so I created a /etc/X11/xorg.conf.d/10-monitor.conf as is stated on https://wiki.archlinux.org/title/Displa … _DPMS_in_X
4. then I installed xautolock and set in .xinitrc
# Xautolock
xautolock -time 5 -locker slock &
So it works now, but only for minutes of inactivity
If I press FN + F1 which puts my laptop to sleep & I wake it up, I don't have the screensaver enabled.
If I'm asked I prefer a solution with xfce4-power-manager since I have different options for plugin and battery also be able to click on Presentation mode to override DPMS settings, but any solutions are accepted even a different screensaver.
Following step 1 & 2 on Debian 11 worked flawlessly, but now I'm on Arch.
Last edited by mafsi (2022-11-29 17:04:28)
Offline
Stop flailing, you're all over the place.
The X screensaver settings have nothing to do w/ DPMS and none if it relates to S3
* xautolock is a generic "do this on idle" tool
* to use slock as client of the XSS, you'll probalby need https://archlinux.org/packages/communit … /xss-lock/
* The /etc/X11/xorg.conf.d/10-monitor.conf exmample is to deactivate DPMS (by default) - you probably don't want that
* I suspect the xfce4 settings only affect https://archlinux.org/packages/extra/x8 … reensaver/ - which you might or not have installed, but it's not slock
On topic and your original approach, please post the output of
find /etc/systemd -type l -exec test -f {} \; -print | awk -F'/' '{ printf ("%-40s | %s\n", $(NF-0), $(NF-1)) }' | sort -f
Offline
Stop flailing, you're all over the place.
New to linux...
* xautolock is a generic "do this on idle" tool
should I uninstall it?
* The /etc/X11/xorg.conf.d/10-monitor.conf exmample is to deactivate DPMS (by default) - you probably don't want that
I didn't put them on 0. I set them to 5, 10 and 15 minutes
On topic and your original approach, please post the output of
find /etc/systemd -type l -exec test -f {} \; -print | awk -F'/' '{ printf ("%-40s | %s\n", $(NF-0), $(NF-1)) }' | sort -f
$ find /etc/systemd -type l -exec test -f {} \; -print | awk -F'/' '{ printf ("%-40s | %s\n", $(NF-0), $(NF-1)) }' | sort -f
acpid.service | multi-user.target.wants
auto-cpufreq.service | multi-user.target.wants
avahi-daemon.service | multi-user.target.wants
avahi-daemon.socket | sockets.target.wants
bluetooth.service | bluetooth.target.wants
cronie.service | multi-user.target.wants
cups.path | multi-user.target.wants
cups.service | multi-user.target.wants
cups.service | printer.target.wants
cups.socket | sockets.target.wants
dbus-org.bluez.service | system
dbus-org.freedesktop.Avahi.service | system
dbus-org.freedesktop.nm-dispatcher.service | system
fstrim.timer | timers.target.wants
gcr-ssh-agent.socket | sockets.target.wants
getty@tty1.service | getty.target.wants
NetworkManager.service | multi-user.target.wants
NetworkManager-wait-online.service | network-online.target.wants
p11-kit-server.socket | sockets.target.wants
pipewire.socket | sockets.target.wants
pulseaudio.socket | sockets.target.wants
reflector.timer | timers.target.wants
remote-fs.target | multi-user.target.wants
rsyslog.service | multi-user.target.wants
slock@mafsi.service | sleep.target.wants
syslog.service | system
xdg-user-dirs-update.service | default.target.wants
Offline
should I uninstall it?
No, I was just running down the completely different and task unrelated vectors your approached.
You can use xautolock for random stuff just fine, it'll not run anything on S3, though.
I didn't put them on 0. I set them to 5, 10 and 15 minutes
Ok, that fine, but won't achieve anything (other than selecting different DPMS defaults, you can btw. adjust them at runtime w/ "xset")
slock@mafsi.service | sleep.target.wants
Ok, so let's see:
whoami
systemctl status slock@mafsi.service
# at this point suspend and then after a brief moment wake the system
systemctl status slock@mafsi.service
sudo journalctl -b | curl -F 'file=@-' 0x0.st
"sudo journalctl -b | curl -F 'file=@-' 0x0.st" will upload the system journal of the boot to 0x0.st - you can also redirect it into a file, but do not copy the journal out of the pager.
Offline
slock@mafsi.service | sleep.target.wants
Ok, so let's see:whoami systemctl status slock@mafsi.service # at this point suspend and then after a brief moment wake the system systemctl status slock@mafsi.service sudo journalctl -b | curl -F 'file=@-' 0x0.st
"sudo journalctl -b | curl -F 'file=@-' 0x0.st" will upload the system journal of the boot to 0x0.st - you can also redirect it into a file, but do not copy the journal out of the pager.
This is what I got
And in terminal I have
$ systemctl status slock@mafsi.service
× slock@mafsi.service - Lock X session using slock for user mafsi
Loaded: loaded (/etc/systemd/system/slock@.service; enabled; preset: disabled)
Active: failed (Result: exit-code) since Tue 2022-11-29 15:38:06 EET; 30s ago
Process: 18528 ExecStartPre=/usr/bin/xset dpms force suspend (code=exited, status=1/FAILURE)
CPU: 1ms
Nov 29 15:38:06 nighthawk systemd[1]: Starting Lock X session using slock for user mafsi...
Nov 29 15:38:06 nighthawk xset[18528]: Authorization required, but no authorization protocol specified
Nov 29 15:38:06 nighthawk xset[18528]: /usr/bin/xset: unable to open display ":0"
Nov 29 15:38:06 nighthawk systemd[1]: slock@mafsi.service: Control process exited, code=exited, status=1/FAILURE
Nov 29 15:38:06 nighthawk systemd[1]: slock@mafsi.service: Failed with result 'exit-code'.
Nov 29 15:38:06 nighthawk systemd[1]: Failed to start Lock X session using slock for user mafsi.
PS: I followed your advice
o use slock as client of the XSS, you'll probalby need https://archlinux.org/packages/communit … /xss-lock/
an installed XSS. I put xss-lock slock +resetsaver & and Is working now, but still have the feeling that I'm shooting in the dark.
I want to understand how these components are related. I read about DPMS & Xorg but being new to linux I feel that these wiki pages are somehow like an insula with no connections between them. Please point me to a good manual, if you have time.
Last edited by mafsi (2022-11-29 13:53:59)
Offline
Nov 29 15:38:06 nighthawk xset[18528]: Authorization required, but no authorization protocol specified
Nov 29 15:38:06 nighthawk xset[18528]: /usr/bin/xset: unable to open display ":0"
sounds as if you forgot
User=%i
Please post your /etc/systemd/system/slock@.service
Alternatively: how do you start your GUI session? startx/xinit? See the last link below.
Sidebar:
COMMAND=/usr/bin/pacman -Syyu
Consult the pacman manpage on what the second "y" does and then stop using it unless you *really* mean to.
Edit:
https://en.wikipedia.org/wiki/VESA_Disp … _Signaling
DPMS, screensavers and screen lockers and S3 (suspend to ram) are all different and (technically) unconnected things.
One will often want to trigger the DPMS when locking the screen to save power.
Screensavers are a somewhat dated concept that predate DPMS, from a time when 1MWh did cost ~50¢ (according to some grandfather of mine) and sought to protect phosphor displays from burning in ghost images.
suspend to RAM powers down the system - the output will often self-dpms because it loses the signal, but otherwise this has absolutely nothing to do with it.
However, one will also often want to lock the system when sending it to spleep, because one doesn't know who's gonna wake it - and you don't want to expose the system.
Again: these connections are all "social" - there's no technical connection between these things.
Last edited by seth (2022-11-29 14:10:57)
Offline
Please post your /etc/systemd/system/slock@.service
[Unit]
Description=Lock X session using slock for user %i
Before=sleep.target
[Service]
User=%i
Environment=DISPLAY=:0
ExecStartPre=/usr/bin/xset dpms force suspend
ExecStart=/usr/bin/slock
[Install]
WantedBy=sleep.target
Alternatively: how do you start your GUI session? startx/xinit? See the last link below.
initialy by startx then I added this code to .bashrc:
I'm using BSPWM
if [ -z "${DISPLAY}" ] && [ "${XDG_VTNR}" -eq 1 ]; then
exec startx
fi
Sidebar:
COMMAND=/usr/bin/pacman -Syyu
Consult the pacman manpage on what the second "y" does and then stop using it unless you *really* mean to.
This is my function to update system. I know paru there is redundant
####### ==>> Update system & LaTeX
upsys ()
{
sudo pacman -Syyu && \
paru && \
tlmgr update --all --self
}
Last edited by mafsi (2022-11-29 14:15:22)
Offline
initialy by startx then I added this code to .bashrc:
And what does your xinitrc look like?
You may also want to revisit the xserverrc and keep the current VT.
This is my function to update system.
Yes, and the second "y" should not be there. At all.
Offline
And what does your xinitrc look like?
#!/bin/sh
userresources=$HOME/.Xresources
usermodmap=$HOME/.Xmodmap
sysresources=/etc/X11/xinit/.Xresources
sysmodmap=/etc/X11/xinit/.Xmodmap
# merge in defaults and keymaps
if [ -f $sysresources ]; then
xrdb -merge $sysresources
fi
if [ -f $sysmodmap ]; then
xmodmap $sysmodmap
fi
if [ -f "$userresources" ]; then
xrdb -merge "$userresources"
fi
if [ -f "$usermodmap" ]; then
xmodmap "$usermodmap"
fi
# start some nice programs
if [ -d /etc/X11/xinit/xinitrc.d ] ; then
for f in /etc/X11/xinit/xinitrc.d/?*.sh ; do
[ -x "$f" ] && . "$f"
done
unset f
fi
# statusbar
# exec slstatus &
## Wallpaper
# nitrogen --restore &
nitrogen --random --set-scaled /personal/DATA/wallpapers/ &
# xfce4-power-manager &
# Keyboard
setxkbmap -layout "us,ro" -variant ",std" -option "grp:menu_toggle" -option caps:swapescape &
# Redshift
killall -q redshift
redshift &
# faster cursor
xset r rate 300 50
# Desktop manager
# exec dwm
# Lock screen when sleep
xss-lock slock +resetsaver &
# statusbar
# exec slstatus &
exec polybar &
# bspwm
exec bspwm
You may also want to revisit the xserverrc and keep the current VT.
I don't have any xserverrc file
Offline
I don't have any xserverrc file
The idea was to add that.
Sanity check: when you suspend the system, the X11 session is still running, is it?
You're not trying to do so from within a console session?
---
Fyi, the "exec" in "exec polybar &" is nonsense, but not a problem.
Offline
The idea was to add that.
I added this from wiki
#!/bin/sh
exec /usr/bin/Xorg -nolisten tcp "$@" vt$XDG_VTNR
Then I executed again those steps and still have this:
[mafsi@nighthawk ~][0]
$ systemctl status slock@mafsi.service
#### Before suspend #####
○ slock@mafsi.service - Lock X session using slock for user mafsi
Loaded: loaded (/etc/systemd/system/slock@.service; enabled; preset: disabled)
Active: inactive (dead)
[mafsi@nighthawk ~][0]
$ systemctl status slock@mafsi.service
#### Afters suspend #####
× slock@mafsi.service - Lock X session using slock for user mafsi
Loaded: loaded (/etc/systemd/system/slock@.service; enabled; preset: disabled)
Active: failed (Result: exit-code) since Tue 2022-11-29 16:39:15 EET; 1min 11s ago
Process: 1103 ExecStartPre=/usr/bin/xset dpms force suspend (code=exited, status=1/FAILURE)
CPU: 2ms
Nov 29 16:39:15 nighthawk systemd[1]: Starting Lock X session using slock for user mafsi...
Nov 29 16:39:15 nighthawk xset[1103]: Authorization required, but no authorization protocol specified
Nov 29 16:39:15 nighthawk xset[1103]: /usr/bin/xset: unable to open display ":0"
Nov 29 16:39:15 nighthawk systemd[1]: slock@mafsi.service: Control process exited, code=exited, status=1/FAILURE
Nov 29 16:39:15 nighthawk systemd[1]: slock@mafsi.service: Failed with result 'exit-code'.
Nov 29 16:39:15 nighthawk systemd[1]: Failed to start Lock X session using slock for user mafsi.
Sanity check: when you suspend the system, the X11 session is still running, is it?
You're not trying to do so from within a console session?
I press FN + F1 on my Hp keyboard. I don't know how to do it from console
Sidenote: Does this have to do because I don't have gnome-polkit or xfce-polkit installed? Cause I had some trouble launching balena-etcher. The same problem I had on debian but I solved in a dirty way with a file that authorized me all over the system
---
Fyi, the "exec" in "exec polybar &" is nonsense, but not a problem.
thanks
Offline
This isn't a polkit issue, but an xauth one. I suspect that systemd isn't able to properly control the environment or doesn't run the command as your UID.
What is the output of
echo $XAUTHORITY
Next:
scrap the ExecStartPre and make the ExecStart
/usr/bin/sudo -u mafsi DISPLAY=:0 /usr/bin/slock
Don't forget to "systemctl daemon-reload"
Offline
This is my function to update system. I know paru there is redundant
####### ==>> Update system & LaTeX upsys () { sudo pacman -Syyu && \ paru && \ tlmgr update --all --self }
This is a side issue and not related to the topic of this thread, but you should consider carefully whether you wish to automate TeX Live updates in this way. If you rely on TeX, it is wise not to update it at crucial moments (e.g. on the day your dissertation is due or when about to submit that groundbreaking paper or whatever). At the same time, you don't want to postpone updating your system unnecessarily. This obviously depends on your personal preferences and situation, but I wouldn't, personally, want to automate it like that. Again personally, I'd end up forgetting upsys might break my documents.
CLI Paste | How To Ask Questions
Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L
Offline
This isn't a polkit issue, but an xauth one. I suspect that systemd isn't able to properly control the environment or doesn't run the command as your UID.
What is the output of
echo $XAUTHORITY
$ echo $XAUTHORITY
/run/user/1000/Xauthority
Next:
scrap the ExecStartPre and make the ExecStart/usr/bin/sudo -u mafsi DISPLAY=:0 /usr/bin/slock
Don't forget to "systemctl daemon-reload"
I changed slock@mafsi.service as this:
[Unit]
Description=Lock X session using slock for user %i
Before=sleep.target
[Service]
User=%i
Environment=DISPLAY=:0
ExecStart=/usr/bin/sudo -u mafsi DISPLAY=:0 /usr/bin/slock
[Install]
WantedBy=sleep.target
I get the same errors as above
I dont know that to do with this code
Last edited by mafsi (2022-11-29 16:04:26)
Offline
but I wouldn't, personally, want to automate it like that.
Can you point me to a better solution? I'm relying on Tex because I'm writing my PhD.
Offline
I dont know that to do with this code
For the moment, nothing.
It examplifies on how to import relevant environment variables from a different process.
I get the same errors as above
What's the exact service status? Did you reload the daemon?
$ echo $XAUTHORITY
/run/user/1000/Xauthority
That's likely gonna be the problem.
[Unit]
Description=Lock X session using slock for user %i
Before=sleep.target
[Service]
User=%i
Environment=DISPLAY=:0 XAUTHORITY=/run/user/1000/Xauthority
ExecStartPre=/usr/bin/xset dpms force suspend
ExecStart=/usr/bin/slock
[Install]
WantedBy=sleep.target
Offline
What's the exact service status? Did you reload the daemon?
yes I reloaded. Now I restarted laptop after I put your code
[Unit]
Description=Lock X session using slock for user %i
Before=sleep.target
[Service]
User=%i
Environment=DISPLAY=:0 XAUTHORITY=/run/user/1000/Xauthority
ExecStartPre=/usr/bin/xset dpms force suspend
ExecStart=/usr/bin/slock
[Install]
WantedBy=sleep.target
EDITED
$ systemctl status slock@mafsi.service
○ slock@mafsi.service - Lock X session using slock for user mafsi
Loaded: loaded (/etc/systemd/system/slock@.service; enabled; preset: disabled)
Active: inactive (dead)
Nov 29 18:41:41 nighthawk systemd[1]: Starting Lock X session using slock for user mafsi...
Nov 29 18:41:42 nighthawk systemd[1]: Started Lock X session using slock for user mafsi.
Nov 29 18:41:56 nighthawk systemd[1]: slock@mafsi.service: Deactivated successfully.
Now is working.! Finally!
Wraping up
1. If I reinstall the system in the future, should I put the same code as you put it here?
2. I saw XAUTHORITY=/run/user/1000/Xauthority in the code, so I didn't test it, but I had problems to have notification with cron, so I search on the internet and finaly I came with the solution to put this code in my script in order to have notification
#!/bin/bash
export "XDG_RUNTIME_DIR"=/run/user/$(id -u)
# Start notification
notify-send "News Alert" "Update...";
newsboat -x reload
Do you think that is related?
Thanks a lot for your help!
Last edited by mafsi (2022-11-29 16:51:08)
Offline
Do you think that is related?
/run/user/$(id -u) is supposed to be the default XDG_RUNTIME_DIR, what is it for you otherwise?
notify-send uses dbus, so it's not xauthority related and out of context (system cron or user cron? what was the solution for what script? What was the problem?) I really can't tell whether and how what is related.
However, the default XAUTHORITY should™ be empty and then default to ~/.Xauthority, so I'd rather look what and where exports the different path.
Please always remember to mark resolved threads by editing your initial posts subject - so others will know that there's no task left, but maybe a solution to find.
Thanks.
Offline
Do you think that is related?
/run/user/$(id -u) is supposed to be the default XDG_RUNTIME_DIR, what is it for you otherwise?
notify-send uses dbus, so it's not xauthority related and out of context (system cron or user cron? what was the solution for what script? What was the problem?) I really can't tell whether and how what is related.
However, the default XAUTHORITY should™ be empty and then default to ~/.Xauthority, so I'd rather look what and where exports the different path.Please always remember to mark resolved threads by editing your initial posts subject - so others will know that there's no task left, but maybe a solution to find.
Thanks.
My .Xauthority is empty. The solution for that script was to put
export "XDG_RUNTIME_DIR"=/run/user/$(id -u)
in the script. Without it I dont get notification on user cron
Offline
My .Xauthority is empty.
Cause you're not using it but /run/user/1000/Xauthority
What's the output of
echo $XDG_RUNTIME_DIR
otherwise?
Offline
My .Xauthority is empty.
Cause you're not using it but /run/user/1000/Xauthority
What's the output of
echo $XDG_RUNTIME_DIR
otherwise?
$ echo $XDG_RUNTIME_DIR
/run/user/1000
Offline
Well, you'd be setting the value to itself then?
#!/bin/bash
echo "wtf: $XDG_RUNTIME_DIR" >> /tmp/cron.XDG_RUNTIME_DIR
export XDG_RUNTIME_DIR=/run/user/$(id -u)
# Start notification
notify-send "News Alert" "Update...";
newsboat -x reload
And see what the cronjob prints into /tmp/cron.XDG_RUNTIME_DIR to reveal the value in that context (before you set it)
Offline
And see what the cronjob prints into /tmp/cron.XDG_RUNTIME_DIR to reveal the value in that context (before you set it)
I get only wtf:
PS: Do you want me to split this conversation into another topic?
Last edited by mafsi (2022-11-30 14:31:52)
Offline
Ok, checked - XDG_RUNTIME_DIR isn't available in the crontab context here either.
The crucial bit is likely the DBUS_SESSION_BUS_ADDRESS, though:
https://wiki.archlinux.org/title/Cron#R … plications
Offline