Browse Source

i3 status ping pause

master
Robin Thoni 8 years ago
parent
commit
139bb89b4f

BIN
i3/i3/status/i3status/__pycache__/ping.cpython-34.pyc View File


+ 20
- 7
i3/i3/status/i3status/ping.py View File

10
         ("host", "host to ping"),
10
         ("host", "host to ping"),
11
         ("format", "format string"),
11
         ("format", "format string"),
12
         ("format_down", "format down string"),
12
         ("format_down", "format down string"),
13
+        ("format_pause", "format pause string"),
13
         ("color", "color"),
14
         ("color", "color"),
14
-        ("color_down", "color down")
15
+        ("color_down", "color down"),
16
+        ("color_pause", "color pause")
15
     )
17
     )
16
-    host = "8.8.8.8"
17
-    format = "{ping} ms"
18
-    format_down = "down"
18
+
19
+    active = True
19
     color = "#FFFFFF"
20
     color = "#FFFFFF"
20
     color_down = "#FF0000"
21
     color_down = "#FF0000"
22
+    color_pause = "#FF4500"
23
+    format = "{ping} ms"
24
+    format_down = "{ping} ms"
25
+    format_pause = "{ping} ms"
26
+    host = "8.8.8.8"
27
+    on_leftclick = "switch_state"
21
 
28
 
22
     def ping_host(self):
29
     def ping_host(self):
23
         p = subprocess.Popen(["ping", "-c1", "-w%d" % self.interval,
30
         p = subprocess.Popen(["ping", "-c1", "-w%d" % self.interval,
30
             return ""
37
             return ""
31
 
38
 
32
     def run(self):
39
     def run(self):
40
+        if not self.active:
41
+            self.output = {
42
+                "full_text": self.format_pause.format(ping=0),
43
+                "color": self.color_pause
44
+            }
45
+            return
46
+
33
         ping = self.ping_host()
47
         ping = self.ping_host()
34
         if not ping:
48
         if not ping:
35
             self.output = {
49
             self.output = {
44
             "color": self.color
58
             "color": self.color
45
         }
59
         }
46
 
60
 
47
-
48
-if __name__ == "__main__":
49
-    print(Ping().ping_host())
61
+    def switch_state(self):
62
+        self.active = not self.active

+ 7
- 4
i3/i3/status/status.py View File

125
                 color=g_color_good,
125
                 color=g_color_good,
126
                 color_down=g_color_alert,
126
                 color_down=g_color_alert,
127
                 format="\uf07d {ping:03.0f} ms",
127
                 format="\uf07d {ping:03.0f} ms",
128
-                format_down="\uf07d 000 ms")
128
+                format_down="\uf07d 000 ms",
129
+                format_pause="\uf07d 000 ms")
129
 
130
 
130
 def get_iface_param(iface):
131
 def get_iface_param(iface):
131
     if isinstance(iface, list):
132
     if isinstance(iface, list):
133
     return iface, iface
134
     return iface, iface
134
 
135
 
135
 ifaces_wireless = ["wlan0", "wlan1"]
136
 ifaces_wireless = ["wlan0", "wlan1"]
136
-ifaces_wired = ["eth0", "usb0"]
137
+ifaces_wired = ["eth0", "usb0", "br0"]
137
 ifaces_tun = [["tun0", "rthoni.com"], ["tun1", "inet"],
138
 ifaces_tun = [["tun0", "rthoni.com"], ["tun1", "inet"],
138
         ["tun2", "betaclean"]]
139
         ["tun2", "betaclean"]]
139
 
140
 
146
                 format_down="\uf1eb " + iface_name,
147
                 format_down="\uf1eb " + iface_name,
147
                 format_down_hide="\uf1eb",
148
                 format_down_hide="\uf1eb",
148
                 format_up="\uf1eb {essid} ({quality:03.0f}%) {v4}",
149
                 format_up="\uf1eb {essid} ({quality:03.0f}%) {v4}",
149
-                format_up_hide="\uf1eb " + iface_name)
150
+                format_up_hide="\uf1eb " + iface_name,
151
+                unknown_up=True)
150
 
152
 
151
 for iface in ifaces_wired:
153
 for iface in ifaces_wired:
152
     iface, iface_name = get_iface_param(iface)
154
     iface, iface_name = get_iface_param(iface)
157
                 format_down="\uf0e8 " + iface_name,
159
                 format_down="\uf0e8 " + iface_name,
158
                 format_down_hide="\uf0e8",
160
                 format_down_hide="\uf0e8",
159
                 format_up="\uf0e8 {v4}",
161
                 format_up="\uf0e8 {v4}",
160
-                format_up_hide="\uf0e8 " + iface_name)
162
+                format_up_hide="\uf0e8 " + iface_name,
163
+                unknown_up=True)
161
 
164
 
162
 for iface in ifaces_tun:
165
 for iface in ifaces_tun:
163
     iface, iface_name = get_iface_param(iface)
166
     iface, iface_name = get_iface_param(iface)

Loading…
Cancel
Save