summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-01-19 16:59:37 +0100
committerhut <hut@lavabit.com>2010-01-19 17:01:38 +0100
commit0268e3c3ff6b2235d0ca072c396b2b94ee13710b (patch)
treefe70b1eea6bea0164551da460807ade981f6ad06
parentffd5e26b420a1f9a0020314cd617459bb1da1898 (diff)
downloadranger-0268e3c3ff6b2235d0ca072c396b2b94ee13710b.tar.gz
titlebar: red hostname if logged in with root
-rw-r--r--TODO1
-rw-r--r--ranger/colorschemes/default.py2
-rw-r--r--ranger/gui/widgets/titlebar.py12
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: