You are not logged in.

#1 2022-09-28 22:51:41

ndttt
Member
Registered: 2017-03-19
Posts: 38

[SOLVED] Running systemd prior to suspending

I wrote a systemd configuration that I want to run prior to suspend to turn off lighting in my system.

[Unit]
Description=Set OpenRGB Lighting with Off Profile
Before=suspend.target

[Service]
User=nn
Type=oneshot
ExecStart=/usr/bin/openrgb -p off.orp
TimeoutSec=0

[Install]
WantedBy=suspend.target

I can manually run it - systemctl start openrgb_off.service and it'll turn off the lighting, but when suspending my system, the lighting does not go off.

Oddly, when I do resume from suspend, the lighting will turn off leading me to believe it's actually running after resuming.

Last edited by ndttt (2022-09-30 04:53:15)

Offline

#2 2022-09-29 06:11:20

mpan
Member
Registered: 2012-08-01
Posts: 1,200
Website

Re: [SOLVED] Running systemd prior to suspending

I am not using OpenRGB, but upon having a look it seems it’s running as a daemon+client. Which would mean your invocation of “/usr/bin/openrgb” merely sends a request to the daemon and instantly returns without waiting for the daemon to actually apply changes.


Sometimes I seem a bit harsh — don’t get offended too easily!

Offline

#3 2022-09-29 13:54:04

ndttt
Member
Registered: 2017-03-19
Posts: 38

Re: [SOLVED] Running systemd prior to suspending

mpan wrote:

I am not using OpenRGB, but upon having a look it seems it’s running as a daemon+client. Which would mean your invocation of “/usr/bin/openrgb” merely sends a request to the daemon and instantly returns without waiting for the daemon to actually apply changes.

So because it sends a request to the daemon and doesn't actually wait for it to finish (when I run it manually, it isn't instantaneous, I do notice it takes a few seconds to actually turn off the RGB.) but the system suspends before it can complete?

Would there be a way to ensure the request can be completed prior to suspending ?

Offline

#4 2022-09-29 14:13:54

seth
Member
Registered: 2012-09-03
Posts: 50,927

Re: [SOLVED] Running systemd prior to suspending

"ensure" not, unless openrgb has a synchronous mode (ie wait for response from the daemon) but you coud "ExecStartPost=sleep 3" to have the service wait 3 seconds.

Offline

#5 2022-09-29 14:52:30

mpan
Member
Registered: 2012-08-01
Posts: 1,200
Website

Re: [SOLVED] Running systemd prior to suspending

ndttt wrote:

but the system suspends before it can complete?

This is my hypothesis.


Sometimes I seem a bit harsh — don’t get offended too easily!

Offline

#6 2022-09-29 23:02:08

ndttt
Member
Registered: 2017-03-19
Posts: 38

Re: [SOLVED] Running systemd prior to suspending

seth wrote:

"ensure" not, unless openrgb has a synchronous mode (ie wait for response from the daemon) but you coud "ExecStartPost=sleep 3" to have the service wait 3 seconds.

This did the trick!

My system reliably shuts down the lights when suspending, thanks !

mpan wrote:

This is my hypothesis.

Looks like you were right. I appreciate the help, it led me to the solution!

Offline

#7 2022-09-30 06:02:12

seth
Member
Registered: 2012-09-03
Posts: 50,927

Re: [SOLVED] Running systemd prior to suspending

You can probably shorten the timeout, 1 second might be enough (sleep also does miliseconds, but the lower you got the less reliable it becomes)

Offline

Board footer

Powered by FluxBB