nosuspend - avoid computer suspend as long a app is running

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

nosuspend - avoid computer suspend as long a app is running

Hermann Meyer
Hi

After some discussions with @wolftune, I wrote a little app to allow
users to avoid temporary computer suspend on systemd based systems.

nosuspend allows users to avoid suspend or shutdown even on privileged
level (e.g. root) when a running user process shouldn't be interrupted.
for example capture a session.
To accomplish this, nosuspend sets the systemd-inhibit flag with UID
0/root in order to block computer suspend while another command-line
operation is running.
Permissions therefore are granted in a PolKit policy rule file which
comes with nosuspend.
nosuspend comes in 2. fashions, e.g. with 2 different Polkit files.

1.) default is the security mode, which requires you to enter the root
password in order to run nosuspend.

2.) is the relaxed mode, which allow you to run nosuspend without
password. To get this mode, you must build nosuspend with|
|

|make relaxed|

||
Sure, you could switch of suspend at all, but maybe that's not what you
wont. So nosuspend may be the tool for you.
To use nosuspend, simply run before another command as in:

|nosuspend appname -parameter for appname|

For easy command substitution full bash completion support is provided.

here you go:
https://github.com/brummer10/nosuspend

regards
hermann

_______________________________________________
Linux-audio-user mailing list
[hidden email]
http://lists.linuxaudio.org/listinfo/linux-audio-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: nosuspend - avoid computer suspend as long a app is running

Ralf Mardorf
On Sat, 1 Jul 2017 09:22:05 +0200, Hermann Meyer wrote:
>Sure, you could switch of suspend at all, but maybe that's not what
>you wont.

Or you simply edit the polkit rules, as I did for power-off and reboot,
by just using the "org.freedesktop.login1.suspend" lines instead of the
org.freedesktop.login1.power-off and org.freedesktop.login1.reboot
lines.

[root@archlinux rocketmouse]# cat /etc/polkit-1/rules.d/10-admin-shutdown-reboot.rules
polkit.addRule(function(action, subject) {
    if (action.id == "org.freedesktop.login1.power-off" ||
        action.id == "org.freedesktop.login1.power-off-ignore-inhibit" ||
        action.id == "org.freedesktop.login1.power-off-multiple-sessions" ||
        action.id == "org.freedesktop.login1.reboot" ||
        action.id == "org.freedesktop.login1.reboot-ignore-inhibit" ||
        action.id == "org.freedesktop.login1.reboot-multiple-sessions"
    ) {
        return polkit.Result.AUTH_SELF_KEEP;
    }
});

Regards,
Ralf

--
Vote for apulse!
echo $(w3m https://aur.archlinux.org/packages/apulse |grep 'Votes:    ')
Votes: 81                         Updated: Sat Jul  1 10:30:07 CEST 2017
_______________________________________________
Linux-audio-user mailing list
[hidden email]
http://lists.linuxaudio.org/listinfo/linux-audio-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: nosuspend - avoid computer suspend as long a app is running

Ralf Mardorf
In reply to this post by Hermann Meyer
On Sat, 1 Jul 2017 09:22:05 +0200, Hermann Meyer wrote:
>nosuspend allows users to avoid suspend or shutdown even on privileged
>level (e.g. root)

Pardon, I missed that. What is it good for? The polkit rules I posted
allow to do an action with root privileges only. I guess an admin knows
what she's doing.

--
Vote for apulse!
echo $(w3m https://aur.archlinux.org/packages/apulse |grep 'Votes:    ')
Votes: 81                         Updated: Sat Jul  1 10:35:11 CEST 2017
_______________________________________________
Linux-audio-user mailing list
[hidden email]
http://lists.linuxaudio.org/listinfo/linux-audio-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: nosuspend - avoid computer suspend as long a app is running

Hermann Meyer


Am 01.07.2017 um 10:35 schrieb Ralf Mardorf:
> On Sat, 1 Jul 2017 09:22:05 +0200, Hermann Meyer wrote:
>> nosuspend allows users to avoid suspend or shutdown even on privileged
>> level (e.g. root)
> Pardon, I missed that. What is it good for? The polkit rules I posted
> allow to do an action with root privileges only. I guess an admin knows
> what she's doing.
>

My system goes into suspend after 10 min idle. That's how I've set it
up, and that is what I wont, usually.
Sometimes, I don't wont that, . .
The system suspend signal comes with a higher priority then the users
inhibitor, hence, running systemd-inhibit as user will simply be ignored
when it comes to the automatic setted systemd suspend.
Setting the inhibitor with 0/root flag avoid that.
_______________________________________________
Linux-audio-user mailing list
[hidden email]
http://lists.linuxaudio.org/listinfo/linux-audio-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: nosuspend - avoid computer suspend as long a app is running

Ralf Mardorf
On Sat, 1 Jul 2017 10:53:37 +0200, Hermann Meyer wrote:

>Am 01.07.2017 um 10:35 schrieb Ralf Mardorf:
>> On Sat, 1 Jul 2017 09:22:05 +0200, Hermann Meyer wrote:  
>>> nosuspend allows users to avoid suspend or shutdown even on
>>> privileged level (e.g. root)  
>> Pardon, I missed that. What is it good for? The polkit rules I posted
>> allow to do an action with root privileges only. I guess an admin
>> knows what she's doing.
>>  
>
>My system goes into suspend after 10 min idle. That's how I've set it
>up, and that is what I wont, usually.
>Sometimes, I don't wont that, . .
>The system suspend signal comes with a higher priority then the users
>inhibitor, hence, running systemd-inhibit as user will simply be
>ignored when it comes to the automatic setted systemd suspend.
>Setting the inhibitor with 0/root flag avoid that.

Thanks for the clarification.

--
Vote for apulse!
echo $(w3m https://aur.archlinux.org/packages/apulse |grep 'Votes:    ')
Votes: 81                         Updated: Sat Jul  1 13:02:21 CEST 2017
_______________________________________________
Linux-audio-user mailing list
[hidden email]
http://lists.linuxaudio.org/listinfo/linux-audio-user
Loading...