def run(self): if shell('which netctl-auto') is None: return while True: rv = shell('SUDO_ASKPASS=/bin/false ' 'sudo -A netctl-auto list').splitlines() for x in rv: if x.startswith('*'): self.text = x[1:].strip() break else: self.text = '{}disconnected {}'.format(urgent_color, normal_color) time.sleep(10)
def run(self): while True: if is_running('ncmpcpp'): self.text = 'MPD: {select}{song}'.format( select=selected_color, song=shell('mpc | head -1 | cut -c-50') ) else: self.text = None time.sleep(0.3)
def _set_vol(self): state = shell('amixer get Master | grep "Left: Playback" | head -1') \ .strip().split() if not state: return vol = state[-2].replace('[', '').replace(']', '') mute = state[-1] text = '{}VOL: '.format(title_color) text += urgent_color if mute == '[off]' else selected_color text += vol self.text = text
def run(self): while True: cores = [ line for line in shell('sensors').split('\n') if line.startswith('Core ') ] core_temps = [ title_color + repr(float(core.split()[2].replace('°C', ''))) for core in cores ] self.text = self.bar.between.join(core_temps) time.sleep(5)
def run(self): while True: rv = shell('upower -i ' '/org/freedesktop/UPower/devices/battery_BAT0') if not rv: break rv = rv.split('\n') data = {} for l in rv: if ':' not in l: continue k, v = l.split(':', 1) k = k.strip() v = v.strip() data[k] = v if 'state' not in data: # no battery in this device break state = data['state'] percentage = int(data['percentage'].strip('%')) battery_empty = percentage < 10 if battery_empty and (not self._color or state == 'charging'): self._color = urgent2_color else: self._color = '' if state == 'charging': _time = data.get('time to full', None) else: _time = data.get('time to empty', None) if _time: self.text = '{}{} ({}); {}%'.format( self._color, state, _time, percentage) else: self.text = '{}{}; {}%'.format( self._color, state, percentage) time.sleep(1 if self._color or battery_empty else 20)
def _send_notification(self, amount): shell('notify-send "You have {} new mails!"'.format(amount))
def watch_dir(p): shell('inotifywait -rq -e create -e delete -e move ' + p)