Browse Source

move config to yaml, json is atrocious

master
Von Random 3 months ago
parent
commit
46f3d778af
4 changed files with 35 additions and 42 deletions
  1. 6
    1
      README.md
  2. 0
    38
      conf.json
  3. 20
    0
      conf.yaml
  4. 9
    3
      vdstatus

+ 6
- 1
README.md View File

@@ -1,4 +1,9 @@
1 1
 vdstatus
2 2
 ========
3 3
 
4
-A status script initially for i3bar. Potentially will support lemonbar. It is on very early stages of development.
4
+A simple replacement for i3status that is both extensible and customizable.
5
+Documentation is pending, but no promises.
6
+
7
+Requirements:
8
+* python 3
9
+* pyyaml

+ 0
- 38
conf.json View File

@@ -1,38 +0,0 @@
1
-{
2
-    "output_format": "i3",
3
-    "plugins": [
4
-        {
5
-            "name": "ping",
6
-            "hosts": [
7
-                "de-ber-as20647.anchors.atlas.ripe.net",
8
-                "nl-ams-as1101.anchors.atlas.ripe.net",
9
-                "uk-boh-as196745.anchors.atlas.ripe.net"
10
-            ],
11
-            "title": "NET"
12
-        },
13
-        {
14
-            "name": "disk",
15
-            "partition": "/",
16
-            "problem": 80,
17
-            "hide_ok": false
18
-        },
19
-        {
20
-            "name": "disk",
21
-            "partition": "/home",
22
-            "problem": 90
23
-        },
24
-        {
25
-            "name": "pacman"
26
-        },
27
-        {
28
-            "name": "mem"
29
-        },
30
-        {
31
-            "name": "load"
32
-        },
33
-        {
34
-            "name": "date",
35
-            "format": "%a %d %H:%M"
36
-        }
37
-    ]
38
-}

+ 20
- 0
conf.yaml View File

@@ -0,0 +1,20 @@
1
+output_format: i3
2
+plugins:
3
+- name: ping
4
+  title: NET
5
+  hosts:
6
+  - de-ber-as20647.anchors.atlas.ripe.net
7
+  - nl-ams-as1101.anchors.atlas.ripe.net
8
+  - uk-boh-as196745.anchors.atlas.ripe.net
9
+- name: disk
10
+  partition: /
11
+  problem: 80
12
+  hide_ok: false
13
+- name: disk
14
+  partition: /home
15
+  problem: 90
16
+- name: pacman
17
+- name: mem
18
+- name: load
19
+- name: date
20
+  format: '%a %d %H:%M'

+ 9
- 3
vdstatus View File

@@ -1,4 +1,5 @@
1 1
 #!/usr/bin/python3
2
+# pylint: disable=C0111
2 3
 # TODO: consider per plugin hide_ok overriding global, not the other way around
3 4
 # TODO: add documentation / comments
4 5
 # TODO: interactivity support
@@ -8,10 +9,11 @@ import json
8 9
 import os
9 10
 import sys
10 11
 import time
12
+import yaml
11 13
 import plugins
12 14
 
13 15
 
14
-DEFAULT_CONFIG = os.path.join(os.environ['HOME'], '.config/vdstatus/conf.json')
16
+DEFAULT_CONFIG = os.path.join(os.environ['HOME'], '.config/vdstatus/conf.yaml')
15 17
 
16 18
 
17 19
 def parse_arguments():
@@ -33,7 +35,7 @@ class PluginRunner:
33 35
         }
34 36
         config = dict()
35 37
         with open(config_file) as config_data:
36
-            config = json.load(config_data)
38
+            config = yaml.load(config_data)
37 39
         self.conf = plugins.parse_config(config, defaults)
38 40
         self.plugins_loaded = list()
39 41
         self.format_output = self.format_term
@@ -79,9 +81,13 @@ class PluginRunner:
79 81
         return ' \033[1m|\033[0m '.join(return_info)
80 82
 
81 83
 
82
-if __name__ == '__main__':
84
+def main():
83 85
     args = parse_arguments()
84 86
     plugin_runner = PluginRunner(args.conf)
85 87
     plugin_runner.start()
86 88
     time.sleep(0.1)
87 89
     plugin_runner.run()
90
+
91
+
92
+if __name__ == '__main__':
93
+    main()

Loading…
Cancel
Save