diff options
author | Kalle Wallin <kaw@linux.se> | 2004-06-24 16:12:51 +0000 |
---|---|---|
committer | Kalle Wallin <kaw@linux.se> | 2004-06-24 16:12:51 +0000 |
commit | 11d0bf3e6e4128a8afb3dd92dbf5c2adca74f642 (patch) | |
tree | 4adc4d3baf3b7cbc554b8f93e5bc72ca96136deb /src | |
parent | b0353fc77099ec9e95310ca4e106d88985ee05b4 (diff) | |
download | mpd-11d0bf3e6e4128a8afb3dd92dbf5c2adca74f642.tar.gz mpd-11d0bf3e6e4128a8afb3dd92dbf5c2adca74f642.tar.xz mpd-11d0bf3e6e4128a8afb3dd92dbf5c2adca74f642.zip |
Made the xterm title dynamic, added configuration option xterm-title-format
git-svn-id: https://svn.musicpd.org/ncmpc/trunk@1648 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/src/main.c b/src/main.c index f42a2b01c..bc607da81 100644 --- a/src/main.c +++ b/src/main.c @@ -34,8 +34,9 @@ #include "command.h" #include "screen.h" #include "screen_utils.h" +#include "strfsong.h" -#define BUFSIZE 256 +#define BUFSIZE 1024 static mpdclient_t *mpd = NULL; static gboolean connected = FALSE; @@ -78,6 +79,35 @@ error_callback(mpdclient_t *c, gint error, gchar *msg) } } +static void +update_xterm_title(void) +{ + static char title[BUFSIZE]; + char tmp[BUFSIZE]; + mpd_Status *status = NULL; + mpd_Song *song = NULL; + + if( mpd ) + { + status = mpd->status; + song = mpd->song; + } + + if(options.xterm_title_format && status && song && IS_PLAYING(status->state)) + { + strfsong(tmp, BUFSIZE, options.xterm_title_format, song); + } + else + strncpy(tmp, PACKAGE " version " VERSION, BUFSIZE); + + if( strcmp(title,tmp) ) + { + strncpy(title, tmp, BUFSIZE); + fprintf(stderr, "%s\n", title); + set_xterm_title(title); + } +} + void exit_and_cleanup(void) { @@ -164,9 +194,6 @@ main(int argc, const char *argv[]) exit(EXIT_FAILURE); } - /* set xterm title */ - set_xterm_title(PACKAGE " version " VERSION); - /* install exit function */ atexit(exit_and_cleanup); @@ -259,7 +286,8 @@ main(int argc, const char *argv[]) } doupdate(); } - + if( options->enable_xterm_title ) + update_xterm_title(); t = g_timer_elapsed(timer, NULL); } exit(EXIT_FAILURE); |