From 0268e3c3ff6b2235d0ca072c396b2b94ee13710b Mon Sep 17 00:00:00 2001 From: hut Date: Tue, 19 Jan 2010 16:59:37 +0100 Subject: titlebar: red hostname if logged in with root --- TODO | 1 + ranger/colorschemes/default.py | 2 +- ranger/gui/widgets/titlebar.py | 12 +++++++++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/TODO b/TODO index ed420d3c..1f7be5e7 100644 --- a/TODO +++ b/TODO @@ -47,6 +47,7 @@ Bugs (X) #31 10/01/06 ^C breaks cd-after-exit by stopping sourced shell script ( ) #40 10/01/17 freeze with unavailable sshfs (X) #41 10/01/17 capital file extensions are not recognized + ( ) #46 10/01/19 old username displayed after using su Ideas diff --git a/ranger/colorschemes/default.py b/ranger/colorschemes/default.py index 68f1d4a7..1c7f1e1b 100644 --- a/ranger/colorschemes/default.py +++ b/ranger/colorschemes/default.py @@ -72,7 +72,7 @@ class Default(ColorScheme): attr |= bold if context.hostname: - fg = green + fg = context.bad and red or green elif context.directory: fg = blue diff --git a/ranger/gui/widgets/titlebar.py b/ranger/gui/widgets/titlebar.py index b702b3e7..7b557f3d 100644 --- a/ranger/gui/widgets/titlebar.py +++ b/ranger/gui/widgets/titlebar.py @@ -54,10 +54,16 @@ class TitleBar(Widget): def _get_left_part(self, bar): import socket, os + + username = os.getenv('USER') + if logname == 'root': + clr = 'bad' + else: + clr = 'good' - bar.add(os.getenv('LOGNAME'), 'hostname', fixedsize=True) - bar.add('@', 'hostname', fixedsize=True) - bar.add(socket.gethostname(), 'hostname', fixedsize=True) + bar.add(username, 'hostname', clr, fixedsize=True) + bar.add('@', 'hostname', clr, fixedsize=True) + bar.add(socket.gethostname(), 'hostname', clr, fixedsize=True) for path in self.env.pathway: if path.islink: -- cgit 1.4.1-2-gfad0