From 0975b343f06e504579455985e1e6ab4947b0cd4c Mon Sep 17 00:00:00 2001 From: mathieui Date: Mon, 19 Jan 2015 13:35:49 +0100 Subject: Fix the tmux detection of the screen_detach plugin --- plugins/screen_detach.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'plugins') 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'] -- cgit v1.2.3