You are not logged in.
I have a service file like this:
[Unit]
Description=xkeysnail
[Service]
# DISPLAY 的值应该和 `echo $DISPLAY` 的值相同
Environment=DISPLAY=:0
ExecStartPre=xhost +SI:localuser:root
ExecStart=/usr/bin/xkeysnail -q --watch /home/zw963/utils/xkeysnail/config.py
Type=simple
Restart=always
RestartSec=2
[Install]
WantedBy=graphical.target
but it not work, because get error like this:
Xlib.error.DisplayConnectionError: Can't connect to display ":0": b'Authorization required, but no authorization protocol specified\n'
The workaround is, i have to add above xhost code into .bashrc.
# .bashrc
xhost +SI:localuser:root
no,the service file start to works now.
Thank you.
Offline
You omitted to say if the service is a system or user service. I will assume the latter. Tools to diagnose the problem include `systemctl` and `journalctl`.
You could write a script that does two things: call xhost and launch xkeysnail. Then invoke the script in your user service.
Offline
You omitted to say if the service is a system or user service. I will assume the latter. Tools to diagnose the problem include `systemctl` and `journalctl`.
this is a system service. as i said, the failing message in journal is:
Authorization required, but no authorization protocol specified
I guess root can't access X cause this.
You could write a script that does two things: call xhost and launch xkeysnail. Then invoke the script in your user service.
Yes, i guess it will works, but anyway, i want to know why this same services can work on others arch, but not works for me.
BTW: i use GNOME 40 + Wayland.
EDIT:
in fact, add xhost code into shell script not work. i guess those xhost command should be run on current user instead of root.
Last edited by zw963 (2021-06-05 11:31:52)
Offline