diff --git a/CHANGELOG b/CHANGELOG index d5311d0c..bf6a4712 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -11,3 +11,4 @@ - Additional readline style shortcuts - Improved chat session handling - Override resource during chat and resource display settings (/resource) +- Disable terminal title by default, additonal title on exit diff --git a/src/command/command.c b/src/command/command.c index 64bf09d7..f2ceaa82 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -723,10 +723,12 @@ static struct cmd_t command_defs[] = { "/titlebar", cmd_titlebar, parse_args, 2, 2, &cons_titlebar_setting, - { "/titlebar show on|off", "Show information in the window title bar.", - { "/titlebar show on|off", + { "/titlebar show|goodbye on|off", "Manage the terminal window title.", + { "/titlebar show|goodbye on|off", "---------------------", - "Show information in the window title bar.", + "Show or hide a title and exit message in the terminal window title.", + "show - Show current logged in user, and unread messages in the title.", + "goodbye - Show a message in the title when exiting profanity.", NULL } } }, { "/mouse", @@ -1208,6 +1210,7 @@ cmd_init(void) titlebar_ac = autocomplete_new(); autocomplete_add(titlebar_ac, "show"); + autocomplete_add(titlebar_ac, "goodbye"); log_ac = autocomplete_new(); autocomplete_add(log_ac, "maxsize"); @@ -2497,6 +2500,11 @@ _titlebar_autocomplete(char *input, int *size) return found; } + found = autocomplete_param_with_func(input, size, "/titlebar goodbye", prefs_autocomplete_boolean_choice); + if (found != NULL) { + return found; + } + found = autocomplete_param_with_ac(input, size, "/titlebar", titlebar_ac, FALSE); if (found != NULL) { return found; diff --git a/src/command/commands.c b/src/command/commands.c index f72a6047..fba32b8b 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -3252,14 +3252,18 @@ cmd_states(gchar **args, struct cmd_help_t help) gboolean cmd_titlebar(gchar **args, struct cmd_help_t help) { - if (g_strcmp0(args[0], "show") != 0) { + if (g_strcmp0(args[0], "show") != 0 && g_strcmp0(args[0], "goodbye") != 0) { cons_show("Usage: %s", help.usage); return TRUE; } - if (g_strcmp0(args[1], "off") == 0) { + if (g_strcmp0(args[0], "show") == 0 && g_strcmp0(args[1], "off") == 0) { ui_clear_win_title(); } - return _cmd_set_boolean_preference(args[1], help, "Titlebar show", PREF_TITLEBAR_SHOW); + if (g_strcmp0(args[0], "show") == 0) { + return _cmd_set_boolean_preference(args[1], help, "Titlebar show", PREF_TITLEBAR_SHOW); + } else { + return _cmd_set_boolean_preference(args[1], help, "Titlebar goodbye", PREF_TITLEBAR_GOODBYE); + } } gboolean diff --git a/src/command/commands.h b/src/command/commands.h index dd09fae0..f4e040a9 100644 --- a/src/command/commands.h +++ b/src/command/commands.h @@ -140,4 +140,4 @@ gboolean cmd_inpblock(gchar **args, struct cmd_help_t help); gboolean cmd_form_field(char *tag, gchar **args); -#endif \ No newline at end of file +#endif diff --git a/src/config/preferences.c b/src/config/preferences.c index 30456f99..6e7ab576 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -511,6 +511,7 @@ _get_group(preference_t pref) case PREF_THEME: case PREF_VERCHECK: case PREF_TITLEBAR_SHOW: + case PREF_TITLEBAR_GOODBYE: case PREF_FLASH: case PREF_INTYPE: case PREF_HISTORY: @@ -583,6 +584,8 @@ _get_key(preference_t pref) return "vercheck"; case PREF_TITLEBAR_SHOW: return "titlebar.show"; + case PREF_TITLEBAR_GOODBYE: + return "titlebar.goodbye"; case PREF_FLASH: return "flash"; case PREF_INTYPE: diff --git a/src/config/preferences.h b/src/config/preferences.h index a7ce4d8d..a0ad2f84 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -55,6 +55,7 @@ typedef enum { PREF_VERCHECK, PREF_THEME, PREF_TITLEBAR_SHOW, + PREF_TITLEBAR_GOODBYE, PREF_FLASH, PREF_INTYPE, PREF_HISTORY, diff --git a/src/profanity.c b/src/profanity.c index 467e4c2c..18bcc5f9 100644 --- a/src/profanity.c +++ b/src/profanity.c @@ -292,7 +292,13 @@ _init(const int disable_tls, char *log_level) static void _shutdown(void) { - ui_clear_win_title(); + if (prefs_get_boolean(PREF_TITLEBAR_SHOW)) { + if (prefs_get_boolean(PREF_TITLEBAR_GOODBYE)) { + ui_goodbye_title(); + } else { + ui_clear_win_title(); + } + } ui_close_all_wins(); jabber_disconnect(); jabber_shutdown(); diff --git a/src/ui/console.c b/src/ui/console.c index e595a024..d219a175 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -969,6 +969,11 @@ cons_titlebar_setting(void) } else { cons_show("Titlebar show (/titlebar) : OFF"); } + if (prefs_get_boolean(PREF_TITLEBAR_GOODBYE)) { + cons_show("Titlebar goodbye (/titlebar) : ON"); + } else { + cons_show("Titlebar goodbye (/titlebar) : OFF"); + } } void diff --git a/src/ui/core.c b/src/ui/core.c index 22e7bcf1..be16dfad 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -2301,6 +2301,13 @@ ui_clear_win_title(void) printf("%c]0;%c", '\033', '\007'); } +void +ui_goodbye_title(void) +{ + int result = system("/bin/echo -ne \"\033]0;Thanks for using Profanity\007\""); + if(result == -1) log_error("Error printing title on shutdown"); +} + void ui_statusbar_new(const int win) { diff --git a/src/ui/ui.h b/src/ui/ui.h index 4d64342a..32484b9e 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -191,6 +191,7 @@ void ui_handle_recipient_not_found(const char * const recipient, const char * co void ui_handle_recipient_error(const char * const recipient, const char * const err_msg); void ui_handle_error(const char * const err_msg); void ui_clear_win_title(void); +void ui_goodbye_title(void); void ui_handle_room_join_error(const char * const roomjid, const char * const err); void ui_handle_room_configuration(const char * const roomjid, DataForm *form); void ui_handle_room_configuration_form_error(const char * const roomjid, const char * const message); diff --git a/tests/ui/stub_ui.c b/tests/ui/stub_ui.c index 296efbee..ef0778d0 100644 --- a/tests/ui/stub_ui.c +++ b/tests/ui/stub_ui.c @@ -284,6 +284,7 @@ void ui_handle_error(const char * const err_msg) } void ui_clear_win_title(void) {} +void ui_goodbye_title(void) {} void ui_handle_room_join_error(const char * const roomjid, const char * const err) {} void ui_handle_room_configuration(const char * const roomjid, DataForm *form) {} void ui_handle_room_configuration_form_error(const char * const roomjid, const char * const message) {}