diff options
author | Kevin Velghe <kevin@paretje.be> | 2016-11-02 18:48:33 +0100 |
---|---|---|
committer | nfnty <git@nfnty.se> | 2017-01-29 20:47:14 +0100 |
commit | f6fca81a9a3ab58f4838cf22fb7fb7d2f3240313 (patch) | |
tree | 9229de8f992c774999669700594433c831a22cf6 | |
parent | 924135e1934a01faef64e94d2425d23f9790b6cf (diff) | |
download | ranger-f6fca81a9a3ab58f4838cf22fb7fb7d2f3240313.tar.gz |
gui.ui: Handle tmux `automatic-rename`
Fixes #228 Fixes #685 Fixes #154
-rw-r--r-- | ranger/gui/ui.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/ranger/gui/ui.py b/ranger/gui/ui.py index 1deacc89..6a2f3c6c 100644 --- a/ranger/gui/ui.py +++ b/ranger/gui/ui.py @@ -7,10 +7,12 @@ import os import sys import threading import curses +from subprocess import CalledProcessError from ranger.ext.keybinding_parser import KeyBuffer, KeyMaps, ALT_KEY from ranger.ext.lazy_property import lazy_property from ranger.ext.signals import Signal +from ranger.ext.spawn import check_output from .displayable import DisplayableContainer from .mouse_event import MouseEvent @@ -63,6 +65,7 @@ class UI( # pylint: disable=too-many-instance-attributes,too-many-public-method self.console = None self.pager = None self._draw_title = None + self._tmux_automatic_rename = None self.browser = None if fm is not None: @@ -108,6 +111,14 @@ class UI( # pylint: disable=too-many-instance-attributes,too-many-public-method self.win.refresh() self._draw_title = curses.tigetflag('hs') # has_status_line + # Save tmux setting `automatic-rename` + if self.settings.update_tmux_title: + try: + self._tmux_automatic_rename = check_output( + ['tmux', 'show-window-options', '-v', 'automatic-rename']).strip() + except CalledProcessError: + self._tmux_automatic_rename = None + self.update_size() self.is_on = True @@ -154,6 +165,21 @@ class UI( # pylint: disable=too-many-instance-attributes,too-many-public-method def destroy(self): """Destroy all widgets and turn off curses""" DisplayableContainer.destroy(self) + + # Restore tmux setting `automatic-rename` + if self.settings.update_tmux_title: + if self._tmux_automatic_rename: + try: + check_output(['tmux', 'set-window-option', + 'automatic-rename', self._tmux_automatic_rename]) + except CalledProcessError: + pass + else: + try: + check_output(['tmux', 'set-window-option', '-u', 'automatic-rename']) + except CalledProcessError: + pass + self.suspend() def handle_mouse(self): |