A person, on the Gnome Issue, suggested that terminals inhibit sleep when there is stuff running in them.
Continuing from that discussion, I am trying to understand, at which point it would be desirable to implement said inhibition - terminal emulator, the shell or the program itself
Additionally:
- We want to inhibit when running stuff like
pacman
,wget
,cp
ormv
- We don’t want to inhibit when running stuff like
htop
,less
,watch
We want to inhibit when running stuff like pacman, wget, cp or mv
There is already a separate
systemd-inhibit
command that does exactly what you need. Trust your users, they are capable of googling it (most of the time).Only pacman and wget will benefit from suspend inhibition, because it will prevent breaking network connections. cp and mv will resume working just fine even when you hibernated your laptop while cp was executing. And in that case it’s less bug-prone to scan your system for active TCP connections to external addresses instead of adding a hack wakelock inside your terminal or inside wget.
It is also a poor idea to mess up with system-wide settings from some command when the user does not expect it, you’ll likely to get a thousand invalid bug reports that sleep mode is broken when some service randomly decides to use wget to continuously read from local Unix socket.
MacOS has had caffeinate forever, and it works great
I use
gnome-session-inhibit
quite a bit, but it’s hard to imagine a good way to automate it.Sometimes I inhibit
idle
to keep something on screen, and sometimes I just inhibitsuspend
so something can complete.It probably doesn’t make sense for the terminal to have anything more than a protocol to control it. The only real benefit to that would be in remote sessions, and it’s not really clear how it should work when multiple machines are involved.
I remember writing a script that posted an X event 1x a minute for something like that. The event was probably simulating pressing the shift key.
I stIll use tHis methOd, it worKs flawleSsly!