Fix the tmux detection of the screen_detach plugin
This commit is contained in:
parent
889eea463d
commit
0975b343f0
1 changed files with 11 additions and 6 deletions
|
@ -27,10 +27,10 @@ import pyinotify
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
DEFAULT_CONFIG = {
|
DEFAULT_CONFIG = {
|
||||||
'screen_detach': {
|
'screen_detach': {
|
||||||
'use_tmux': True,
|
'use_tmux': True,
|
||||||
'use_screen': True
|
'use_screen': True
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ DEFAULT_CONFIG = {
|
||||||
# is configured
|
# is configured
|
||||||
try:
|
try:
|
||||||
LOGIN = os.getlogin()
|
LOGIN = os.getlogin()
|
||||||
LOGIN_TMUX = LOGIN
|
LOGIN_TMUX = os.getuid()
|
||||||
except Exception:
|
except Exception:
|
||||||
LOGIN = os.getenv('USER')
|
LOGIN = os.getenv('USER')
|
||||||
LOGIN_TMUX = os.getuid()
|
LOGIN_TMUX = os.getuid()
|
||||||
|
@ -47,6 +47,8 @@ SCREEN_DIR = '/var/run/screens/S-%s' % LOGIN
|
||||||
TMUX_DIR = '/tmp/tmux-%s' % LOGIN_TMUX
|
TMUX_DIR = '/tmp/tmux-%s' % LOGIN_TMUX
|
||||||
|
|
||||||
def find_screen(path):
|
def find_screen(path):
|
||||||
|
if not os.path.isdir(path):
|
||||||
|
return
|
||||||
for f in os.listdir(path):
|
for f in os.listdir(path):
|
||||||
path = os.path.join(path, f)
|
path = os.path.join(path, f)
|
||||||
if screen_attached(path):
|
if screen_attached(path):
|
||||||
|
@ -73,6 +75,10 @@ class Plugin(BasePlugin, pyinotify.Notifier):
|
||||||
wm.add_watch(sock_path, pyinotify.EventsCodes.ALL_FLAGS['IN_ATTRIB'])
|
wm.add_watch(sock_path, pyinotify.EventsCodes.ALL_FLAGS['IN_ATTRIB'])
|
||||||
pyinotify.Notifier.__init__(self, wm, default_proc_fun=HandleScreen(plugin=self))
|
pyinotify.Notifier.__init__(self, wm, default_proc_fun=HandleScreen(plugin=self))
|
||||||
asyncio.get_event_loop().add_reader(self._fd, self.process)
|
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):
|
def process(self):
|
||||||
self.read_events()
|
self.read_events()
|
||||||
|
@ -88,7 +94,6 @@ class Plugin(BasePlugin, pyinotify.Notifier):
|
||||||
status = 'available' if self.attached else 'away'
|
status = 'available' if self.attached else 'away'
|
||||||
self.core.command_status(status)
|
self.core.command_status(status)
|
||||||
|
|
||||||
|
|
||||||
class HandleScreen(pyinotify.ProcessEvent):
|
class HandleScreen(pyinotify.ProcessEvent):
|
||||||
def my_init(self, **kwargs):
|
def my_init(self, **kwargs):
|
||||||
self.plugin = kwargs['plugin']
|
self.plugin = kwargs['plugin']
|
||||||
|
|
Loading…
Reference in a new issue