From 57f0e60174a97bde42599ffcf609356dac9e244b Mon Sep 17 00:00:00 2001 From: philipdexter Date: Tue, 12 Mar 2013 10:18:59 -0400 Subject: [PATCH 1/5] fixed installation github url --- README.md | 3 +-- README.tpl.md | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b755bd4..2d46c94 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ For examples how it works, take a look at the __main__.py.dist file with some ex To install it, follow these steps: cd ~/.config/i3status/ - git clone git@github.com:janoliver/i3pystatus contrib + git clone git@github.com:enkore/i3pystatus contrib cd contrib/i3pystatus cp __main__.py.dist __main__.py @@ -371,4 +371,3 @@ a python class that can be registered with the `I3statusHandler` class. Also don forget to add yourself to the LICENSE file. **Patches and pull requests are very welcome :-)** - diff --git a/README.tpl.md b/README.tpl.md index d742d69..dbce4fc 100644 --- a/README.tpl.md +++ b/README.tpl.md @@ -14,7 +14,7 @@ For examples how it works, take a look at the __main__.py.dist file with some ex To install it, follow these steps: cd ~/.config/i3status/ - git clone git@github.com:janoliver/i3pystatus contrib + git clone git@github.com:enkore/i3pystatus contrib cd contrib/i3pystatus cp __main__.py.dist __main__.py From 68e93008703c7d0aaf55b49f501389eb55c926fc Mon Sep 17 00:00:00 2001 From: philipdexter Date: Tue, 12 Mar 2013 11:52:18 -0400 Subject: [PATCH 2/5] changed default port in imap to 993 --- i3pystatus/mail/imap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i3pystatus/mail/imap.py b/i3pystatus/mail/imap.py index db15433..154d2cf 100644 --- a/i3pystatus/mail/imap.py +++ b/i3pystatus/mail/imap.py @@ -20,7 +20,7 @@ class IMAP(Backend): ) required = ("host", "username", "password") - port = 143 + port = 993 ssl = False imap_class = imaplib.IMAP4 From 0ff17f4242dc2abdfa7ef61eff4a2b99705c8961 Mon Sep 17 00:00:00 2001 From: philipdexter Date: Tue, 12 Mar 2013 12:17:03 -0400 Subject: [PATCH 3/5] added some debug statements for imap connection --- i3pystatus/mail/imap.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/i3pystatus/mail/imap.py b/i3pystatus/mail/imap.py index 154d2cf..d804192 100644 --- a/i3pystatus/mail/imap.py +++ b/i3pystatus/mail/imap.py @@ -21,7 +21,7 @@ class IMAP(Backend): required = ("host", "username", "password") port = 993 - ssl = False + ssl = True imap_class = imaplib.IMAP4 connection = None @@ -51,3 +51,5 @@ class IMAP(Backend): conn = self.get_connection() if conn: return len(conn.search(None,"UnSeen")[1][0].split()) + else: + sys.stderr.write("no connection") From ecb6c54052e885f5c1bba195ef6b60f4fd3ce6a4 Mon Sep 17 00:00:00 2001 From: philipdexter Date: Fri, 15 Mar 2013 21:20:24 -0400 Subject: [PATCH 4/5] Add the ability to change the position of a module in the i3bar Create a method `move' in modules.py to insert the module's json in a different position than the default 0. --- i3pystatus/core/__init__.py | 4 +++- i3pystatus/core/modules.py | 6 +++++- i3pystatus/core/util.py | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/i3pystatus/core/__init__.py b/i3pystatus/core/__init__.py index 17d6f8b..ccac0b6 100644 --- a/i3pystatus/core/__init__.py +++ b/i3pystatus/core/__init__.py @@ -23,7 +23,9 @@ class Status: """Register a new module.""" if module: - self.modules.append(module, *args, **kwargs) + return self.modules.append(module, *args, **kwargs) + else: + return None def run_command_endpoint(self): for command in io.JSONIO(io=io.IOHandler(sys.stdin, open(os.devnull,"w")), skiplines=1).read(): diff --git a/i3pystatus/core/modules.py b/i3pystatus/core/modules.py index a70de73..f1c1050 100644 --- a/i3pystatus/core/modules.py +++ b/i3pystatus/core/modules.py @@ -10,6 +10,7 @@ __all__ = [ class Module(SettingsBase): output = None + position = 0 def registered(self, status_handler): """Called when this module is registered with a status handler""" @@ -19,7 +20,7 @@ class Module(SettingsBase): if "name" not in self.output: self.output["name"] = self.__name__ self.output["instance"] = str(id(self)) - json.insert(0, self.output) + json.insert(self.position, self.output) def on_click(self, button): if button == 1: # Left mouse button @@ -27,6 +28,9 @@ class Module(SettingsBase): elif button == 3: # Right mouse button self.on_rightclick() + def move(self, position): + self.position = position + def on_leftclick(self): pass diff --git a/i3pystatus/core/util.py b/i3pystatus/core/util.py index 2334ee4..aae8f5f 100644 --- a/i3pystatus/core/util.py +++ b/i3pystatus/core/util.py @@ -46,6 +46,7 @@ class ModuleList(collections.UserList): module = self.finder.instanciate_class_from_module(module, *args, **kwargs) module.registered(self.status_handler) super().append(module) + return module def get_by_id(self, find_id): find_id = int(find_id) From 60c475d6e6840cc7ca2bdf9ee6daab475325c097 Mon Sep 17 00:00:00 2001 From: philipdexter Date: Fri, 15 Mar 2013 21:34:45 -0400 Subject: [PATCH 5/5] Add the option of specifying python-ish negative array indices to the move method --- i3pystatus/core/modules.py | 3 ++- i3pystatus/core/util.py | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/i3pystatus/core/modules.py b/i3pystatus/core/modules.py index f1c1050..926d91d 100644 --- a/i3pystatus/core/modules.py +++ b/i3pystatus/core/modules.py @@ -3,6 +3,7 @@ import time from .settings import SettingsBase from .threading import Manager +from .util import convert_position __all__ = [ "Module", "AsyncModule", "IntervalModule", @@ -20,7 +21,7 @@ class Module(SettingsBase): if "name" not in self.output: self.output["name"] = self.__name__ self.output["instance"] = str(id(self)) - json.insert(self.position, self.output) + json.insert(convert_position(self.position, json), self.output) def on_click(self, button): if button == 1: # Left mouse button diff --git a/i3pystatus/core/util.py b/i3pystatus/core/util.py index aae8f5f..26b1a0f 100644 --- a/i3pystatus/core/util.py +++ b/i3pystatus/core/util.py @@ -95,3 +95,8 @@ class KeyConstraintDict(collections.UserDict): def missing(self): return self.required_keys - (self.seen_keys & self.required_keys) + +def convert_position(pos, json): + if pos < 0: + pos = len(json) + (pos+1) + return pos