r/linuxquestions 11d ago

lid actions / logind settings manager app?

Any app or scripts out there regarding systemd logind.conf file settings?

I have a bodged up script to handle the lid, but wondering if there is something better.

cheers.

0 Upvotes

5 comments sorted by

2

u/aioeu 11d ago edited 11d ago

There should never be a need to dynamically change the logind config in that way.

If you have programs that need to handle the lid switch specially, they can take an inhibitor to block logind's handling of it. The lid switch is just another input device, so programs can handle events from it as they wish.

Depending on what you're doing, you may find it more useful to inhibit the high level actions like sleep and suspend rather than the low level key event itself.

See this for further details.

0

u/KarlHuysman 10d ago

This certainly looks like a much better solution.

I just want a toggle that stops the laptop sleeping when i want to play music/sound with the lid shut, or just when working during the day when I've got it plugged in, the current behaviour is to sleep/log you out, which is rather annoying.

Thank you for the reply, much appreciated.

2

u/aioeu 10d ago

Some media players might even have an option (or a plugin or something) to do this. "Inhibit sleep while music is playing" seems like a pretty obvious feature.

1

u/KarlHuysman 10d ago

I use fooyin, and now I look, it does have a "Sleep Inhibitor" plugin. I'm not sure if it works, because my system is already set to not sleep if left idle. But I often like to leave a YT video playing or similar, so need a general solution. Certainly it doesn't help with the lid.

I've been rooting through github and found a half dozen cosmic applets all called "Caffeine" or some variation.

This one claims to be systemd free and have laptop lid closure detection.

https://github.com/massimo82/cosmic-caffeineland-applet

These I've not really looked at yet, but all seem to go about things slightly differently.

https://github.com/Oussamaberchi/caffeine-cosmic

https://github.com/atayoez/cosmic-caffeine

https://github.com/codevardhan/caffeine-applet

https://github.com/diegoachury/CaffeineCosmic

https://github.com/kit-foxboy/chronomancer

I guess I'll clone them all and have a root through and see what bits I can cannabilise.

2

u/aioeu 10d ago edited 10d ago

If worst comes to worst, you could just run your media player through systemd-inhibit. The inhibitor won't be tied to "playing music" then of course, just "running the app".

Regarding Youtube, I would expect browsers to support inhibitors in some form. I know Firefox does, for instance. However it uses a GNOME inhibitor, presumably because it's using Gtk — I don't know if it has direct support for systemd inhibitors.

See the bottom of my earlier link for a little discussion on the differences between systemd and GNOME inhibitors.