diff --git a/doc/config b/doc/config index 0f4a022b..10b2ea0a 100644 --- a/doc/config +++ b/doc/config @@ -110,6 +110,13 @@ # ##### various settings ##### # +## +## Note: Custom command that will be executed each time song changes. +## It uses the same syntax as song format (for now playing song). +## Useful for notifications etc. +## +#execute_on_song_change = "" +# #playlist_show_remaining_time = "no" # #playlist_display_mode = "classic" (classic/columns) diff --git a/src/settings.cpp b/src/settings.cpp index 060998af..1bac1560 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -533,6 +533,11 @@ void ReadConfiguration(ncmpcpp_config &conf) if (!v.empty()) conf.system_encoding = v + "//TRANSLIT"; } + else if (cl.find("execute_on_song_change") != string::npos) + { + if (!v.empty()) + conf.execute_on_song_change = v; + } else if (cl.find("browser_playlist_prefix") != string::npos) { if (!v.empty()) diff --git a/src/settings.h b/src/settings.h index 6f80caca..191504dd 100644 --- a/src/settings.h +++ b/src/settings.h @@ -119,6 +119,7 @@ struct ncmpcpp_config std::string tag_editor_album_format; std::string external_editor; std::string system_encoding; + std::string execute_on_song_change; std::string pattern; diff --git a/src/status.cpp b/src/status.cpp index 8259024b..c5366c08 100644 --- a/src/status.cpp +++ b/src/status.cpp @@ -343,6 +343,8 @@ void NcmpcppStatusChanged(Connection *Mpd, StatusChanges changed, void *) if (myPlaylist->isPlaying()) { np = Mpd->GetCurrentSong(); + if (!Config.execute_on_song_change.empty()) + system(np.toString(Config.execute_on_song_change).c_str()); if (Mpd->GetState() > psStop) WindowTitle(utf_to_locale_cpy(np.toString(Config.song_window_title_format))); if (Config.autocenter_mode && !myPlaylist->Main()->isFiltered())