Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

systemd user service file #2

Open
dsalt opened this issue Sep 5, 2021 · 4 comments
Open

systemd user service file #2

dsalt opened this issue Sep 5, 2021 · 4 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@dsalt
Copy link
Owner

dsalt commented Sep 5, 2021

https://bugs.debian.org/933866

It would be wonderful to have Debian ship a systemd user service file for
devilspie2. I've searched the internet a bit and know a bit about systemd, but
don't know the exact configurations for said service file. My current attempts
are failing. If I get it to work, I'll follow-up to this bug report.

It'd be great to be able to:

systemctl --user enable devilspie2
systemctl --user start devilspie2

and have it work out of the box.

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.)

@dsalt dsalt added enhancement New feature or request help wanted Extra attention is needed labels Sep 5, 2021
@RainOrigami
Copy link

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.

https://unix.stackexchange.com/a/360685

@keypresser1
Copy link

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:

https://unix.stackexchange.com/a/360685

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:

  • for gnome
  • as the only person using the machine
  • never accessing remotely e.g. ssh

$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.

@bill-mcgonigle
Copy link

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:

  • Why is it necessary to set DISPLAY and XDG_RUNTIME_DIR under systemd? Maybe starting it under the wm autostart script would fix that?
  • systemd's %t variable doesn't seem to work for XDG_RUNTIME_DIR but docs seem like it should.
  • hardcoding the DISPLAY is bogus. Maybe @%i semantics would work?
  • putting logs into the config dir is bogus, but systemd won't make parent directories (~/.local/share/devilspie2 should be preferred?).
  • Maybe stderr should go into the journal instead of a file.
  • None of systemd's extensive security features are being used. Ideally every feasible restriction would be added.

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: 

@dsalt
Copy link
Owner Author

dsalt commented May 21, 2023

Valid point re. desktop/wm autostart (so, presumably, XDG autostart). I've just pushed a commit which should allow for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants