<html><head></head><body><div style=""><div><span style="font-size:
13px;"><font face="monospace">Hello,</font></span></div><div><span
style="font-size: 13px;"><font face="monospace">I have my computer hooked
up to an AVR that runs my home cinema and ideally I would like the computer
to turn off the AVR when I turn it off or suspend it. The only way to do
this is over network and I wrote a simple script that does just that.
Hooking it to shutdown was quite easy using network.target that is defined
when shutting down. </font></span></div><div><span style="font-size:
13px;"><font face="monospace"><br></font></span></div><div><span
style="font-size: 13px;"><font face="monospace">I am struggling to make it
work with suspend though. When I look at the logs, terminating network
seems to be the first thing that happens when suspend is invoked. I tried
putting the script to /usr/lib/systemd/system-sleep/ and it runs, but only
after network si down, so it fails. Running the script with systemd-inhibit
(E</font></span><span style="color: rgb(0, 0, 0); font-family: monospace;
background-color: var(--colorBgIntense);">xecStart=/usr/bin/systemd-inhibit
--what=sleep my_script) tells me that "</span><span style="color: rgb(0, 0,
0); font-family: monospace; background-color:
var(--colorBgIntense);">Failed to inhibit: The operation inhibition has
been requested for is already running".</span></div><div><span
style="color: rgb(0, 0, 0); font-family: monospace; background-color:
var(--colorBgIntense);"><br></span></div><div><span style="color: rgb(0, 0,
0); font-family: monospace; background-color: var(--colorBgIntense);">Is
there a way to make this work with service files by specifying that the
script needs to be run before network is shut down or would I need to run a
daemon listening for </span><span style="background-color:
var(--colorBgIntense); font-size: 13px;"><font face="monospace"
color="#000000">PrepareForSleep as here: </font></span><span
style="background-color: var(--colorBgIntense); font-size: 13px;"><font
face="monospace"
color="#000000">https://github.com/davidn/av/blob/master/av </font></span><span
style="color: rgb(0, 0, 0); font-family: monospace; background-color:
var(--colorBgIntense); font-size: 13px;">?</span></div><div><span
style="background-color: var(--colorBgIntense); font-size: 13px;"><font
face="monospace" color="#000000"><br></font></span></div><div><span
style="background-color: var(--colorBgIntense); font-size: 13px;"><font
face="monospace" color="#000000">Kind
regards,</font></span></div><div><font face="monospace"
color="#000000"><span style="font-size:
13px;">Tomas</span></font></div><div style="font-family: monospace;">
<br></div></div></body></html>