ultrabug / py3status

py3status is an extensible i3status wrapper written in python
https://ultrabug.github.io/py3status/
BSD 3-Clause "New" or "Revised" License
893 stars 261 forks source link

Prevent bar being stopped by using signal other than SIGSTOP #2093

Closed pedro-nonfree closed 2 years ago

pedro-nonfree commented 2 years ago

Is your feature request related to a problem? Please describe.

When the bar is hidden, i3bar sends the SIGSTOP and SIGCONT signals to the status_command process in order to conserve battery power. This feature can be disabled by the status_command process by setting the appropriate values in its JSON header message.

https://i3wm.org/docs/userguide.html#_display_mode

it also fills the syslog with strange messages like this:

Jan 21 13:11:05 host py3status: received SIGTSTP
Jan 21 13:11:15 host py3status: received SIGCONT
Jan 21 13:11:16 host py3status: received SIGTSTP
Jan 21 13:11:25 host py3status: received SIGCONT
Jan 21 13:11:26 host py3status: received SIGTSTP
Jan 21 13:11:32 host py3status: received SIGCONT
Jan 21 13:11:32 host py3status: received SIGTSTP

looks like stop_signal is hardcoded to certain value (20)

https://github.com/ultrabug/py3status/blob/725cfec4480ba542ba7821aff7445653e1587f3f/py3status/core.py#L1019

Your py3status version py3status version 3.31 (python 3.9.2) on i3

Describe the solution you'd like

the solution they found in i3status-rust https://github.com/greshake/i3status-rust/pull/701 is a new option called never-pause

Additional context Additional links

lasers commented 2 years ago

Rough draft.

diff --git a/py3status/core.py b/py3status/core.py
index 77e624d..42161aa 100644
--- a/py3status/core.py
+++ b/py3status/core.py
@@ -1016,7 +1016,7 @@ class Py3statusWrapper:
         header = {
             "version": 1,
             "click_events": self.config["click_events"],
-            "stop_signal": SIGTSTP,
+            "stop_signal": signal.Signals[py3_config.get("py3status", {}).get("stop_signal", "SIGTSTP")],
         }
         write(dumps(header))
         write("\n[[]\n")

and

# ~/.config/py3status/config
# --------------------------
general {

}
py3status {
    stop_signal = "SIGTSTP"
}

order += "sysdata"
order += "lm_sensors"
order += "nvidia_smi"
# ...
ultrabug commented 2 years ago

@pedro-nonfree I think that what @lasers suggests is good; would you like such an option?

ultrabug commented 2 years ago

please check #2095 thanks :)

ultrabug commented 2 years ago

closed via #2095