You are not logged in.
I am trying to run the imwheel service on login or after calling startx but the service fails to start. It works when I use a display manager.
The output from "journalctl -xe | grep imwheel" is:
Jun 19 09:59:50 Arch imwheel[857]: INFO: imwheel is not running as a daemon.
Jun 19 09:59:50 Arch imwheel[857]: INFO: imwheel started (pid=857)
Jun 19 09:59:50 Arch imwheel[857]: Could not open display, check shell DISPLAY variable, and export or setenv it!
Jun 19 09:59:50 Arch systemd[802]: imwheel.service: Main process exited, code=exited, status=1/FAILURE
Jun 19 09:59:50 Arch systemd[802]: imwheel.service: Failed with result 'exit-code'.
Jun 19 09:59:51 Arch systemd[802]: imwheel.service: Scheduled restart job, restart counter is at 3.and the output from "systemctl --user status imwheel.service"
● imwheel.service - IMWheel
Loaded: loaded (/home/matt/.config/systemd/user/imwheel.service; enabled; vendor preset:$
Active: failed (Result: exit-code) since Fri 2020-06-19 13:43:15 EDT; 12min ago
Process: 821 ExecStart=/usr/bin/imwheel -d -b 45 (code=exited, status=1/FAILURE)
Main PID: 821 (code=exited, status=1/FAILURE)
Jun 19 13:43:14 Arch systemd[743]: Stopped IMWheel.
Jun 19 13:43:14 Arch systemd[743]: Started IMWheel.
Jun 19 13:43:14 Arch systemd[743]: ^[[0;1;39m^[[0;1;39mimwheel.service: Main process exited, $
Jun 19 13:43:14 Arch systemd[743]: ^[[0;1;38;5;185m^[[0;1;39m^[[0;1;38;5;185mimwheel.service:$
Jun 19 13:43:15 Arch systemd[743]: imwheel.service: Scheduled restart job, restart counter is$
Jun 19 13:43:15 Arch systemd[743]: Stopped IMWheel.
Jun 19 13:43:15 Arch systemd[743]: ^[[0;1;38;5;185m^[[0;1;39m^[[0;1;38;5;185mimwheel.service:$
Jun 19 13:43:15 Arch systemd[743]: ^[[0;1;38;5;185m^[[0;1;39m^[[0;1;38;5;185mimwheel.service:$
Jun 19 13:43:15 Arch systemd[743]: ^[[0;1;39mFailed to start IMWheel.and the ~/.config/systemd/user/imwheel.service is:
# Service file from Arch Wiki (mjd119 added -b 45 argument to enable front/back buttons)
# Restart on failure line added from https://bbs.archlinux.org/viewtopic.php?id=250540
[Unit]
Description=IMWheel
Wants=display-manager.service
After=display-manager.service
[Service]
Type=simple
Environment=XAUTHORITY=%h/.Xauthority
ExecStart=/usr/bin/imwheel -d -b 45
ExecStop=/usr/bin/pkill imwheel
RemainAfterExit=yes
Restart=on-failure
[Install]
WantedBy=default.targetLast edited by mjd119 (2020-06-19 20:17:46)
Offline
Jun 19 09:59:50 Arch imwheel[857]: Could not open display, check shell DISPLAY variable, and export or setenv it!And the reason for this was noted in a previous thread of yours:
https://bbs.archlinux.org/viewtopic.php … 9#p1910079
Follow the wiki page for xinit.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Jun 19 09:59:50 Arch imwheel[857]: Could not open display, check shell DISPLAY variable, and export or setenv it!And the reason for this was noted in a previous thread of yours:
https://bbs.archlinux.org/viewtopic.php … 9#p1910079Follow the wiki page for xinit.
I was looking at that page earlier and I am not trying start imwheel by calling "exec imwheel" in the xinitrc file. I am trying to run it as a systemd service. The wiki page you linked doesn't mention anything about that. I got the systemd service file from the imwheel wiki page. Since I'm not using a display manager, it appears that the Wants and After parameters should be changed but I'm not sure what they should be changed too. I'm having trouble finding resources that list other potential arguments. I've read through some of the systemd page on the wiki.
Last edited by mjd119 (2020-06-19 18:27:32)
Offline
You're not supposed to just look at the page, you're supposed to follow the instructions in it by copying the default xinitrc to edit, or at least include the bits highlighted in the box with the bold lettering "NOTE"
https://wiki.archlinux.org/index.php/Xinit#xinitrc
The absence of this section is why the DISPLAY variable is not define which in turn is why imwheel service is failing as clearly noted in the error message.
Last edited by Trilby (2020-06-19 18:32:44)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
The absence of this section is why the DISPLAY variable is not define
No, the DISPLAY variable is set automatically by the X server.
@OP: add this to your unit file in the [Service] section:
Environment=DISPLAY=:0Check that $DISPLAY is actually ":0" for your chosen desktop though, change the value in the unit file if it isn't.
Jin, Jîyan, Azadî
Offline
Trilby wrote:The absence of this section is why the DISPLAY variable is not define
No, the DISPLAY variable is set automatically by the X server.
@OP: add this to your unit file in the [Service] section:
Environment=DISPLAY=:0Check that $DISPLAY is actually ":0" for your chosen desktop though, change the value in the unit file if it isn't.
Should that always be added to service files? Redshift-gtk fails to start when I use startx too. I didn't create a custom redshift-gtk.service file (I can make a new thread if this is off-topic).
Offline
Should that always be added to service files?
Only for units starting programs that use X and need the variable to be set for them to work.
Redshift-gtk fails to start when I use startx too.
The unit file in the package from the [Community] repository has
After=display-manager.serviceSo that probably won't work if display-manager.service isn't finishing on your desktop.
Check the journal to see what's actually happening though.
I can make a new thread if this is off-topic
Yes, that would be best.
Jin, Jîyan, Azadî
Offline
Trilby wrote:The absence of this section is why the DISPLAY variable is not define
No, the DISPLAY variable is set automatically by the X server.
Environment variables are not global variables. Explicity setting the DISPLAY variable in the service file is wrong. It will completely fail anytime your random guess at what the DISPLAY variable is supposed to be is wrong.
If you follow the wiki guidance on setting up xinitrc, it imports the current DISPLAY variable into the system user session so it is available to services.
Should that always be added to service files?
No, it shouldn't be added to any of them. Just fix your xinitrc as advised multiple times now and your user services will have access to the correct values for DISPLAY and XAUTHORITY.
Last edited by Trilby (2020-06-19 19:39:27)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Actually Trilby we're both wrong ![]()
I've been checking and the service will restart just fine even without /etc/X11/xinit/xinitrc.d/50-systemd-user.sh being sourced from ~/.xinitrc and it still fails to start even with that file sourced correctly from ~/.xinitrc — the DISPLAY warning is a red herring.
The real problem here is the After= & Wants= lines because display-manager.service isn't running if startx is used, not sure why the OP has marked this [SOLVED] because my (erroneous) suggestion doesn't fix things at all.
The correct solution is to add the imwheel command to ~/.xinitrc
EDIT: clarification.
Last edited by Head_on_a_Stick (2020-06-19 22:06:31)
Jin, Jîyan, Azadî
Offline
HoaS, I don't know much about the After= and Wants= as I've seen too much non-deterministic behavior from them. But doesn't the first post clearly demonstrate that the service is starting and failing? If the problem were that the After= and/or Wants= was preventing the service from starting, those messages would not be in the journal - certainly not one mentioning the absence of the DISPLAY variable (as this comes from the binary that the service file launches not from systemd).
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
I think the unit is attempting to start before X is running (hence the DISPLAY error in the journal) rather than being prevented from starting.
Jin, Jîyan, Azadî
Offline
That doesn't add up: if the Wants= and After= criteria were relevant, it wouldn't even try to start.
As it's trying to start, the Wants= and After= are not the issue. The lack of the DISPLAY variable is.
I've never seen problems with autostarting X from a shell profile being too slow for user services requiring X to be running - but I suppose the OP is not autostarting X from what I can gather. If this is the case, then a user service is just completely the wrong way to start this program.
mjd119, do you plan on setting X to autostart, or are you going to log in and manually run startx when you want X running?
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline