Initial commit
This commit is contained in:
2
py3status/.gitignore
vendored
Normal file
2
py3status/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
__pycache__/
|
||||
*.py[co]
|
||||
22
py3status/color.py
Normal file
22
py3status/color.py
Normal file
@@ -0,0 +1,22 @@
|
||||
class Py3status:
|
||||
|
||||
force = False
|
||||
|
||||
class Meta:
|
||||
container = True
|
||||
|
||||
def __init__(self):
|
||||
self.items = []
|
||||
|
||||
def colorize(self):
|
||||
output = []
|
||||
for item in self.items:
|
||||
out = self.py3.get_output(item)
|
||||
if out and 'separator' not in out[-1]:
|
||||
out[-1]['separator'] = True
|
||||
for o in out:
|
||||
if self.force or not o.get('color'):
|
||||
o['color'] = self.color
|
||||
output += out
|
||||
|
||||
return {'composite': output}
|
||||
14
py3status/uptime.py
Normal file
14
py3status/uptime.py
Normal file
@@ -0,0 +1,14 @@
|
||||
import datetime
|
||||
import math
|
||||
|
||||
class Py3status:
|
||||
|
||||
def uptime(self):
|
||||
with open('/proc/uptime') as f:
|
||||
secs = float(f.read().split()[0])
|
||||
t = datetime.timedelta(seconds=math.floor(secs))
|
||||
if t.days >= 1:
|
||||
r = str(t).split(',')[0]
|
||||
else:
|
||||
r = str(t).rsplit(':', 1)[0]
|
||||
return {'full_text': r, 'cached_until': self.py3.time_in(60)}
|
||||
Reference in New Issue
Block a user