move config to yaml, json is atrocious

This commit is contained in:
Von Random 2019-03-05 12:33:05 +03:00
parent ba862efad9
commit 46f3d778af
4 changed files with 35 additions and 42 deletions

View file

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

View file

@ -1,38 +0,0 @@
{
"output_format": "i3",
"plugins": [
{
"name": "ping",
"hosts": [
"de-ber-as20647.anchors.atlas.ripe.net",
"nl-ams-as1101.anchors.atlas.ripe.net",
"uk-boh-as196745.anchors.atlas.ripe.net"
],
"title": "NET"
},
{
"name": "disk",
"partition": "/",
"problem": 80,
"hide_ok": false
},
{
"name": "disk",
"partition": "/home",
"problem": 90
},
{
"name": "pacman"
},
{
"name": "mem"
},
{
"name": "load"
},
{
"name": "date",
"format": "%a %d %H:%M"
}
]
}

20
conf.yaml Normal file
View file

@ -0,0 +1,20 @@
output_format: i3
plugins:
- name: ping
title: NET
hosts:
- de-ber-as20647.anchors.atlas.ripe.net
- nl-ams-as1101.anchors.atlas.ripe.net
- uk-boh-as196745.anchors.atlas.ripe.net
- name: disk
partition: /
problem: 80
hide_ok: false
- name: disk
partition: /home
problem: 90
- name: pacman
- name: mem
- name: load
- name: date
format: '%a %d %H:%M'

View file

@ -1,4 +1,5 @@
#!/usr/bin/python3
# pylint: disable=C0111
# TODO: consider per plugin hide_ok overriding global, not the other way around
# TODO: add documentation / comments
# TODO: interactivity support
@ -8,10 +9,11 @@ import json
import os
import sys
import time
import yaml
import plugins
DEFAULT_CONFIG = os.path.join(os.environ['HOME'], '.config/vdstatus/conf.json')
DEFAULT_CONFIG = os.path.join(os.environ['HOME'], '.config/vdstatus/conf.yaml')
def parse_arguments():
@ -33,7 +35,7 @@ class PluginRunner:
}
config = dict()
with open(config_file) as config_data:
config = json.load(config_data)
config = yaml.load(config_data)
self.conf = plugins.parse_config(config, defaults)
self.plugins_loaded = list()
self.format_output = self.format_term
@ -79,9 +81,13 @@ class PluginRunner:
return ' \033[1m|\033[0m '.join(return_info)
if __name__ == '__main__':
def main():
args = parse_arguments()
plugin_runner = PluginRunner(args.conf)
plugin_runner.start()
time.sleep(0.1)
plugin_runner.run()
if __name__ == '__main__':
main()