You are not logged in.

#26 2019-03-17 11:29:20

Vectorlocity
Member
Registered: 2018-04-15
Posts: 132

Re: [SOLVED] Systemd errors

Head_on_a_Stick wrote:

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

#27 2019-03-17 12:50:21

Vectorlocity
Member
Registered: 2018-04-15
Posts: 132

Re: [SOLVED] Systemd errors

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.target

It now works after waking up the system from suspension.

Offline

#28 2019-03-17 13:04:30

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 9,003
Website

Re: [SOLVED] Systemd errors

Vectorlocity wrote:

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

#29 2019-03-17 13:13:15

Vectorlocity
Member
Registered: 2018-04-15
Posts: 132

Re: [SOLVED] Systemd errors

I'll test it first.

EDIT: Nope - same error occurs.

Offline

#30 2019-03-17 13:39:43

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 9,003
Website

Re: [SOLVED] Systemd errors

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

#31 2019-03-17 14:52:51

Vectorlocity
Member
Registered: 2018-04-15
Posts: 132

Re: [SOLVED] Systemd errors

Right. Without the User= line it runs fine. But now it doesn't run when intended - after waking up the system.

Offline

#32 2019-03-17 15:25:19

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 9,003
Website

Re: [SOLVED] Systemd errors

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.target

Then enable & start it with

# systemctl enable --now kbd-and-background-fix@$user

Replace $user with your actual user name.

Are you sure that DISPLAY value is correct?

Check with

echo $DISPLAY

from your graphical desktop.


Jin, Jîyan, Azadî

Offline

#33 2019-03-17 15:42:43

Vectorlocity
Member
Registered: 2018-04-15
Posts: 132

Re: [SOLVED] Systemd errors

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 abstract

It is now running on waking up from suspend.

Offline

#34 2019-03-17 15:49:11

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,574

Re: [SOLVED] Systemd errors

The relevant environment here is $DBUS_SESSION_BUS_ADDRESS

Offline

#35 2019-03-17 15:57:54

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 9,003
Website

Re: [SOLVED] Systemd errors

Import the environment globally:

systemctl import-environment DBUS_SESSION_BUS_ADDRESS

Jin, Jîyan, Azadî

Offline

#36 2019-03-17 15:58:52

Vectorlocity
Member
Registered: 2018-04-15
Posts: 132

Re: [SOLVED] Systemd errors

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

#37 2019-03-17 16:14:59

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 9,003
Website

Re: [SOLVED] Systemd errors

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

#38 2019-03-17 17:45:22

Vectorlocity
Member
Registered: 2018-04-15
Posts: 132

Re: [SOLVED] Systemd errors

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.target

Executable 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 gb

Thanks for your help smile

Last edited by Vectorlocity (2019-03-17 17:45:38)

Offline

Board footer

Powered by FluxBB