Commits

Fernando G N Rocha committed de4f2c8

Adicionado oss_vol

Comments (0)

Files changed (1)

+#!/usr/bin/python2
+# -*- coding: utf-8 -*-
+
+import os
+import datetime
+import pynotify
+import procname
+
+procname.setprocname('oss_vol')
+
+
+class Bars(object):
+    def __init__(self):
+        self.num_bars = self.get_num_bars()
+        self.last_update = datetime.datetime.now()
+
+    def __str__(self):
+        return self.get_bars()
+
+    def get_num_bars(self):
+        vol = os.popen('ossmix vmix0-outvol').read()
+        vol = vol.split(' ')
+        vol = vol[-2]
+
+        vol = int(float(vol))
+
+        return (vol*17)/25
+
+    def get_bars(self):
+        if self.num_bars != self.get_num_bars():
+            self.num_bars = self.get_num_bars()
+            self.last_update = datetime.datetime.now()
+
+        return  '❚'* self.get_num_bars() + '➤' 
+
+
+pynotify.init("oss_vol")
+bars = Bars()
+n = pynotify.Notification(str(bars))
+n.show()
+while True:
+    if (datetime.datetime.now() - bars.last_update) > datetime.timedelta(0,1):
+        break
+    n.update(str(bars))
+    n.show()