apognu / tuigreet

Graphical console greeter for greetd
GNU General Public License v3.0
925 stars 41 forks source link

[Feature Request] Hibernate/shut down timer #154

Closed najjt closed 3 weeks ago

najjt commented 1 month ago

Hi,

First of all, thank you for making tuigreet. On to my request:

To my knowledge, there isn't a way of making tuigreet shut down or hibernate automatically. For example, I would like to be able to set a two-minute timer after which the computer is put into hibernation or shut down. Have I missed this somewhere perhaps? Thanks in advance.

apognu commented 4 weeks ago

I do not think that it should be the responsibility of tuigreet, or a login manager in general, to handle that kind of power management. Unless someone gives a very good rationale of why it should be, I do not think this will get implemented.

najjt commented 3 weeks ago

Thank you for the quick reply. Where do you recommend I turn in order to achieve this?

apognu commented 3 weeks ago

I do not know of anything that does this automatically (except maybe systemd-logind that should be able to detect and act on idle sessions). It would definitely need to be something global that can ensure that nothing is happening on the system at all.

For tuigreet itself, without external dependencies, you can check for activity by stating the appropriate TTY:

$ stat -c '%X' /dev/tty2
1725179180

...should give you the epoch of the last character typed.

Now just a heads up, be careful if you design such a script yourself, it would be quite easy to make something that results in an infinite wake-suspend loop (the command will only give relevant results when tuigreet is actually running, and the script might immediately suspend again when waking up before you have a chance to enter a new character).

One of the reason I am against doing it in tuigreet itself, we cannot assume, just because we are idle, that there isn't another active session (you logged into another TTY, you are SSH-ing in, or you are running something that inhibits idling and should not be suspended).

najjt commented 3 weeks ago

Thank you very much for your quick and detailed reply.