<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Nov 2, 2015 at 3:34 PM, Richard Maw <span dir="ltr"><<a href="mailto:richard.maw@codethink.co.uk" target="_blank">richard.maw@codethink.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class="">On Mon, Nov 02, 2015 at 09:04:31AM +0100, Lennart Poettering wrote:<br>
> On Wed, 28.10.15 19:30, John (<a href="mailto:da_audiophile@yahoo.com">da_audiophile@yahoo.com</a>) wrote:<br>
><br>
> > I have a simple bash script that I would like to have a user service<br>
> > file run with an argument when the system enters a sleep or<br>
> > hibernation state but as I understand it, user service units do not<br>
> > use the sleep.target. The goal is to have the following run before<br>
> > the system goes into sleep/hibernate triggered by whatever mechanism<br>
> > systemd uses to detect when the user sleeps or hibernates the<br>
> > system: '/usr/bin/psd sync'<br>
><br>
> You can install a suspend delay inhibitor:<br>
><br>
> <a href="https://wiki.freedesktop.org/www/Software/systemd/inhibit/" rel="noreferrer" target="_blank">https://wiki.freedesktop.org/www/Software/systemd/inhibit/</a><br>
><br>
> That works from privileged code the same as for user code. However,<br>
> you cannot really do that from shell code. I fear for shell this is<br>
> simply not available, sorry.<br>
<br>
</span>You may be able to abuse the hell out of systemd-inhibit to have it work:<br>
<br>
#!/bin/sh<br>
# Approach cribbed from <a href="http://www.opopop.net/Harnessing_DBus/" rel="noreferrer" target="_blank">http://www.opopop.net/Harnessing_DBus/</a></blockquote><div><br></div><div>Might as well use ctypes.sh then... Or a more capable language:<br></div><div><br></div><div><a href="https://gist.github.com/grawity/a10ee46d7ff58048d483">https://gist.github.com/grawity/a10ee46d7ff58048d483</a><br></div></div><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">Mantas Mikulėnas <<a href="mailto:grawity@gmail.com" target="_blank">grawity@gmail.com</a>></div></div>
</div></div>