-
Notifications
You must be signed in to change notification settings - Fork 1
/
windows_open.py
executable file
·45 lines (31 loc) · 1.03 KB
/
windows_open.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python
# fuck you python; why make it so hard to cleanly import from parent dir?
from os.path import dirname, abspath
import sys ; sys.path.insert(1, dirname(dirname(abspath(__file__))))
import os
import random
import fuckometer
def main(args):
fuckometer.init()
windows = WindowsOpen(period=59)
windows.loop() # run forever
class WindowsOpen(fuckometer.Factor):
"""How many windows are open on my desktop?"""
path = 'windows_open'
def fucks(self):
floor = 50.0
ceil = 400.0
value = (self.raw - floor) / (ceil-floor)
value = min(1.0, max(0.0, value))
return 100.0 * value
def on_update(self):
if fuckometer.cfg.verbose:
print('%.1f fucks: %s' % (self.fucks(), self.text))
def update(self):
line = open('%s/.open/open.otl.stats' % (os.environ['HOME'])).readline()
parts = line.split()
self.raw = int(parts[0])
self.text = line.strip()
if __name__ == "__main__":
import sys
main(sys.argv[1:])