summaryrefslogtreecommitdiffstats
path: root/py3status/modules
diff options
context:
space:
mode:
Diffstat (limited to 'py3status/modules')
-rw-r--r--py3status/modules/README.md90
-rw-r--r--py3status/modules/aws_bill.py10
-rw-r--r--py3status/modules/dpms.py30
-rw-r--r--py3status/modules/imap.py16
-rw-r--r--py3status/modules/netdata.py4
-rw-r--r--py3status/modules/volume_status.py147
6 files changed, 260 insertions, 37 deletions
diff --git a/py3status/modules/README.md b/py3status/modules/README.md
index 1c8be5f..e9e73fd 100644
--- a/py3status/modules/README.md
+++ b/py3status/modules/README.md
@@ -18,6 +18,9 @@ Available modules:
Follow this article to activate this feature:
http://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/detailed-billing-reports.html
+ Format of status string placeholders:
+ {bill_amount} - AWS bill amount
+
Requires:
- boto
@@ -79,35 +82,40 @@ Available modules:
@author Francois LASSERRE <choiz@me.com>
@license GNU GPL http://www.gnu.org/licenses/gpl.html
---
- counter Display days/hours/minutes spent and calculated the price of your service for you.
-
- Configuration parameters:
- - config_file: file path to store the time already spent and restore it the next session.
- - tax : tax value (1.02 = 2%)
- - hour_price : your price per hour
-
- @author Amaury Brisou <py3status AT puzzledge.org>
- ---
dpms Activate or deactivate DPMS and screen blanking.
This module allows activation and deactivation
of DPMS (Display Power Management Signaling)
by clicking on 'DPMS' in the status bar.
+ Configuration parameters:
+ - format_off: string to display when DPMS is disabled
+ - format_on: string to display when DPMS is enabled
+
@author Andre Doser <dosera AT tf.uni-freiburg.de>
---
external_script Display output of given script.
-
- Display output of any executable script set by script_path
- Pay attention. The output must be one liner, or will break your i3status
- The script should not have any parameters, but it could work
+ Display output of any executable script set by 'script_path'.
+ Pay attention. The output must be one liner, or will break your i3status !
+ The script should not have any parameters, but it could work.
Configuration parameters:
- cache_timeout : how often we refresh this module in seconds
- color : color of printed text
+ - format : see placeholders below
- script_path : script you want to show output of (compulsory)
+ Format of status string placeholders:
+ {output} - output of script given by "script_path"
+
+ i3status.conf example:
+
+ external_script {
+ color = "#00FF00"
+ format = "my name is {output}"
+ script_path = "/usr/bin/whoami"
+
@author frimdo ztracenastopa@centrum.cz
---
glpi Display the total number of open tickets from GLPI.
@@ -128,19 +136,25 @@ Available modules:
Configuration parameters:
- cache_timeout : how often to run this check
- criterion : status of emails to check for
+ - format : format to display
- hide_if_zero : don't show on bar if 0
- imap_server : IMAP server to connect to
- mailbox : name of the mailbox to check
- - name : format to display
- new_mail_color : what color to output on new mail
- password : login password
- port : IMAP server port
- user : login user
+ Format of status string placeholders:
+ {unseen} - number of unread emails
+
@author obb
---
keyboard_layout Display the current keyboard layout.
+ Configuration parameters:
+ - cache_timeout: check for keyboard layout change every seconds
+
Requires:
- xkblayout-state
or
@@ -196,7 +210,7 @@ Available modules:
netdata Display network speed and bandwidth usage.
Configuration parameters:
- - cache_timeout : 0 by default, you usually want continuous monitoring
+ - cache_timeout : how often we refresh this module in seconds (2s default)
- low_* / med_* : coloration thresholds
- nic : the network interface to monitor (defaults to eth0)
@@ -360,7 +374,7 @@ Available modules:
@author Pierre Guilbert <pierre@1000mercis.com>
---
static_string Display static text.
-
+
Configuration parameters:
- color : color of printed text
- format : text that should be printed
@@ -370,11 +384,22 @@ Available modules:
---
sysdata Display system RAM and CPU utilization.
- NOTE: If you want py3status to show you your CPU temperature,
- change value of CPUTEMP into True in Py3status class - CPUInfo function
- and REMEMBER that you must install lm_sensors if you want CPU temp!
+ Configuration parameters:
+ - format: output format string
+ - high_threshold: percent to consider CPU or RAM usage as 'high load'
+ - med_threshold: percent to consider CPU or RAM usage as 'medium load'
- @author Shahin Azad <ishahinism at Gmail>
+ Format of status string placeholders:
+ {cpu_temp} - cpu temperature
+ {cpu_usage} - cpu usage percentage
+ {mem_total} - total memory
+ {mem_used} - used memory
+ {mem_used_percent} - used memory percentage
+
+ NOTE: If using the {cpu_temp} option, the 'sensors' command should
+ be available, provided by the 'lm-sensors' or 'lm_sensors' package.
+
+ @author Shahin Azad <ishahinism at Gmail>, shrimpza
---
vnstat Display vnstat statistics.
@@ -399,6 +424,31 @@ Available modules:
@author shadowprince
@license Eclipse Public License
---
+ volume_status Display current sound volume using amixer.
+
+ Expands on the standard i3status volume module by adding color
+ and percentage threshold settings.
+
+ Configuration parameters:
+ - cache_timeout : how often we refresh this module in seconds (10s default)
+ - channel : "Master" by default, alsamixer channel to track
+ - device : "default" by default, alsamixer device to use
+ - format : format the output, available variables: {percentage}
+ - format_muted : format the output when the volume is muted
+ - threshold_bad : 20 by default
+ - threshold_degraded : 50 by default
+
+ Requires:
+ alsa-utils (tested with alsa-utils 1.0.29-1)
+
+ NOTE:
+ If you want to refresh the module quicker than the i3status interval,
+ send a USR1 signal to py3status in the keybinding.
+ Example: killall -s USR1 py3status
+
+ @author <Jan T> <jans.tuomi@gmail.com>
+ @license BSD
+ ---
weather_yahoo Display Yahoo! Weather forecast as icons.
Based on Yahoo! Weather. forecast, thanks guys !
diff --git a/py3status/modules/aws_bill.py b/py3status/modules/aws_bill.py
index 98643f6..5452718 100644
--- a/py3status/modules/aws_bill.py
+++ b/py3status/modules/aws_bill.py
@@ -18,6 +18,9 @@ Configuration parameters:
Follow this article to activate this feature:
http://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/detailed-billing-reports.html
+Format of status string placeholders:
+ {bill_amount} - AWS bill amount
+
Requires:
- boto
@@ -41,6 +44,7 @@ class Py3status:
aws_secret_access_key = ''
billing_file = '/tmp/.aws_billing.csv'
cache_timeout = 3600
+ format = '{bill_amount}$'
s3_bucket_name = ''
def _get_bill_amount(self):
@@ -90,8 +94,8 @@ class Py3status:
def aws_bill(self, i3s_output_list, i3s_config):
response = {
'cached_until': time() + self.cache_timeout,
- 'full_text': '',
- 'color': i3s_config['color_bad']
+ 'color': i3s_config['color_bad'],
+ 'full_text': ''
}
bill_amount = self._get_bill_amount()
@@ -105,7 +109,7 @@ class Py3status:
elif bill_amount == 'conn_error':
response['full_text'] = 'Check your internet access'
elif bill_amount is not False:
- response['full_text'] = str(bill_amount) + '$'
+ response['full_text'] = self.format.format(bill_amount=bill_amount)
response['color'] = i3s_config['color_good']
else:
response['full_text'] = 'Global error - WTF exception'
diff --git a/py3status/modules/dpms.py b/py3status/modules/dpms.py
index ecbc3a7..6a5d881 100644
--- a/py3status/modules/dpms.py
+++ b/py3status/modules/dpms.py
@@ -6,6 +6,10 @@ This module allows activation and deactivation
of DPMS (Display Power Management Signaling)
by clicking on 'DPMS' in the status bar.
+Configuration parameters:
+ - format_off: string to display when DPMS is disabled
+ - format_on: string to display when DPMS is enabled
+
@author Andre Doser <dosera AT tf.uni-freiburg.de>
"""
@@ -15,6 +19,10 @@ from os import system
class Py3status:
"""
"""
+ # available configuration parameters
+ format_off = "DPMS"
+ format_on = "DPMS"
+
def dpms(self, i3s_output_list, i3s_config):
"""
Display a colorful state of DPMS.
@@ -23,13 +31,10 @@ class Py3status:
self.run = system('xset -q | grep -iq "DPMS is enabled"') == 0
response = {
- 'full_text': 'DPMS'
+ 'full_text': self.format_on if self.run else self.format_off,
+ 'color': i3s_config['color_good'] if self.run else i3s_config['color_bad']
}
- if self.run:
- response['color'] = i3s_config['color_good']
- else:
- response['color'] = i3s_config['color_bad']
return response
def on_click(self, i3s_output_list, i3s_config, event):
@@ -43,3 +48,18 @@ class Py3status:
else:
self.run = True
system("xset +dpms;xset s on")
+
+if __name__ == "__main__":
+ """
+ Test this module by calling it directly.
+ """
+ from time import sleep
+ x = Py3status()
+ config = {
+ 'color_bad': '#FF0000',
+ 'color_good': '#00FF00',
+ }
+
+ while True:
+ print(x.dpms([], config))
+ sleep(1)
diff --git a/py3status/modules/imap.py b/py3status/modules/imap.py
index 473c55d..ec1d90e 100644
--- a/py3status/modules/imap.py
+++ b/py3status/modules/imap.py
@@ -5,15 +5,18 @@ Display the unread messages count from your IMAP account.
Configuration parameters:
- cache_timeout : how often to run this check
- criterion : status of emails to check for
+ - format : format to display
- hide_if_zero : don't show on bar if 0
- imap_server : IMAP server to connect to
- mailbox : name of the mailbox to check
- - name : format to display
- new_mail_color : what color to output on new mail
- password : login password
- port : IMAP server port
- user : login user
+Format of status string placeholders:
+ {unseen} - number of unread emails
+
@author obb
"""
@@ -30,7 +33,7 @@ class Py3status:
hide_if_zero = False
imap_server = '<IMAP_SERVER>'
mailbox = 'INBOX'
- name = 'Mail: {unseen}'
+ format = 'Mail: {unseen}'
new_mail_color = ''
password = '<PASSWORD>'
port = '993'
@@ -39,9 +42,7 @@ class Py3status:
def check_mail(self, i3s_output_list, i3s_config):
mail_count = self._get_mail_count()
- response = {
- 'cached_until': time() + self.cache_timeout
- }
+ response = {'cached_until': time() + self.cache_timeout}
if not self.new_mail_color:
self.new_mail_color = i3s_config['color_good']
@@ -50,12 +51,12 @@ class Py3status:
response['full_text'] = mail_count
elif mail_count != 0:
response['color'] = self.new_mail_color
- response['full_text'] = self.name.format(unseen=mail_count)
+ response['full_text'] = self.format.format(unseen=mail_count)
else:
if self.hide_if_zero:
response['full_text'] = ''
else:
- response['full_text'] = self.name.format(unseen=mail_count)
+ response['full_text'] = self.format.format(unseen=mail_count)
return response
@@ -78,6 +79,7 @@ class Py3status:
except:
return 'N/A'
+
if __name__ == "__main__":
"""
Test this module by calling it directly.
diff --git a/py3status/modules/netdata.py b/py3status/modules/netdata.py
index 9e81710..c537dbb 100644
--- a/py3status/modules/netdata.py
+++ b/py3status/modules/netdata.py
@@ -3,7 +3,7 @@
Display network speed and bandwidth usage.
Configuration parameters:
- - cache_timeout : 0 by default, you usually want continuous monitoring
+ - cache_timeout : how often we refresh this module in seconds (2s default)
- low_* / med_* : coloration thresholds
- nic : the network interface to monitor (defaults to eth0)
@@ -52,7 +52,7 @@ class Py3status:
low_traffic = 400
med_speed = 60
med_traffic = 700
- nic = 'wlp2s0'
+ nic = 'eth0'
def __init__(self):
self.old_transmitted = 0
diff --git a/py3status/modules/volume_status.py b/py3status/modules/volume_status.py
new file mode 100644
index 0000000..cddc763
--- /dev/null
+++ b/py3status/modules/volume_status.py
@@ -0,0 +1,147 @@
+# -*- coding: utf-8 -*-
+"""
+Display current sound volume using amixer.
+
+Expands on the standard i3status volume module by adding color
+and percentage threshold settings.
+
+Configuration parameters:
+ - cache_timeout : how often we refresh this module in seconds (10s default)
+ - channel : "Master" by default, alsamixer channel to track
+ - device : "default" by default, alsamixer device to use
+ - format : format the output, available variables: {percentage}
+ - format_muted : format the output when the volume is muted
+ - threshold_bad : 20 by default
+ - threshold_degraded : 50 by default
+
+Requires:
+ alsa-utils (tested with alsa-utils 1.0.29-1)
+
+NOTE:
+ If you want to refresh the module quicker than the i3status interval,
+ send a USR1 signal to py3status in the keybinding.
+ Example: killall -s USR1 py3status
+
+@author <Jan T> <jans.tuomi@gmail.com>
+@license BSD
+"""
+
+import re
+import shlex
+
+from subprocess import check_output
+from time import time
+
+
+class Py3status:
+ """
+ """
+ # available configuration parameters
+ cache_timeout = 10
+ channel = 'Master'
+ device = 'default'
+ format = u'♪: {percentage}%'
+ format_muted = u'♪: muted'
+ threshold_bad = 20
+ threshold_degraded = 50
+
+ # constructor
+ def __init__(self):
+ self.text = ''
+
+ # compares current volume to the thresholds, returns a color code
+ def _perc_to_color(self, i3s_config, string):
+ try:
+ value = int(string)
+ except ValueError:
+ return i3s_config['color_bad']
+
+ if value < self.threshold_bad:
+ return i3s_config['color_bad']
+ elif value < self.threshold_degraded:
+ return i3s_config['color_degraded']
+ else:
+ return i3s_config['color_good']
+
+ # return the format string formatted with available variables
+ def _format_output(self, format, percentage):
+ text = format.format(percentage=percentage)
+ return text
+
+ # return the current channel volume value as a string
+ def _get_percentage(self, output):
+
+ # attempt to find a percentage value in square brackets
+ p = re.compile(r'(?<=\[)\d{1,3}(?=%\])')
+ text = p.search(output).group()
+
+ # check if the parsed value is sane by checking if it's an integer
+ try:
+ int(text)
+ return text
+
+ # if not, show an error message in output
+ except ValueError:
+ return "error: can't parse amixer output."
+
+ # returns True if the channel is muted
+ def _get_muted(self, output):
+ p = re.compile(r'(?<=\[)\w{2,3}(?=\])')
+ text = p.search(output).group()
+
+ # check if the parsed string is either "off" or "on"
+ if text in ['on', 'off']:
+ return text == 'off'
+
+ # if not, return False
+ else:
+ return False
+
+ # this method is ran by py3status
+ # returns a response dict
+ def current_volume(self, i3s_output_list, i3s_config):
+
+ # call amixer
+ output = check_output(shlex.split('amixer -D {} sget {}'.format(
+ self.device, self.channel))).decode('utf-8')
+
+ # get the current percentage value
+ perc = self._get_percentage(output)
+
+ # get info about channel mute status
+ muted = self._get_muted(output)
+
+ # determine the color based on the current volume level
+ color = self._perc_to_color(i3s_config, perc)
+
+ # format the output
+ text = self._format_output(self.format_muted
+ if muted else self.format, perc)
+
+ # if the text has been changed, update the cached text and
+ # set transformed to True
+ transformed = text != self.text
+ self.text = text
+
+ # create response dict
+ response = {
+ 'cached_until': time() + self.cache_timeout,
+ 'color': color,
+ 'full_text': text,
+ 'transformed': transformed
+ }
+ return response
+
+# test if run directly
+if __name__ == "__main__":
+ from time import sleep
+ x = Py3status()
+ config = {
+ 'color_bad': '#FF0000',
+ 'color_degraded': '#FFFF00',
+ 'color_good': '#00FF00'
+ }
+
+ while True:
+ print(x.current_volume([], config))
+ sleep(1)