summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTjaart van der Walt <github@tjaart.co.za>2015-05-13 17:34:30 -0500
committerTjaart van der Walt <github@tjaart.co.za>2015-05-13 17:34:30 -0500
commit295d070044d8fecf579156d7e4f28eee72423532 (patch)
treed8efffe4e8566ce08a1aea7b739df44229d39e60
parentbfb86596dfce05501ddd4f5d66def9a6fdf29206 (diff)
added dropbox.py
-rw-r--r--py3status/modules/dropbox.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/py3status/modules/dropbox.py b/py3status/modules/dropbox.py
new file mode 100644
index 0000000..1cd1532
--- /dev/null
+++ b/py3status/modules/dropbox.py
@@ -0,0 +1,47 @@
+# -*- coding: utf-8 -*-
+"""
+Display your dropbox status.
+
+Configuration parameters:
+ - format : Prefix text for the dropbox status
+
+Requires:
+ - the 'dropbox-cli' command
+
+@author Tjaart van der Walt (github:tjaartvdwalt)
+@license GNU GPL http://www.gnu.org/licenses/gpl.html
+"""
+import subprocess
+
+
+class Py3status:
+ format = "Dropbox: {}"
+
+ def dropbox(self, i3status_output_json, i3status_config):
+ response = {}
+
+ lines = subprocess.check_output(["dropbox-cli", "status"]).decode(
+ "utf-8").split("\n")
+ status = lines[0]
+ full_text = self.format.format(str(status))
+ response['full_text'] = full_text
+
+ if (status == "Dropbox isn't running!"):
+ response.update({'color': i3status_config['color_bad']})
+ elif (status == "Up to date"):
+ response.update({'color': i3status_config['color_good']})
+ else:
+ response.update({'color': i3status_config['color_degraded']})
+ return response
+
+if __name__ == "__main__":
+ from time import sleep
+ x = Py3status()
+ config = {
+ 'color_bad': '#FF0000',
+ 'color_degraded': '#FFFF00',
+ 'color_good': '#00FF00'
+ }
+ while True:
+ print(x.dropbox([], config))
+ sleep(1)