summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.rst2
-rw-r--r--doc/example_module.py4
-rw-r--r--py3status/modules/README.md23
-rw-r--r--py3status/modules/aws_bill.py10
-rw-r--r--py3status/modules/dpms.py30
-rw-r--r--py3status/modules/external_script.py68
-rw-r--r--py3status/modules/imap.py16
-rw-r--r--py3status/modules/netdata.py2
-rw-r--r--py3status/modules/pomodoro.py6
-rw-r--r--py3status/modules/static_string.py40
10 files changed, 179 insertions, 22 deletions
diff --git a/README.rst b/README.rst
index 62ef440..d24eed6 100644
--- a/README.rst
+++ b/README.rst
@@ -3,7 +3,7 @@ py3status
*********
|version|
-.. |version| image:: https://pypip.in/version/py3status/badge.png
+.. |version| image:: https://img.shields.io/pypi/v/py3status.svg
**py3status** is an extensible i3status wrapper written in python.
diff --git a/doc/example_module.py b/doc/example_module.py
index d132eed..6a952a1 100644
--- a/doc/example_module.py
+++ b/doc/example_module.py
@@ -51,7 +51,7 @@ from time import time
class Py3status:
"""
- The Py3status class name is mendatory.
+ The Py3status class name is mandatory.
Below you list all the available configuration parameters and their
default value for your module which can be overwritten by users
@@ -121,5 +121,5 @@ if __name__ == "__main__":
'color_good': '#00FF00'
}
while True:
- print(x.empty([], config))
+ print(x.example_method([], config))
sleep(1)
diff --git a/py3status/modules/README.md b/py3status/modules/README.md
index 2b62105..1c8be5f 100644
--- a/py3status/modules/README.md
+++ b/py3status/modules/README.md
@@ -96,6 +96,20 @@ Available modules:
@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
+
+ Configuration parameters:
+ - cache_timeout : how often we refresh this module in seconds
+ - color : color of printed text
+ - script_path : script you want to show output of (compulsory)
+
+ @author frimdo ztracenastopa@centrum.cz
+ ---
glpi Display the total number of open tickets from GLPI.
Configuration parameters:
@@ -345,6 +359,15 @@ 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
+ - separator : whether the separator is shown or not (true or false)
+
+ @author frimdo ztracenastopa@centrum.cz
+ ---
sysdata Display system RAM and CPU utilization.
NOTE: If you want py3status to show you your CPU temperature,
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/external_script.py b/py3status/modules/external_script.py
new file mode 100644
index 0000000..4b3f2e8
--- /dev/null
+++ b/py3status/modules/external_script.py
@@ -0,0 +1,68 @@
+# -*- coding: utf-8 -*-
+"""
+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.
+
+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
+"""
+
+import subprocess
+from time import time
+
+
+class Py3status:
+ """
+ """
+ # available configuration parameters
+ cache_timeout = 15
+ color = None
+ format = '{output}'
+ script_path = None
+
+ def external_script(self, i3s_output_list, i3s_config):
+ if self.script_path:
+ return_value = subprocess.check_output(self.script_path,
+ shell=True,
+ universal_newlines=True)
+ response = {
+ 'cached_until': time() + self.cache_timeout,
+ 'color': self.color,
+ 'full_text': self.format.format(output=return_value.rstrip())
+ }
+ else:
+ response = {
+ 'cached_until': time() + self.cache_timeout,
+ 'full_text': ''
+ }
+ return response
+
+
+if __name__ == "__main__":
+ from time import sleep
+ x = Py3status()
+ config = {
+ 'color_good': '#00FF00',
+ 'color_bad': '#FF0000',
+ }
+ while True:
+ print(x.external_script([], 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..75495ea 100644
--- a/py3status/modules/netdata.py
+++ b/py3status/modules/netdata.py
@@ -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/pomodoro.py b/py3status/modules/pomodoro.py
index 25149a7..02b0be3 100644
--- a/py3status/modules/pomodoro.py
+++ b/py3status/modules/pomodoro.py
@@ -106,14 +106,14 @@ class Py3status:
bar += PROGRESS_BAR_ITEMS[selector]
bar_val -= 1
- bar = bar.ljust(self.num_progress_bars).encode('utf_8')
+ bar = bar.ljust(self.num_progress_bars)
else:
bar = self.timer
if self.run:
- text = '{} [{}]'.format(self.prefix, bar)
+ text = u'{} [{}]'.format(self.prefix, bar)
else:
- text = '{} ({})'.format(self.prefix, bar)
+ text = u'{} ({})'.format(self.prefix, bar)
return dict(full_text=text)
diff --git a/py3status/modules/static_string.py b/py3status/modules/static_string.py
new file mode 100644
index 0000000..bb12ec2
--- /dev/null
+++ b/py3status/modules/static_string.py
@@ -0,0 +1,40 @@
+# -*- coding: utf-8 -*-
+"""
+Display static text.
+
+Configuration parameters:
+ - color : color of printed text
+ - format : text that should be printed
+ - separator : whether the separator is shown or not (true or false)
+
+@author frimdo ztracenastopa@centrum.cz
+"""
+
+from time import time
+
+
+class Py3status:
+ """
+ """
+ # available configuration parameters
+ color = None
+ format = ''
+ separator = True
+
+ def static_string(self, i3s_output_list, i3s_config):
+ response = {
+ 'cached_until': time() + 60,
+ 'color': self.color,
+ 'full_text': self.format,
+ 'separator': self.separator
+ }
+ return response
+
+
+if __name__ == "__main__":
+ x = Py3status()
+ config = {
+ 'color_good': '#00FF00',
+ 'color_bad': '#FF0000',
+ }
+ print(x.static_string([], config))