Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

systemd: new module from scratch #1554

Closed
wants to merge 1 commit into from
Closed

systemd: new module from scratch #1554

wants to merge 1 commit into from

Conversation

lasers
Copy link
Contributor

@lasers lasers commented Oct 21, 2018

This addresses the issues in (2) systemd pull requests.

  • Replaces systemd: add config parameter to hide service extension #1381, Hide service extension.
    • We replace boolean config with the format.
    • Single format for full customization. Colors included.
    • Allow more things to happen in the future (ie formatters).
    • Users can specify: SSH, ssh, sshd, [sshd], OpenSSH etc.
  • Replaces systemd: Suppress output if unit is in default state #1382, Suppress output if unit is in default state.
    • We replace string config with the format.
    • Single format for full customization. Colors included.
    • Allow more things to happen in the future (ie formatters).
    • Format allows us to do more than (4) hide_if_default options.
    • More than 50+ placeholders. Not all of them will be supported or usable.

This is also here because @tobes puts out a dbus helper for modules.

  • If he want to, he can use this PR with a diff below to help himself making a better dbus helper... for systemd without cache_timeout and other modules. Note: The diff seems identical to the Upower one, but it does not work. I acknowledge it is not finished. Cheers.
diff --git a/py3status/modules/systemd.py b/py3status/modules/systemd.py
index caa2bde7..dfbcb53f 100644
--- a/py3status/modules/systemd.py
+++ b/py3status/modules/systemd.py
@@ -3,7 +3,6 @@
 Display systemd1 unit properties of a service.
 
 Configuration parameters:
-    cache_timeout: refresh interval for this module (default 5)
     format: display format for this module
         *(default '{Id} [\?if=LoadState=not-found&color=degraded '
         '{LoadState}|[\?color=ActiveState {ActiveState}]]')*
@@ -120,7 +119,6 @@ class Py3status:
     """
 
     # available configuration parameters
-    cache_timeout = 5
     format = (
         "{Id} [\?if=LoadState=not-found&color=degraded {LoadState}"
         "|[\?color=ActiveState {ActiveState}]]"
@@ -148,6 +146,7 @@ class Py3status:
         manager = dbus.Interface(systemd, dbus_interface=MANAGER)
         proxy = bus.get_object(SYSTEMD1, manager.LoadUnit(self.unit))
         self.systemd_unit = dbus.Interface(proxy, dbus_interface=UNIT)
+        self.py3.dbus_subscribe(".systemd1", "update")
 
     def systemd(self):
         systemd_data = self.systemd_unit.GetAll(UNIT, dbus_interface=PROP)
@@ -162,7 +161,7 @@ class Py3status:
                 self.py3.threshold_get_color(systemd_data[x], x)
 
         return {
-            "cached_until": self.py3.time_in(self.cache_timeout),
+            "cached_until": self.py3.time_in(self.py3.CACHE_FOREVER),
             "full_text": self.py3.safe_format(self.format, systemd_data),
         }
 

@lasers lasers added the dangerous 💣 I require users to change their configuration label Oct 22, 2018
@lasers lasers changed the title new module from scratch: systemd systemd: new module from scratch Nov 9, 2018
@ultrabug
Copy link
Owner

Too much format magic, this is not the way forward, closing for simpler implementations

@ultrabug ultrabug closed this Dec 23, 2018
@lasers lasers deleted the newmodule-systemd branch December 23, 2018 17:40
@lasers lasers mentioned this pull request Jun 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dangerous 💣 I require users to change their configuration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants