You are not logged in.
I got screen locking to work after resuming from suspend (and hibernate) with this unit file:
https://forum.archlabslinux.com/t/how-t … ed/2065/45
So you don't need an After= statement or the WantedBy=multi-user.target, just add the various suspend & hibernate .targets to the WantedBy= string.
If you still have problems then perhaps try a per-user instance (as with my example) rather then a --user service (and import the DBUS_SESSION_BUS_ADDRESS globally).
Sorry got post cutted - didn't manage to read your post.
Offline
It gives me this error with "User=%I"
Mar 17 12:46:57 Kevin-B350MA systemd[848]: Failed to start Fixes wallpaper after suspend and resets keyboard layout to UK.
Mar 17 12:48:55 Kevin-B350MA systemd[848]: /home/kevin/.config/systemd/user/kbd-and-background-fix.service:4: Invalid user/group name or numeric ID: [Unit]
Description=Fixes wallpaper after suspend and resets keyboard layout to UK
[Service]
User=%I
Environment=DISPLAY=:1
Type=oneshot
ExecStart=/usr/bin/kbd-and-background-fix
[Install]
WantedBy=suspend.target sleep.target hibernate.target hybrid-sleep.target suspend-then-hibernate.targetIt now works after waking up the system from suspension.
Offline
It gives me this error with "User=%I"
Yeah, sorry, that should probably be %i if you have a dash in your user name.
So is this [SOLVED] then?
Jin, Jîyan, Azadî
Offline
I'll test it first.
EDIT: Nope - same error occurs.
Offline
You shouldn't need the User= line if your using a --user .service (as you appear to be from the location of the unit file), that is only needed for an instance.
Jin, Jîyan, Azadî
Offline
Right. Without the User= line it runs fine. But now it doesn't run when intended - after waking up the system.
Offline
OK, so disable & stop the --user .service and try an instance instead, for example:
# /etc/systemd/system/kbd-and-background-fix@.service
[Unit]
Description=Fixes wallpaper after suspend
[Service]
User=%i
Environment=DISPLAY=:1
ExecStart=/usr/bin/kbd-and-background-fix
[Install]
WantedBy=suspend.target sleep.target hibernate.target hybrid-sleep.target suspend-then-hibernate.targetThen enable & start it with
# systemctl enable --now kbd-and-background-fix@$userReplace $user with your actual user name.
Are you sure that DISPLAY value is correct?
Check with
echo $DISPLAYfrom your graphical desktop.
Jin, Jîyan, Azadî
Offline
Yes, my $DISPLAY is :1
I get this error:
Mar 17 15:41:12 Kevin-B350MA kbd-and-background-fix[24630]: Failed to open connection to "session" message bus: Server address of type unix was missing argument path or abstractIt is now running on waking up from suspend.
Offline
The relevant environment here is $DBUS_SESSION_BUS_ADDRESS
Online
Import the environment globally:
systemctl import-environment DBUS_SESSION_BUS_ADDRESSJin, Jîyan, Azadî
Offline
It works now. But how can I get it run when the screen is unlocked? Because right now it is overriding the screen lock and unlocking my system automatically.
Offline
I suppose you could try adding /usr/bin/slock to the unit file as another ExecStart (and specifying Type=oneshot).
Jin, Jîyan, Azadî
Offline
Going to mark as solved now. Got it to work.
Unit file if anybody is interested:
[Unit]
Description=Fixes wallpaper after suspend and resets keyboard layout to UK
[Service]
User=%i
Environment=DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus DISPLAY=:1
ExecStart=/usr/bin/kbd-and-background-fix
[Install]
WantedBy=suspend.target sleep.target hibernate.target hybrid-sleep.target suspend-then-hibernate.targetExecutable if anybody's interested:
#!/bin/sh
dbus-send --type=method_call --dest=org.gnome.Shell /org/gnome/Shell org.gnome.Shell.Eval "string:global.reexec_self()"
sleep 6
gnome-screensaver-command -l
setxkbmap gbThanks for your help ![]()
Last edited by Vectorlocity (2019-03-17 17:45:38)
Offline