From 78f7be4e4b6501b15b5fefc9f7824bbadf0daf2a Mon Sep 17 00:00:00 2001 From: Weitian LI Date: Fri, 13 Jun 2014 21:12:21 +0800 Subject: Added various dotfiles. * Xresources * profile, xprofile, xinitrc * bash (aliases, logout, profile, rc, completion) * gitconfig * gtkrc and gtk-bookmarks * i3 configs (with py3status configs) * i3status.conf * lftp/rc * tmux.conf * xbindkeysrc * mpdconf * ncmpcpp (config and keys) * sbclrc * vifm (vifmrc, colors) * urxvt (perl extensions) * conkyrc (and conky/cronograph configs) --- .i3/py3status/backup/dpms.py | 44 +++++++++ .i3/py3status/backup/empty_class.py | 41 +++++++++ .i3/py3status/backup/glpi.py | 52 +++++++++++ .i3/py3status/backup/i3bar_click_events.py | 127 ++++++++++++++++++++++++++ .i3/py3status/backup/netdata.py | 132 +++++++++++++++++++++++++++ .i3/py3status/backup/ns_checker.py | 57 ++++++++++++ .i3/py3status/backup/pingdom.py | 59 +++++++++++++ .i3/py3status/backup/pomodoro.py | 123 ++++++++++++++++++++++++++ .i3/py3status/backup/sysdata.py | 137 +++++++++++++++++++++++++++++ .i3/py3status/backup/weather_yahoo.py | 106 ++++++++++++++++++++++ .i3/py3status/backup/whoami.py | 26 ++++++ 11 files changed, 904 insertions(+) create mode 100644 .i3/py3status/backup/dpms.py create mode 100644 .i3/py3status/backup/empty_class.py create mode 100644 .i3/py3status/backup/glpi.py create mode 100644 .i3/py3status/backup/i3bar_click_events.py create mode 100644 .i3/py3status/backup/netdata.py create mode 100644 .i3/py3status/backup/ns_checker.py create mode 100644 .i3/py3status/backup/pingdom.py create mode 100644 .i3/py3status/backup/pomodoro.py create mode 100644 .i3/py3status/backup/sysdata.py create mode 100644 .i3/py3status/backup/weather_yahoo.py create mode 100644 .i3/py3status/backup/whoami.py (limited to '.i3/py3status/backup') diff --git a/.i3/py3status/backup/dpms.py b/.i3/py3status/backup/dpms.py new file mode 100644 index 0000000..783c53c --- /dev/null +++ b/.i3/py3status/backup/dpms.py @@ -0,0 +1,44 @@ +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/.i3/py3status/backup/empty_class.py b/.i3/py3status/backup/empty_class.py new file mode 100644 index 0000000..077269c --- /dev/null +++ b/.i3/py3status/backup/empty_class.py @@ -0,0 +1,41 @@ +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/.i3/py3status/backup/glpi.py b/.i3/py3status/backup/glpi.py new file mode 100644 index 0000000..929749d --- /dev/null +++ b/.i3/py3status/backup/glpi.py @@ -0,0 +1,52 @@ +# 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/.i3/py3status/backup/i3bar_click_events.py b/.i3/py3status/backup/i3bar_click_events.py new file mode 100644 index 0000000..792965c --- /dev/null +++ b/.i3/py3status/backup/i3bar_click_events.py @@ -0,0 +1,127 @@ +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 = { + "": { +