From d9747b64e1e62abee12ef0bafd365cf380ff7fe9 Mon Sep 17 00:00:00 2001 From: Ultrabug Date: Sun, 23 Nov 2014 20:55:53 +0100 Subject: move modules folder so we can install it as a module of py3status --- modules/__init__.py | 0 modules/battery-level.py | 68 ------------------ modules/clementine.py | 65 ----------------- modules/dpms.py | 44 ------------ modules/empty_class.py | 41 ----------- modules/glpi.py | 52 -------------- modules/i3bar_click_events.py | 127 -------------------------------- modules/imap.py | 58 --------------- modules/keyboard-layout.py | 73 ------------------- modules/mpd_status.py | 117 ------------------------------ modules/net_rate.py | 163 ------------------------------------------ modules/netdata.py | 132 ---------------------------------- modules/ns_checker.py | 57 --------------- modules/pingdom.py | 59 --------------- modules/pomodoro.py | 123 ------------------------------- modules/scratchpad-counter.py | 50 ------------- modules/sysdata.py | 148 -------------------------------------- modules/vnstat.py | 138 ----------------------------------- modules/weather_yahoo.py | 106 --------------------------- modules/whoami.py | 26 ------- modules/window-title.py | 58 --------------- 21 files changed, 1705 deletions(-) delete mode 100644 modules/__init__.py delete mode 100644 modules/battery-level.py delete mode 100644 modules/clementine.py delete mode 100644 modules/dpms.py delete mode 100644 modules/empty_class.py delete mode 100644 modules/glpi.py delete mode 100644 modules/i3bar_click_events.py delete mode 100644 modules/imap.py delete mode 100644 modules/keyboard-layout.py delete mode 100644 modules/mpd_status.py delete mode 100644 modules/net_rate.py delete mode 100644 modules/netdata.py delete mode 100644 modules/ns_checker.py delete mode 100644 modules/pingdom.py delete mode 100644 modules/pomodoro.py delete mode 100644 modules/scratchpad-counter.py delete mode 100644 modules/sysdata.py delete mode 100644 modules/vnstat.py delete mode 100644 modules/weather_yahoo.py delete mode 100644 modules/whoami.py delete mode 100644 modules/window-title.py (limited to 'modules') diff --git a/modules/__init__.py b/modules/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/modules/battery-level.py b/modules/battery-level.py deleted file mode 100644 index 6c30556..0000000 --- a/modules/battery-level.py +++ /dev/null @@ -1,68 +0,0 @@ -# -*- coding: utf8 -*- - -from __future__ import division # python2 compatibility -from time import time - -import math -import re -import subprocess - -""" -Module for displaying information about battery. - -Requires: - - the 'acpi' command line - -@author shadowprince -@license Eclipse Public License -""" - -CACHE_TIMEOUT = 30 # time to update battery -HIDE_WHEN_FULL = False # hide any information when battery is fully charged - -MODE = "bar" # for primitive-one-char bar, or "text" for text percentage ouput - -BLOCKS = ["_", "▁", "▂", "▃", "▄", "▅", "▆", "▇", "█"] # block for bar -TEXT_FORMAT = "Battery: {}" # text with "text" mode. percentage with % replaces {} - -CHARGING_CHARACTER = "⚡" - -# None means - get it from i3 config -COLOR_BAD = None -COLOR_CHARGING = "#FCE94F" -COLOR_DEGRADED = None -COLOR_GOOD = None - - -class Py3status: - def battery_level(self, i3status_output_json, i3status_config): - response = {'name': 'battery-level'} - - acpi = subprocess.check_output(["acpi"]).decode('utf-8') - proc = int(re.search(r"(\d+)%", acpi).group(1)) - - charging = bool(re.match(r".*Charging.*", acpi)) - full = bool(re.match(r".*Unknown.*", acpi)) or bool(re.match(r".*Full.*", acpi)) - - if MODE == "bar": - character = BLOCKS[int(math.ceil(proc/100*(len(BLOCKS) - 1)))] - else: - character = TEXT_FORMAT.format(str(proc) + "%") - - if proc < 30: - response['color'] = COLOR_DEGRADED if COLOR_DEGRADED else i3status_config['color_degraded'] - if proc < 10: - response['color'] = COLOR_BAD if COLOR_BAD else i3status_config['color_bad'] - - if full: - response['color'] = COLOR_GOOD if COLOR_GOOD else i3status_config['color_good'] - response['full_text'] = "" if HIDE_WHEN_FULL else BLOCKS[-1] - elif charging: - response['color'] = COLOR_CHARGING - response['full_text'] = CHARGING_CHARACTER - else: - response['full_text'] = character - - response['cached_until'] = time() + CACHE_TIMEOUT - - return (0, response) diff --git a/modules/clementine.py b/modules/clementine.py deleted file mode 100644 index 61917b7..0000000 --- a/modules/clementine.py +++ /dev/null @@ -1,65 +0,0 @@ -# -*- coding: utf-8 -*- - -from time import time -from subprocess import check_output - - -class Py3status: - """ - clementine.py - - This module display the current "artist - title" playing in Clementine. - - Last modified: 2014-03-23 - Author: Francois LASSERRE - License: GNU GPL http://www.gnu.org/licenses/gpl.html - """ - def _getMetadatas(self): - """ - Get the current song metadatas (artist - title) - """ - track_id = check_output('qdbus org.mpris.clementine /TrackList org.freedesktop.MediaPlayer.GetCurrentTrack', shell=True) - metadatas = check_output('qdbus org.mpris.clementine /TrackList org.freedesktop.MediaPlayer.GetMetadata {}'.format(track_id.decode()), shell=True) - lines = metadatas.decode('utf-8').split('\n') - lines = filter(None, lines) - - now_playing = '' - - if lines: - artist = '' - title = '' - internet_radio = False - - for item in lines: - if item.find('artist:') != -1: - artist = item[8:] - if item.find('title:') != -1: - title = item[7:] - - if title.find('.wav') != -1 or title.find('.mp3') != -1: - title = title[:-4] - if title.find('http') != -1: - title = '' - internet_radio = True - - if artist and title: - now_playing = '♫ {} - {}'.format(artist, title) - elif artist: - now_playing = '♫ {}'.format(artist) - elif title: - now_playing = '♫ {}'.format(title) - elif internet_radio: - now_playing = '♫ Internet Radio' - - return now_playing - - def clementine(self, i3status_output_json, i3status_config): - """ - Get the current "artist - title" and return it. - """ - response = {'full_text': '', 'name': 'clementine'} - - response['cached_until'] = time() - response['full_text'] = self._getMetadatas() - - return (0, response) diff --git a/modules/dpms.py b/modules/dpms.py deleted file mode 100644 index 783c53c..0000000 --- a/modules/dpms.py +++ /dev/null @@ -1,44 +0,0 @@ -from os import system - - -class Py3status: - """ - This module allows activation and deactivation - of DPMS (Display Power Management Signaling) - by clicking on 'DPMS' in the status bar. - - Written and contributed by @tasse: - Andre Doser - """ - def __init__(self): - """ - Detect current state on start. - """ - self.run = system('xset -q | grep -iq "DPMS is enabled"') == 0 - - def dpms(self, i3status_output_json, i3status_config): - """ - Display a colorful state of DPMS. - """ - result = { - 'full_text': 'DPMS', - 'name': 'dpms' - } - if self.run: - result['color'] = i3status_config['color_good'] - else: - result['color'] = i3status_config['color_bad'] - return (0, result) - - def on_click(self, json, i3status_config, event): - """ - Enable/Disable DPMS on left click. - """ - if event['button'] == 1: - if self.run: - self.run = False - system("xset -dpms") - else: - self.run = True - system("xset +dpms") - system("killall -USR1 py3status") diff --git a/modules/empty_class.py b/modules/empty_class.py deleted file mode 100644 index 077269c..0000000 --- a/modules/empty_class.py +++ /dev/null @@ -1,41 +0,0 @@ -class Py3status: - """ - Empty and basic py3status class. - - NOTE: py3status will NOT execute: - - methods starting with '_' - - methods decorated by @property and @staticmethod - - NOTE: reserved method names: - - 'kill' method for py3status exit notification - - 'on_click' method for click events from i3bar - """ - def kill(self, i3status_output_json, i3status_config): - """ - This method will be called upon py3status exit. - """ - pass - - def on_click(self, i3status_output_json, i3status_config, event): - """ - This method will be called when a click event occurs on this module's - output on the i3bar. - - Example 'event' json object: - {'y': 13, 'x': 1737, 'button': 1, 'name': 'empty', 'instance': 'first'} - """ - pass - - def empty(self, i3status_output_json, i3status_config): - """ - This method will return an empty text message - so it will NOT be displayed on your i3bar. - - If you want something displayed you should write something - in the 'full_text' key of your response. - - See the i3bar protocol spec for more information: - http://i3wm.org/docs/i3bar-protocol.html - """ - response = {'full_text': '', 'name': 'empty', 'instance': 'first'} - return (0, response) diff --git a/modules/glpi.py b/modules/glpi.py deleted file mode 100644 index 929749d..0000000 --- a/modules/glpi.py +++ /dev/null @@ -1,52 +0,0 @@ -# You need MySQL-python from http://pypi.python.org/pypi/MySQL-python -import MySQLdb - - -class Py3status: - """ - This example class demonstrates how to display the current total number of - open tickets from GLPI in your i3bar. - - It features thresholds to colorize the output and forces a low timeout to - limit the impact of a server connectivity problem on your i3bar freshness. - - Note that we don't have to implement a cache layer as it is handled by - py3status automagically. - """ - def count_glpi_open_tickets(self, json, i3status_config): - response = {'full_text': '', 'name': 'glpi_tickets'} - - # user-defined variables - CRIT_THRESHOLD = 20 - WARN_THRESHOLD = 15 - MYSQL_DB = '' - MYSQL_HOST = '' - MYSQL_PASSWD = '' - MYSQL_USER = '' - POSITION = 0 - - mydb = MySQLdb.connect( - host=MYSQL_HOST, - user=MYSQL_USER, - passwd=MYSQL_PASSWD, - db=MYSQL_DB, - connect_timeout=5, - ) - mycr = mydb.cursor() - mycr.execute('''select count(*) - from glpi_tickets - where closedate is NULL and solvedate is NULL;''') - row = mycr.fetchone() - if row: - open_tickets = int(row[0]) - if i3status_config['colors']: - if open_tickets > CRIT_THRESHOLD: - response.update({'color': i3status_config['color_bad']}) - elif open_tickets > WARN_THRESHOLD: - response.update( - {'color': i3status_config['color_degraded']} - ) - response['full_text'] = '%s tickets' % open_tickets - mydb.close() - - return (POSITION, response) diff --git a/modules/i3bar_click_events.py b/modules/i3bar_click_events.py deleted file mode 100644 index 792965c..0000000 --- a/modules/i3bar_click_events.py +++ /dev/null @@ -1,127 +0,0 @@ -from subprocess import Popen -from time import time - - -class Py3status: - """ - This module allows you to take actions based on click events made on - the i3status modules. For example, thanks to this module you could - launch the wicd GUI when clicking on the ethernet or wireless module - of your i3status output ! - - IMPORTANT: - This module file name is reserved and should NOT be changed if you - want py3status to handle your i3status modules click events ! - - The behavior described above will only work if this file is named - 'i3bar_click_events.py' ! - """ - def __init__(self): - """ - This is where you setup your actions based on your i3status config. - - Configuration: - -------------- - self.actions = { - "": { -