diff options
author | mathieui <mathieui@mathieui.net> | 2015-01-19 13:35:49 +0100 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2015-01-19 13:35:49 +0100 |
commit | 0975b343f06e504579455985e1e6ab4947b0cd4c (patch) | |
tree | 6e505535d4a42522f7015c39c2f122e5739dd789 | |
parent | 889eea463dfccf719350480de58430df430b06b4 (diff) | |
download | poezio-0975b343f06e504579455985e1e6ab4947b0cd4c.tar.gz poezio-0975b343f06e504579455985e1e6ab4947b0cd4c.tar.bz2 poezio-0975b343f06e504579455985e1e6ab4947b0cd4c.tar.xz poezio-0975b343f06e504579455985e1e6ab4947b0cd4c.zip |
Fix the tmux detection of the screen_detach plugin
-rw-r--r-- | plugins/screen_detach.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/plugins/screen_detach.py b/plugins/screen_detach.py index 513e19c6..2b42d01a 100644 --- a/plugins/screen_detach.py +++ b/plugins/screen_detach.py @@ -27,10 +27,10 @@ import pyinotify import asyncio DEFAULT_CONFIG = { - 'screen_detach': { - 'use_tmux': True, - 'use_screen': True - } + 'screen_detach': { + 'use_tmux': True, + 'use_screen': True + } } @@ -38,7 +38,7 @@ DEFAULT_CONFIG = { # is configured try: LOGIN = os.getlogin() - LOGIN_TMUX = LOGIN + LOGIN_TMUX = os.getuid() except Exception: LOGIN = os.getenv('USER') LOGIN_TMUX = os.getuid() @@ -47,6 +47,8 @@ SCREEN_DIR = '/var/run/screens/S-%s' % LOGIN TMUX_DIR = '/tmp/tmux-%s' % LOGIN_TMUX def find_screen(path): + if not os.path.isdir(path): + return for f in os.listdir(path): path = os.path.join(path, f) if screen_attached(path): @@ -73,6 +75,10 @@ class Plugin(BasePlugin, pyinotify.Notifier): wm.add_watch(sock_path, pyinotify.EventsCodes.ALL_FLAGS['IN_ATTRIB']) pyinotify.Notifier.__init__(self, wm, default_proc_fun=HandleScreen(plugin=self)) asyncio.get_event_loop().add_reader(self._fd, self.process) + else: + self.api.information('screen_detach plugin: No tmux or screen found', + 'Warning') + self.attached = False def process(self): self.read_events() @@ -88,7 +94,6 @@ class Plugin(BasePlugin, pyinotify.Notifier): status = 'available' if self.attached else 'away' self.core.command_status(status) - class HandleScreen(pyinotify.ProcessEvent): def my_init(self, **kwargs): self.plugin = kwargs['plugin'] |