about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--doc/ranger.13
-rw-r--r--doc/ranger.pod4
-rw-r--r--examples/rc_emacs.conf3
-rw-r--r--ranger/config/rc.conf3
-rw-r--r--ranger/container/settings.py1
-rw-r--r--ranger/gui/ui.py31
6 files changed, 37 insertions, 8 deletions
diff --git a/doc/ranger.1 b/doc/ranger.1
index 3521d762..a6e20b4c 100644
--- a/doc/ranger.1
+++ b/doc/ranger.1
@@ -1106,6 +1106,9 @@ Requires the python-bidi pip package.
 .IP "update_title [bool]" 4
 .IX Item "update_title [bool]"
 Set a window title?
+.IP "update_icon_title [bool]" 4
+.IX Item "update_icon_title [bool]"
+Set an icon title?
 .IP "update_tmux_title [bool]" 4
 .IX Item "update_tmux_title [bool]"
 Set the title to \*(L"ranger\*(R" in the tmux program?
diff --git a/doc/ranger.pod b/doc/ranger.pod
index be964b37..852afcdc 100644
--- a/doc/ranger.pod
+++ b/doc/ranger.pod
@@ -1150,6 +1150,10 @@ Requires the python-bidi pip package.
 
 Set a window title?
 
+=item update_icon_title [bool]
+
+Set an icon title?
+
 =item update_tmux_title [bool]
 
 Set the title to "ranger" in the tmux program?
diff --git a/examples/rc_emacs.conf b/examples/rc_emacs.conf
index a69d68fe..ba8eaaeb 100644
--- a/examples/rc_emacs.conf
+++ b/examples/rc_emacs.conf
@@ -134,6 +134,9 @@ set display_tags_in_all_columns true
 # Set a title for the window?
 set update_title false
 
+# Set a title for the icon?
+set update_icon_title false
+
 # Set the title to "ranger" in the tmux program?
 set update_tmux_title true
 
diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf
index e557d4de..23601fb6 100644
--- a/ranger/config/rc.conf
+++ b/ranger/config/rc.conf
@@ -182,6 +182,9 @@ set display_tags_in_all_columns true
 # Set a title for the window?
 set update_title false
 
+# Set a title for the icon?
+set update_icon_title false
+
 # Set the title to "ranger" in the tmux program?
 set update_tmux_title true
 
diff --git a/ranger/container/settings.py b/ranger/container/settings.py
index 6fc2da5e..5f0c528b 100644
--- a/ranger/container/settings.py
+++ b/ranger/container/settings.py
@@ -87,6 +87,7 @@ ALLOWED_SETTINGS = {
     'tilde_in_titlebar': bool,
     'unicode_ellipsis': bool,
     'update_title': bool,
+    'update_icon_title': bool,
     'update_tmux_title': bool,
     'use_preview_script': bool,
     'vcs_aware': bool,
diff --git a/ranger/gui/ui.py b/ranger/gui/ui.py
index 2874ee97..38065182 100644
--- a/ranger/gui/ui.py
+++ b/ranger/gui/ui.py
@@ -20,6 +20,11 @@ from .mouse_event import MouseEvent
 
 MOUSEMASK = curses.ALL_MOUSE_EVENTS | curses.REPORT_MOUSE_POSITION
 
+# This escape is not available with a capname from terminfo unlike
+# tsl (to_status_line), so it's hardcoded here. It's used just like tsl,
+# but it sets the icon title instead of the window title.
+ESCAPE_ICON_TITLE = '\033]1;'
+
 _ASCII = ''.join(chr(c) for c in range(32, 127))
 
 
@@ -368,7 +373,9 @@ class UI(  # pylint: disable=too-many-instance-attributes,too-many-public-method
         """Draw all objects in the container"""
         self.win.touchwin()
         DisplayableContainer.draw(self)
-        if self._draw_title and self.settings.update_title:
+        if self._draw_title \
+            and (self.settings.update_title
+                 or self.settings.update_icon_title):
             cwd = self.fm.thisdir.path
             if self.settings.tilde_in_titlebar \
                and (cwd == self.fm.home_path
@@ -381,16 +388,24 @@ class UI(  # pylint: disable=too-many-instance-attributes,too-many-public-method
             try:
                 fixed_cwd = cwd.encode('utf-8', 'surrogateescape'). \
                     decode('utf-8', 'replace')
-                fmt_tup = (
-                    curses.tigetstr('tsl').decode('latin-1'),
-                    fixed_cwd,
-                    curses.tigetstr('fsl').decode('latin-1'),
-                )
+                escapes = [
+                    (
+                        curses.tigetstr('tsl').decode('latin-1'),
+                        self.settings.update_title,
+                    ),
+                    (
+                        ESCAPE_ICON_TITLE,
+                        self.settings.update_icon_title,
+                    ),
+                ]
+                bel = curses.tigetstr('fsl').decode('latin-1')
+                fmt_tups = [(e, fixed_cwd, bel) for e, s in escapes if s]
             except UnicodeError:
                 pass
             else:
-                sys.stdout.write("%sranger:%s%s" % fmt_tup)
-                sys.stdout.flush()
+                for fmt_tup in fmt_tups:
+                    sys.stdout.write("%sranger:%s%s" % fmt_tup)
+                    sys.stdout.flush()
 
         self.win.refresh()