7 changed files with 135 additions and 33 deletions
@ -0,0 +1,33 @@
|
||||
import threading |
||||
import time |
||||
|
||||
|
||||
BATTERY_DIR = '/sys/class/power_supply/BAT0/' |
||||
|
||||
|
||||
class PluginThread(threading.Thread): |
||||
def __init__(self, section, config, thread_id): |
||||
threading.Thread.__init__(self) |
||||
self.threadID = thread_id |
||||
self.status = dict() |
||||
if config.has_option(section, 'color'): |
||||
self.status['color'] = config.get(section, 'color') |
||||
self.freq = 1 |
||||
|
||||
def main(self): |
||||
with open(BATTERY_DIR + 'capacity', 'r') as capacity, \ |
||||
open(BATTERY_DIR + 'status', 'r') as status: |
||||
batt_stat = status.read().strip() |
||||
batt_capacity = capacity.read().strip() |
||||
if batt_stat != 'Discharging': |
||||
batt_stat = '\u2191' |
||||
else: |
||||
batt_stat = '\u2193' |
||||
batt = 'BAT: ' + batt_capacity + '% ' + batt_stat |
||||
|
||||
self.status['full_text'] = batt |
||||
|
||||
def run(self): |
||||
while True: |
||||
self.main() |
||||
time.sleep(self.freq) |
@ -0,0 +1,25 @@
|
||||
import psutil |
||||
import threading |
||||
import time |
||||
|
||||
|
||||
class PluginThread(threading.Thread): |
||||
def __init__(self, section, config, thread_id): |
||||
threading.Thread.__init__(self) |
||||
self.threadID = thread_id |
||||
self.status = dict() |
||||
if config.has_option(section, 'color'): |
||||
self.status['color'] = config.get(section, 'color') |
||||
self.freq = 1 |
||||
|
||||
def main(self): |
||||
mem_stat = psutil.virtual_memory() |
||||
mem_percentage = round(100.0 - mem_stat.percent, 2) |
||||
mem_available = round(mem_stat.available / 2**30, 2) |
||||
mem = 'RAM: ' + str(mem_percentage) + '% (' + str(mem_available) + 'G)' |
||||
self.status['full_text'] = mem |
||||
|
||||
def run(self): |
||||
while True: |
||||
self.main() |
||||
time.sleep(self.freq) |
@ -1,10 +1,21 @@
|
||||
#!/usr/bin/python3 -u |
||||
import json |
||||
from sys import argv |
||||
import argparse |
||||
import vdstatus |
||||
import time |
||||
|
||||
|
||||
print('{"version":1}') |
||||
print('[') |
||||
while True: |
||||
vdstatus.run_plugins() |
||||
def parse_arguments(arguments=argv[1:]): |
||||
desc = ('A simple i3status replacement, ' |
||||
'and more. Warning: WIP, may be broken.') |
||||
p = argparse.ArgumentParser(description=desc) |
||||
p.add_argument('-c', '--config', help='configuration file') |
||||
|
||||
return p.parse_args(arguments) |
||||
|
||||
|
||||
if __name__ == '__main__': |
||||
args = parse_arguments() |
||||
if args.config is not None: |
||||
vdstatus.run_plugins(args.config) |
||||
else: |
||||
vdstatus.run_plugins() |
||||
|
Loading…
Reference in new issue