cdown / clipmenu

Clipboard management using dmenu
MIT License
1.14k stars 91 forks source link

Clipmenu doesn't function correctly when started using systemd service #141

Closed m4rc3iro closed 4 years ago

m4rc3iro commented 4 years ago

OS: Arch Clipmenu 6.1.0

Clipmenu doesn't seem to work correctly when started using systemctl --user enable clipmenud. After restarting, clipmenud seems to be running (+clipnotify as well), however clipmenu is not able to copy any text.

systemctl_clipmenud_status

cdown commented 4 years ago

Can you please try to reproduce with 6.2.0? There are a number of changes in there.

Other than that, can you please run with CM_DEBUG=1, and report the output of journalctl -u clipmenud for that session? :-)

Also, does clipnotify change PID?

m4rc3iro commented 4 years ago

Hi, unfortunately still doesn't work in 6.2.0. These are the journal logs details from one of the last sessions when I tried to make things work:

... Okt 11 21:46:11 manjaro clipmenud[23277]: Can't open X display Okt 11 21:46:11 manjaro clipmenud[23281]: xsel: Can't open display: (null) Okt 11 21:46:11 manjaro clipmenud[23281]: : Inappropriate ioctl for device Okt 11 21:46:11 manjaro clipmenud[23284]: xsel: Can't open display: (null) Okt 11 21:46:11 manjaro clipmenud[23284]: : Inappropriate ioctl for device Okt 11 21:46:11 manjaro clipmenud[23286]: Can't open X display Okt 11 21:46:11 manjaro clipmenud[23290]: xsel: Can't open display: (null) Okt 11 21:46:11 manjaro clipmenud[23290]: : Inappropriate ioctl for device Okt 11 21:46:11 manjaro clipmenud[23293]: xsel: Can't open display: (null) Okt 11 21:46:11 manjaro clipmenud[23293]: : Inappropriate ioctl for device ...

cdown commented 4 years ago

What's your current $DISPLAY in your X session? Is it the same as in /proc/23293/environ?

SeniorMars commented 4 years ago

Hey, I also have a similar issue: OS: arch Verison of package: 6.2.0.1 image

and when I try to run $ clipmenu I get this error: image

I downgraded to 6.1.0.2 and everything works. No journal logs since the service doesn't start.

cdown commented 4 years ago

Are you sure your $DISPLAY is set correctly with systemctl --user import-environment DISPLAY or similar? We used to hardcode :0 as the display name, but now it's expected to come from the environment (since we can't know it ahead of time).

Exit code 2 means DISPLAY is unset.

SeniorMars commented 4 years ago

So I checked to see if that was the problem and this is what I got: image My display is set.

cdown commented 4 years ago

That's way too late to import, you need to do it prior to starting clipmenud. Exit code 2 literally means "$DISPLAY is unset", just because it's set in your terminal, doesn't mean it's being set by systemd :-)

drot commented 4 years ago

If this issue is about startx, at least on Arch the /etc/X11/xinit/xinitrc file by default loads the /etc/X11/xinit/xinitrc.d/50-systemd-user.sh drop-in which already does the job of importing the environment:

#!/bin/sh

systemctl --user import-environment DISPLAY XAUTHORITY

if command -v dbus-update-activation-environment >/dev/null 2>&1; then
    dbus-update-activation-environment DISPLAY XAUTHORITY

The issue here is simply using startx and enabling the clipmenud service won't quite work since naturally the service gets started before it has a chance to "see" any DISPLAY, thus to solve the problem (rather naively) I simply start the unit manually in my .xinitrc without enabling it.

cdown commented 4 years ago

Closing this since, judging by the thumbs up, that explains what's going on. The X server must be started before clipmenud so that systemd knows the $DISPLAY to be pushed into the environment.