You are not logged in.

#1 2015-01-08 23:50:07

Untribium
Member
Registered: 2015-01-07
Posts: 10

Starting devilspie with systemd

Hi everyone,

First of all, I'm not sure if this is the right section, since it's mostly a systemd problem, so feel free to move the topic smile

I'm trying to autostart some applications (mostly the terminal) and I want it maximized on workspace 4 so I use devilspie to do that. I'm (mostly) running Gnome 3, so I previously used its autostarting capabilities, but I'd really like to move to systemd as it seems a bit cleaner to me. I also don't really care whether the setting is per user or system-wide.

So in order to get this to work I wrote two service files at /etc/systemd/system/ as suggested in the wiki article

[Unit]
Description=Devil's Pie
Before=startup.service

[Service]
Type=oneshot
TimeoutStartSec=0

Environment=DISPLAY=:0

ExecStart=/usr/bin/devilspie

[Install]
WantedBy=multi-user.target
[Unit]
Description=startup
After=devilspie.service
Requires=devilspie.service

[Service]
Type=oneshot
TimeoutStartSec=0

ExecStart=/usr/bin/gnome-terminal
ExecStart=/usr/bin/chromium

[Install]
WantedBy=multi-user.target

and enabled them. However, the devilspie service fails with

Jan 09 00:24:11 origami devilspie[12171]: (devilspie:12171): Gdk-WARNING **: cannot open display:
Jan 09 00:24:11 origami systemd[1]: devilspie.service: main process exited, code=exited, status=1/FAILURE
Jan 09 00:24:11 origami systemd[1]: Failed to start Devil's Pie.

which, I think, is due to environment variables (specifically DISPLAY) not being set. Therefore I manually added the Environment parameter as described here, with no effect. I also tried using systemd/User but again was unable to get it to work.

What am I doing wrong here? Any help is much appreciated! smile

Offline

#2 2015-01-13 00:18:13

\hbar
Member
Registered: 2014-03-15
Posts: 165

Re: Starting devilspie with systemd

It seems that the unit is being run before X starts. In fact shouldn't the target be graphical.target ? Perhaps you also need to specify an "After" entry for the devilspie unit.

Offline

#3 2015-01-13 00:31:59

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,525
Website

Re: Starting devilspie with systemd

In addition to the above, you'll likely need to specify "User=".  You don't need to set up the systemd user session described in the wiki you linked to, but you do need to run the program as your regular user - if not specified, systemd runs those Exec lines as root.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#4 2015-01-14 13:34:45

Untribium
Member
Registered: 2015-01-07
Posts: 10

Re: Starting devilspie with systemd

Thanks for the replies! I don't have access to my PC right now, but I'll be back home in a few days and will report my findings then smile

Trilby wrote:

[...] if not specified, systemd runs those Exec lines as root.

The thing is, running devilspie as root from the terminal (using su) works, which is essentially the same, right? So that might not be the issue (though running it as user would be preferable). I'll test it though, just to be sure smile

Offline

#5 2015-01-14 14:55:01

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,525
Website

Re: Starting devilspie with systemd

If it works as root, then that is indeed not the cause of the problem, but there may be functionality lost if devilspie is not running as the same user as the programs you want to manipulate with it.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#6 2015-01-16 01:15:47

Untribium
Member
Registered: 2015-01-07
Posts: 10

Re: Starting devilspie with systemd

Okay, back home...

\hbar wrote:

It seems that the unit is being run before X starts. In fact shouldn't the target be graphical.target ? Perhaps you also need to specify an "After" entry for the devilspie unit.

That makes a ton of sense! So I changed my .service to this:

[Unit]
Description=Devil's Pie
After=graphical.target
Before=startup.service

[Service]
TimeoutStartSec=0
Type=oneshot
User=gray

ExecStart=/usr/bin/devilspie

[Install]
WantedBy=graphical.target

Checking the systemd-analyze plot, devilspie is now started after graphical.target but, alas, still the same error:

$ journalctl -xe | grep devilspie
Jan 15 23:20:16 origami devilspie[374]: (devilspie:374): Gdk-WARNING **: cannot open display:
Jan 15 23:20:16 origami systemd[1]: devilspie.service: main process exited, code=exited, status=1/FAILURE
-- Subject: Unit devilspie.service has failed
-- Unit devilspie.service has failed.
Jan 15 23:20:16 origami systemd[1]: Unit devilspie.service entered failed state.
Jan 15 23:20:16 origami systemd[1]: devilspie.service failed.

Any ideas?... I guess I'll just use gnome for now, but I'll happily try out any suggestion smile

Offline

#7 2016-05-06 13:37:06

seva
Member
Registered: 2016-05-06
Posts: 3
Website

Re: Starting devilspie with systemd

This will do it:

mkdir -p ~/.config/systemd/user/
echo "[Unit]
Description=Devilspie

[Service]
ExecStart=/usr/bin/devilspie

[Install]
WantedBy=default.target" > ~/.config/systemd/user/devilspie.service
systemctl --user enable devilspie
systemctl --user start devilspie

Offline

Board footer

Powered by FluxBB