From f3e080e2683992ed75a58a8f5eff54dc5ef72bff Mon Sep 17 00:00:00 2001 From: Akce <> Date: Sun, 28 Feb 2021 07:43:26 +1100 Subject: Draw wintitle using fputs and fprintf instead of /bin/echo. --- src/ui/core.c | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/ui/core.c b/src/ui/core.c index aad6d387..5021ac72 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -82,7 +82,6 @@ #include "otr/otr.h" #endif -static char* win_title; static int inp_size; static gboolean perform_resize = FALSE; static GTimer* ui_idle_time; @@ -1079,21 +1078,20 @@ ui_contact_offline(char* barejid, char* resource, char* status) void ui_clear_win_title(void) { - printf("%c]0;%c", '\033', '\007'); + fputs("\e]0;\a", stdout); + fflush(stdout); } 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"); + fputs("\e]0;Thanks for using Profanity\a", stdout); + fflush(stdout); } static void _ui_draw_term_title(void) { - char new_win_title[100]; jabber_conn_status_t status = connection_get_status(); if (status == JABBER_CONNECTED) { @@ -1101,29 +1099,14 @@ _ui_draw_term_title(void) gint unread = wins_get_total_unread(); if (unread != 0) { - snprintf(new_win_title, sizeof(new_win_title), - "/bin/echo -n \"%c]0;%s (%d) - %s%c\"", '\033', "Profanity", - unread, jid, '\007'); + fprintf(stdout, "\e]0;Profanity (%d) - %s\a", unread, jid); } else { - snprintf(new_win_title, sizeof(new_win_title), - "/bin/echo -n \"%c]0;%s - %s%c\"", '\033', "Profanity", jid, - '\007'); + fprintf(stdout, "\e]0;Profanity - %s\a", jid); } } else { - snprintf(new_win_title, sizeof(new_win_title), "/bin/echo -n \"%c]0;%s%c\"", '\033', - "Profanity", '\007'); - } - if (g_strcmp0(win_title, new_win_title) != 0) { - // print to x-window title bar - int res = system(new_win_title); - if (res == -1) { - log_error("Error writing terminal window title."); - } - if (win_title) { - free(win_title); - } - win_title = strdup(new_win_title); + fputs("\e]0;Profanity\a", stdout); } + fflush(stdout); } void -- cgit 1.4.1-2-gfad0