master
parent
1d5f714c34
commit
a81530c0c5
5 changed files with 17 additions and 45 deletions
@ -1,39 +0,0 @@ |
||||
#!/usr/bin/python3 -u |
||||
|
||||
import time |
||||
import psutil |
||||
|
||||
def status_print(status_msg): |
||||
prefix = '[' |
||||
postfix = ']' |
||||
result = list() |
||||
for element in status_msg: |
||||
result.append('{"full_text":"' + element + '"}') |
||||
print(prefix + ','.join(result) + postfix) |
||||
|
||||
print('{"version":1}\n[') |
||||
while True: |
||||
values = list() |
||||
current_time = time.strftime('%H:%M') |
||||
current_day = time.strftime('%a %d') |
||||
mem = psutil.virtual_memory() |
||||
memory = 'RAM: {}% ({}G)'.format(round(100.0 - mem.percent, 2), |
||||
round(mem.available / 2**30, 2)) |
||||
with open('/sys/class/power_supply/BAT0/capacity', 'r') as capacity, \ |
||||
open('/sys/class/power_supply/BAT0/status', 'r') as status: |
||||
batt_status = status.read().strip() |
||||
batt_capacity = capacity.read().strip() |
||||
if batt_status != 'Discharging': |
||||
batt_status = '↑' |
||||
else: |
||||
batt_status = '↓' |
||||
batt = 'BAT: ' + batt_capacity + '% ' + batt_status |
||||
# populate the bar |
||||
values.append(batt) |
||||
values.append(memory) |
||||
values.append(current_day) |
||||
values.append(current_time) |
||||
# print da shit |
||||
status_print(values) |
||||
time.sleep(5) |
||||
print(',', end='') |
@ -0,0 +1,4 @@ |
||||
" vim: set ft=vimperator: |
||||
|
||||
set hintchars="qwertyuiop[]asdfghjkl;'zxcvbnm,./" |
||||
set toolbars=addons,nobookmarks,nomenu,nonavigation,tabs |
Loading…
Reference in new issue