[PATCH][Fwd: Re: Xterm window title enhancement to hostname:/path II.]



Hello mc-devel,

I haven't noticed any objection against this patch and many people
consider it helpful. Any chance to see it committed?

Thanks,
Jindrich

-- 
Jindrich Novy <jnovy redhat com>, http://people.redhat.com/jnovy/

The worst evil in the world is refusal to think.
--- Begin Message ---
Hello Pavel,

here is the patch where both hostname and username are printed in the
xterm window title.

Cheers,
Jindrich

-- 
Jindrich Novy <jnovy redhat com>, http://people.redhat.com/jnovy/
--- mc-4.6.1a/src/main.c.hostname	2005-03-23 13:59:31.198747928 +0100
+++ mc-4.6.1a/src/main.c	2005-03-23 16:00:49.135333392 +0100
@@ -32,6 +32,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
+#include <pwd.h>
 
 #include "global.h"
 #include "tty.h"
@@ -1612,9 +1613,22 @@ void
 update_xterm_title_path (void)
 {
     unsigned char *p, *s;
+    char h[64];
+    struct passwd *pw;
 
     if (xterm_flag && xterm_title) {
 	p = s = g_strdup (strip_home_and_password (current_panel->cwd));
+	if ( !gethostname (h, 64) ) {
+		h[63] = '\0'; /* Be sure the hostname is NUL terminated */
+		s = g_strdup_printf ("%s:%s", h, s);
+		g_free (p);
+		p = s;
+	}
+	if ( (pw = getpwuid(getuid())) ) {
+		s = g_strdup_printf ("%s %s", pw->pw_name, s);
+		g_free (p);
+		p = s;
+	}
 	do {
 	    if (*s < ' ')
 		*s = '?';
_______________________________________________
Mc-devel mailing list
http://mail.gnome.org/mailman/listinfo/mc-devel

--- End Message ---


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]