You are not logged in.

#1 2015-07-22 09:20:41

lardon
Member
Registered: 2008-05-31
Posts: 264
Website

[solved] Running a user systemd service after the desktop becomes

I want to set my nvidia driver's setting on performance. Unfortunately, there doesn't seem to be a permanent config setting for that, so I made a user systemd unit:

[Unit]
Description=Force nvidia settings to performance

[Service]
Type=oneshot
ExecStart=/usr/bin/nvidia-settings -a [gpu:0]/GpuPowerMizerMode=1
Environment=DISPLAY=:1

[Install]
WantedBy=default.target

Unfortunately, this fails most of the time because it is run before the display becomes available (I use GNOME with gdm). Is there a way to tell systemd to run the job after this display becomes available?

Last edited by lardon (2015-09-01 10:04:22)


Autojump, the fastest way to navigate your filesystem from the command line!

Offline

#2 2015-07-22 09:52:01

Chazza
Wiki Maintainer
Registered: 2013-06-02
Posts: 506

Re: [solved] Running a user systemd service after the desktop becomes

Perhaps, under [Unit] you want something like

After=graphical.target

Offline

#3 2015-07-22 09:53:05

lardon
Member
Registered: 2008-05-31
Posts: 264
Website

Re: [solved] Running a user systemd service after the desktop becomes

Chazza wrote:

Perhaps, under [Unit] you want something like

After=graphical.target

I thought about that, but I believe graphical.target refers to gdm and not the final desktop session. Anyways, I'll have to try and report back.


Autojump, the fastest way to navigate your filesystem from the command line!

Offline

#4 2015-07-22 10:08:37

Chazza
Wiki Maintainer
Registered: 2013-06-02
Posts: 506

Re: [solved] Running a user systemd service after the desktop becomes

Well if it doesn't, here's a rather hacky solution that occurred to me:

ExecStart=until [ $(pgrep -f gnome-session) ]; do sleep 1; done && /usr/bin/nvidia-settings -a [gpu:0]/GpuPowerMizerMode=1

Edit: by the way, have you considered using GNOME's autostart facility instead of a systemd service? https://wiki.archlinux.org/index.php/GN … plications
Edit2: whoops! Added missed semi-colon after square bracket.

Last edited by Chazza (2015-07-22 10:18:37)

Offline

#5 2015-09-01 10:03:39

lardon
Member
Registered: 2008-05-31
Posts: 264
Website

Re: [solved] Running a user systemd service after the desktop becomes

I can confirm "After=graphical.target" does not work per se. So I went with your last solution, but I had to tweak it a little bit more to get it to work. Here's my working solution:

[Unit]
Description=Force nvidia settings to performance
After=graphical.target

[Service]
Type=simple
ExecStart=/usr/bin/bash -c 'until /usr/bin/nvidia-settings -a [gpu:0]/GpuPowerMizerMode=1; do echo "waiting for desktop..."; sleep 1; done'
Environment=DISPLAY=:1

[Install]
WantedBy=default.target

Autojump, the fastest way to navigate your filesystem from the command line!

Offline

Board footer

Powered by FluxBB