dustin
/
i3
Archived
1
0
Fork 0
This repository has been archived on 2023-11-14. You can view files and clone it, but cannot push or open issues/pull-requests.
i3/py3status/uptime.py

15 lines
398 B
Python

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)}