summaryrefslogtreecommitdiff
path: root/plugins/screen_detach.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2018-08-15 13:13:17 +0200
committermathieui <mathieui@mathieui.net>2018-08-15 13:13:17 +0200
commit6e13b8b73572f9c0ac9b5c683b98a475afbeab38 (patch)
tree7dae86588339a8cf144b2d98c9280f28646341a9 /plugins/screen_detach.py
parentd1b624753bb5371cf287cc9d86bb685593a99315 (diff)
downloadpoezio-6e13b8b73572f9c0ac9b5c683b98a475afbeab38.tar.gz
poezio-6e13b8b73572f9c0ac9b5c683b98a475afbeab38.tar.bz2
poezio-6e13b8b73572f9c0ac9b5c683b98a475afbeab38.tar.xz
poezio-6e13b8b73572f9c0ac9b5c683b98a475afbeab38.zip
yapf -rip on plugins
Diffstat (limited to 'plugins/screen_detach.py')
-rw-r--r--plugins/screen_detach.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/plugins/screen_detach.py b/plugins/screen_detach.py
index 8a00d90f..0a2514c4 100644
--- a/plugins/screen_detach.py
+++ b/plugins/screen_detach.py
@@ -40,7 +40,6 @@ DEFAULT_CONFIG = {
}
}
-
# overload if this is not how your stuff
# is configured
try:
@@ -53,6 +52,7 @@ except Exception:
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
@@ -61,9 +61,11 @@ def find_screen(path):
if screen_attached(path):
return path
+
def screen_attached(socket):
return (os.stat(socket).st_mode & stat.S_IXUSR) != 0
+
class Plugin(BasePlugin, pyinotify.Notifier):
default_config = DEFAULT_CONFIG
@@ -79,12 +81,14 @@ class Plugin(BasePlugin, pyinotify.Notifier):
if sock_path:
self.attached = True
wm = pyinotify.WatchManager()
- wm.add_watch(sock_path, pyinotify.EventsCodes.ALL_FLAGS['IN_ATTRIB'])
- pyinotify.Notifier.__init__(self, wm, default_proc_fun=HandleScreen(plugin=self))
+ 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.api.information(
+ 'screen_detach plugin: No tmux or screen found', 'Warning')
self.attached = False
def process(self):
@@ -106,6 +110,7 @@ class Plugin(BasePlugin, pyinotify.Notifier):
else:
self.core.xmpp.plugin['xep_0352'].send_inactive()
+
class HandleScreen(pyinotify.ProcessEvent):
def my_init(self, **kwargs):
self.plugin = kwargs['plugin']