i3 status and default $TERM for screen and tmux
This commit is contained in:
parent
af4c8c3d98
commit
b01252ad76
5 changed files with 38 additions and 60 deletions
34
i3_status
Executable file
34
i3_status
Executable file
|
@ -0,0 +1,34 @@
|
|||
#!/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('%a %d %H:%M')
|
||||
values.append(current_time)
|
||||
mem = psutil.virtual_memory()
|
||||
memory = 'RAM: {}% ({:.3}G)'.format(100.0 - mem.percent, mem.available / 2**30)
|
||||
values.append(memory)
|
||||
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
|
||||
values.append(batt)
|
||||
values.reverse()
|
||||
status_print(values)
|
||||
time.sleep(5)
|
||||
print(',', end='')
|
Loading…
Add table
Add a link
Reference in a new issue