Open dsalt opened 3 years ago
I don't think that using systemd is the correct way to run devilspie2, the main issue being that it should run when you login to your window manager which is not a systemd target. It should have a seperate instance for each session. The corresponding WM's application autostart is the place that make sense to start it with.
Disclaimer: I don't know much systemd
Could extend this feature request to be more implementation-agnostic - "run devilspie2 automatically", to consider other solutions like the autostart suggestion.
@Longoon12000 I would think this has got to be a common enough condition for there to be a wm-agnostic set of unit constraints in systemd: "user has logged into an X session". It doesn't have to be just a single systemd .target
that expresses this. Also, in your link:
this example seems to be installed as a root entry (/etc/systemd/system/
), not a user entry, per the original request (systemctl --user
). I think that changes things. From the README, it sounds like devilspie2 is intended to be run per-user:
If you don't give devilspie2 any folder with --folder, it will read Lua scripts from the folder that it gets from the GLib function g_get_user_config_dir with devilspie2/ added to the end.
So what about a user service After=graphical.target
installed to /etc/systemd/user
?
That said, I did this:
$HOME/.local/systemd/user/devilspie2.service
[Service]
Type=simple
ExecStart=/usr/local/bin/devilspie2 --debug
Restart=on-failure
[Install]
WantedBy=gnome-session-x11-services.target
I could play around with a more generic solution.
I'm using this:
[Unit]
Description=devilspie2 window wrangler
StartLimitIntervalSec=0
[Service]
Type=exec
Environment=DISPLAY=:0
Environment=XDG_RUNTIME_DIR=/run/user/%U
ExecStart=/usr/bin/devilspie2 --debug
Restart=always
RestartSec=5
StandardOutput=append:%h/.config/devilspie2/debug
StandardError=append:%h/.config/devilspie2/errors
installed in /etc/systemd/user
and it seems to be working OK.
I start it as:
/usr/bin/systemctl --user start devilspie2.service
in .xsessionrc at the moment. I have a few widgets that have an After=devilspie2.service so startup order can be ensured without race conditions.
A few outstanding problems that prevent this from being upstreamed:
But perhapss this could get some folks going without a perfect service file.
This is on:
ii systemd 252.6-1 arm64 system and service manager
ii devilspie2 0.43-5 arm64 Lua-based window matching utility
Without the environment variables I get:
(devilspie2:75947): Gdk-WARNING **: 18:19:43.485: cannot open display:
Valid point re. desktop/wm autostart (so, presumably, XDG autostart). I've just pushed a commit which should allow for that.
https://bugs.debian.org/933866
Being a Devuan user, I don't use systemd myself, so I'm in no position to add this. (I currently use Xfce4's application autostart to run devilspie2 on login.)