From 5769bc36f156a55c0813429419ac8a53ea65260c Mon Sep 17 00:00:00 2001 From: QC Date: Thu, 22 May 2014 10:03:36 +0200 Subject: [PATCH] Make ssh set title public. --- config/config.c | 2 +- doc/rofi.1 | 23 ++++++++++++++++------- include/history.h | 6 +++--- include/rofi.h | 7 +++---- include/textbox.h | 2 +- include/xrmoptions.h | 2 +- source/rofi.c | 15 +++++++++++++++ source/ssh-dialog.c | 2 +- source/xrmoptions.c | 2 ++ 9 files changed, 43 insertions(+), 18 deletions(-) diff --git a/config/config.c b/config/config.c index 83c019d6..7d28c052 100644 --- a/config/config.c +++ b/config/config.c @@ -71,7 +71,7 @@ Settings config = { .hmode = FALSE, // Padding of the window. .padding = 5, - .show_title = 1, + .ssh_set_title = TRUE, .y_offset = 0, .x_offset = 0, .fixed_num_lines = FALSE diff --git a/doc/rofi.1 b/doc/rofi.1 index fdab8c08..34b66918 100644 --- a/doc/rofi.1 +++ b/doc/rofi.1 @@ -1,8 +1,8 @@ -.TH ROFI 1 rofi +.TH ROFI 1 rofi .SH NAME rofi \- a simple EWMH window switcher .SH SYNOPSIS -.B rofi +.B rofi .RB [ \-width .IR pct_scr ] .RB [ \-lines @@ -45,15 +45,18 @@ rofi \- a simple EWMH window switcher .RB [ \-help] .RB [ \-display .IR display ] -.RB [ \-bc +.RB [ \-bc .IR color ] -.RB [ \-bw +.RB [ \-bw .IR width ] -.RB [ \-dmenu +.RB [ \-dmenu .RB [ \-p .IR prompt ] .RB [ \-dump ] +.RB [ \-ssh\-set\-title +true|false +] .SH DESCRIPTION .I rofi @@ -211,12 +214,12 @@ monitor: .B -hmode Switch to horizontal mode (ala dmenu). The number of elements is the number of .IR lines -times the number of +times the number of .IR columns . .TP .B -fixed-num-lines -Keep a fixed number of visible lines (See the +Keep a fixed number of visible lines (See the .IR -lines option.) .TP @@ -234,6 +237,12 @@ Run rofi in dmenu mode. Allowing it to be used for user interaction in scripts. .TP .B -dump Dump the current active configuration to the command-line. +.RE +.TP +.B -ssh-set-title true|false +SSH dialogs tries to set 'ssh ' of the spawned terminal. +Not all terminals support this. +Default value is true. .RS .SH Switch between modi Type '?' to switch between window list, run and ssh mode. diff --git a/include/history.h b/include/history.h index 6d3ae7a2..5a1c87ea 100644 --- a/include/history.h +++ b/include/history.h @@ -39,7 +39,7 @@ void history_set ( const char *filename, const char *entry ); /** * @param filename The filename of the history cache. - * @param entry The entry to remove + * @param entry The entry to remove * * Removes the entry from the history. */ @@ -48,12 +48,12 @@ void history_remove ( const char *filename, const char *entry ); /** * @param filename The filename of the history cache. - * @param length The length of the returned list. + * @param length The length of the returned list. * * Gets the entries in the list (in order of usage) * @returns a list of entries length long. (and NULL terminated). */ -char ** history_get_list ( const char *filename, unsigned int * length); +char ** history_get_list ( const char *filename, unsigned int * length ); diff --git a/include/rofi.h b/include/rofi.h index 81426efd..c9f5782c 100644 --- a/include/rofi.h +++ b/include/rofi.h @@ -10,11 +10,11 @@ #define INTERSECT( x, y, w, h, x1, y1, w1, h1 ) ( OVERLAP ( ( x ), ( w ), ( x1 ), ( w1 ) ) && OVERLAP ( ( y ), ( h ), ( y1 ), ( h1 ) ) ) #ifndef TRUE -#define TRUE 1 +#define TRUE 1 #endif #ifndef FALSE -#define FALSE 0 +#define FALSE 0 #endif extern const char *cache_dir; @@ -94,9 +94,8 @@ typedef struct _Settings int y_offset; int x_offset; - unsigned int show_title; + unsigned int ssh_set_title; unsigned int fixed_num_lines; - } Settings; extern Settings config; diff --git a/include/textbox.h b/include/textbox.h index b9a93b68..4b45ef10 100644 --- a/include/textbox.h +++ b/include/textbox.h @@ -46,6 +46,6 @@ void textbox_draw ( textbox *tb ); int textbox_keypress ( textbox *tb, XEvent *ev ); void textbox_cursor_end ( textbox *tb ); -void textbox_move (textbox *tb, int x, int y); +void textbox_move ( textbox *tb, int x, int y ); void textbox_hide ( textbox *tb ); #endif //__TEXTBOX_H__ diff --git a/include/xrmoptions.h b/include/xrmoptions.h index f8e033fc..5a7a27f5 100644 --- a/include/xrmoptions.h +++ b/include/xrmoptions.h @@ -2,5 +2,5 @@ #define __XRMOPTIONS_H__ void parse_xresource_options ( Display *display ); -void parse_xresource_free( void ); +void parse_xresource_free ( void ); #endif diff --git a/source/rofi.c b/source/rofi.c index 605b8952..a4217d6c 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -1926,6 +1926,20 @@ static void parse_cmd_options ( int argc, char ** argv ) config.hmode = TRUE; } + if ( find_arg ( argc, argv, "-ssh-set-title" ) >= 0 ) + { + char *value; + find_arg_str ( argc, argv, "-ssh-set-title", &value ); + if ( strcasecmp ( value, "true" ) == 0 ) + { + config.ssh_set_title = TRUE; + } + else + { + config.ssh_set_title = FALSE; + } + } + // Keybindings find_arg_str ( argc, argv, "-key", &( config.window_key ) ); find_arg_str ( argc, argv, "-rkey", &( config.run_key ) ); @@ -2057,6 +2071,7 @@ void config_print ( void ) /* Terminal */ printf ( "Terminal emulator: %22s\n", config.terminal_emulator ); + printf ( "SSH dialog set terminal title: %5s\n", config.ssh_set_title ? "true" : "false" ); /* Keybindings. */ printf ( "Window switcher key: %7s\n", config.window_key ); printf ( "Run dialog key: %7s\n", config.run_key ); diff --git a/source/ssh-dialog.c b/source/ssh-dialog.c index ab99f72b..5670325f 100644 --- a/source/ssh-dialog.c +++ b/source/ssh-dialog.c @@ -56,7 +56,7 @@ static inline int execshssh ( const char *host ) char **args = malloc ( sizeof ( char* ) * 7 ); int i = 0; args[i++] = config.terminal_emulator; - if ( config.show_title ) + if ( config.ssh_set_title ) { char *buffer = NULL; if ( asprintf ( &buffer, "ssh %s", host ) > 0 ) diff --git a/source/xrmoptions.c b/source/xrmoptions.c index e61676e8..5cd94246 100644 --- a/source/xrmoptions.c +++ b/source/xrmoptions.c @@ -96,6 +96,8 @@ static XrmOption xrmOptions[] = { { xrm_String, "terminal", { .str = &config.terminal_emulator }, NULL }, + + { xrm_Boolean, "ssh-set-title", { .num = &config.ssh_set_title }, NULL }, /* Key bindings */ { xrm_String, "key", { .str = &config.window_key }, NULL }, { xrm_String, "rkey", { .str = &config.run_key }, NULL },