You are not logged in.

#1 2024-09-05 03:54:57

arbitarycounterfactual
Member
Registered: 2024-07-17
Posts: 6

[Solved] program doesn't update X root window when run as systemd.unit

It is a program written in C that updates X root window (which is the status bar in DWM). It uses libxcb and libxcb-util (mainly, xcb_change_property() to write characters in the root window). Being run as an event loop.

I usually just leave it running in the background by typing into the shell  each time I log in, like so...

sys-status 1>/dev/null 2>~/.local/sys-status/log & 

I need systemd to take care of it. I copied a minimal boilerplate systemd.service file in /usr/lib/systemd/user.

[Unit]
Description=status bar for DWM

[Service]
ExecStart=sys-status 1>/dev/null 
Type=simple
Restart=on-failure 
RestartSec=1s

[Install]
WantedBy=default.target

starting this service does not have any effect, it does not change the status bar.

Please let me know if you need any more information.

Last edited by arbitarycounterfactual (2024-09-09 15:46:53)

Offline

#2 2024-09-05 06:53:32

seth
Member
Registered: 2012-09-03
Posts: 56,292

Re: [Solved] program doesn't update X root window when run as systemd.unit

The user service likely lacks the $DISPLAY environment? Have you checked it's status?

Offline

#3 2024-09-05 07:16:18

arbitarycounterfactual
Member
Registered: 2024-07-17
Posts: 6

Re: [Solved] program doesn't update X root window when run as systemd.unit

seth wrote:

The user service likely lacks the $DISPLAY environment?

Oh well, right! Completely forgot systemd execution doesn't look at system envvars, and dealing with X server requires knowing them. Added these two definitions

Environment="DISPLAY=:0"
Environment="XAUTHORITY="/home/aissy/.Xauthority""

 
It works now. Thanks for the reminder! smile

By the way, I would have it better if systemd envvars could be automatically set to already-set system envvars (maybe somewhat like an import into systemd environment)?

Offline

#4 2024-09-05 07:25:19

seth
Member
Registered: 2012-09-03
Posts: 56,292

Re: [Solved] program doesn't update X root window when run as systemd.unit

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.

A fundamental problem is that the service might even start before any X11 server and your session isn't tied to a specific one either.
I'd typically rather start such daemons w/ the relevant X11 session (xinitrc or from dwm) than as a user service.

Offline

Board footer

Powered by FluxBB