You are not logged in.

#1 2017-07-01 18:22:08

roghnin
Member
Registered: 2017-06-17
Posts: 8

[SOLVED]Dealing with random DISPLAY environment in systemd service

Hi all,

I'm using a systemd service to enable i3lock after waking up from suspend. The file /etc/systemd/system/i3lock.service looks like:

[Unit]
Description=i3lock on suspend
Before=sleep.target

[Service]
User=hensen
Type=forking
Environment=DISPLAY=:1
ExecStart=/bin/lock

[Install]
WantedBy=sleep.target



However, the DISPLAY environment of the system is set to :0 or :1 randomly on startup, causing the service to fail sometimes. Can someone tell me what's going on here, and any solutions to this problem?


Thanks,

R

Last edited by roghnin (2017-07-02 05:09:25)

Offline

#2 2017-07-01 18:43:34

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,545
Website

Re: [SOLVED]Dealing with random DISPLAY environment in systemd service

First, this should be a user service.  Second, see the wiki.

(also please use [ code ] tags for commands/output/file-contents on the forums).


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2017-07-02 05:07:09

roghnin
Member
Registered: 2017-06-17
Posts: 8

Re: [SOLVED]Dealing with random DISPLAY environment in systemd service

Trilby wrote:

First, this should be a user service.  Second, see the wiki.

(also please use [ code ] tags for commands/output/file-contents on the forums).


Cool. Problem solved. Thanks, Trilby.

BTW, it's easy to forget removing "User=Somebody" when switching the service from system to user.

Offline

Board footer

Powered by FluxBB