From 2d9d22281a6c4d65a65740eb1c3cbfa090324d58 Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Mon, 24 Aug 2009 21:16:53 +0200 Subject: [PATCH] new config option: jump_to_now_playing_song_at_start (enabled by default) --- doc/config | 2 ++ doc/ncmpcpp.1 | 3 +++ src/ncmpcpp.cpp | 7 +++++++ src/settings.cpp | 5 +++++ src/settings.h | 1 + 5 files changed, 18 insertions(+) diff --git a/doc/config b/doc/config index 97b57202..ecfda58c 100644 --- a/doc/config +++ b/doc/config @@ -201,6 +201,8 @@ # #display_screens_numbers_on_start = "yes" # +#jump_to_now_playing_song_at_start = "yes" +# #ask_before_clearing_main_playlist = "no" # #clock_display_seconds = "no" diff --git a/doc/ncmpcpp.1 b/doc/ncmpcpp.1 index 218370e6..5346c7c1 100644 --- a/doc/ncmpcpp.1 +++ b/doc/ncmpcpp.1 @@ -186,6 +186,9 @@ If set to "playlist", Search engine will perform searching in current MPD playli .B display_screens_numbers_on_start = yes/no If enabled, screens' names and their keybindings will be shown in header window until key is pressed, otherwise they won't be displayed at all. .TP +.B jump_to_now_playing_song_at_start = yes/no +If enabled, ncmpcpp will jump at start to now playing song if mpd is playing or paused. +.TP .B ask_before_clearing_main_playlist = yes/no If enabled, user will be asked if he really wants to clear the main playlist after pressing key responsible for that. .TP diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp index 0417e812..7bff8ca2 100644 --- a/src/ncmpcpp.cpp +++ b/src/ncmpcpp.cpp @@ -167,6 +167,13 @@ int main(int argc, char *argv[]) if (Config.mouse_support) mousemask(ALL_MOUSE_EVENTS, 0); + if (Config.jump_to_now_playing_song_at_start) + { + TraceMpdStatus(); + if (myPlaylist->isPlaying()) + myPlaylist->Main()->Highlight(myPlaylist->NowPlaying); + } + while (!main_exit) { if (!Mpd.Connected()) diff --git a/src/settings.cpp b/src/settings.cpp index eef6ff76..e34916d8 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -289,6 +289,7 @@ void DefaultConfiguration(ncmpcpp_config &conf) conf.local_browser_show_hidden_files = false; conf.search_in_db = true; conf.display_screens_numbers_on_start = true; + conf.jump_to_now_playing_song_at_start = true; conf.clock_display_seconds = false; conf.display_bitrate = false; conf.ignore_leading_the = false; @@ -730,6 +731,10 @@ void ReadConfiguration(ncmpcpp_config &conf) { conf.display_screens_numbers_on_start = v == "yes"; } + else if (cl.find("jump_to_now_playing_song_at_start") != std::string::npos) + { + conf.jump_to_now_playing_song_at_start = v == "yes"; + } else if (cl.find("clock_display_seconds") != std::string::npos) { conf.clock_display_seconds = v == "yes"; diff --git a/src/settings.h b/src/settings.h index 1094568e..3b6886d6 100644 --- a/src/settings.h +++ b/src/settings.h @@ -187,6 +187,7 @@ struct ncmpcpp_config bool local_browser_show_hidden_files; bool search_in_db; bool display_screens_numbers_on_start; + bool jump_to_now_playing_song_at_start; bool clock_display_seconds; bool display_bitrate; bool ignore_leading_the;