diff --git a/doc/config b/doc/config index c67fd73f..75b63539 100644 --- a/doc/config +++ b/doc/config @@ -163,6 +163,8 @@ # #lyrics_database = "1" # +#external_editor = "" +# ##### colors definitions ##### # #colors_enabled = "yes" diff --git a/src/lyrics.cpp b/src/lyrics.cpp index a8b0abf8..ed9a45f8 100644 --- a/src/lyrics.cpp +++ b/src/lyrics.cpp @@ -45,6 +45,8 @@ const std::string Lyrics::Folder = home_folder + "/.lyrics"; bool Lyrics::Reload = 0; +std::string Lyrics::Filename; + #ifdef HAVE_CURL_CURL_H pthread_mutex_t Global::curl = PTHREAD_MUTEX_INITIALIZER; @@ -157,11 +159,11 @@ void *Lyrics::Get(void *song) string filename = artist + " - " + title + ".txt"; EscapeUnallowedChars(filename); - const string fullpath = Folder + "/" + filename; + Filename = Folder + "/" + filename; mkdir(Folder.c_str(), 0755); - std::ifstream input(fullpath.c_str()); + std::ifstream input(Filename.c_str()); if (input.is_open()) { @@ -237,7 +239,7 @@ void *Lyrics::Get(void *song) *myLyrics->Main() << utf_to_locale_cpy(result); - std::ofstream output(fullpath.c_str()); + std::ofstream output(Filename.c_str()); if (output.is_open()) { output << result; @@ -252,6 +254,21 @@ void *Lyrics::Get(void *song) # endif } +void Lyrics::Edit() +{ + if (myScreen != this) + return; + + if (Config.external_editor.empty()) + { + ShowMessage("External editor is not set!"); + return; + } + + ShowMessage("Opening lyrics in external editor..."); + system(("nohup " + Config.external_editor + " \"" + Filename + "\" > /dev/null 2>&1 &").c_str()); +} + #ifdef HAVE_CURL_CURL_H void Lyrics::Take() diff --git a/src/lyrics.h b/src/lyrics.h index 40968169..6551412d 100644 --- a/src/lyrics.h +++ b/src/lyrics.h @@ -58,6 +58,8 @@ class Lyrics : public Screen virtual List *GetList() { return 0; } + void Edit(); + static bool Reload; # ifdef HAVE_CURL_CURL_H @@ -67,6 +69,7 @@ class Lyrics : public Screen protected: static void *Get(void *); + static std::string Filename; static const std::string Folder; # ifdef HAVE_CURL_CURL_H diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp index 7ac5a53f..730d7b18 100644 --- a/src/ncmpcpp.cpp +++ b/src/ncmpcpp.cpp @@ -1126,6 +1126,10 @@ int main(int argc, char *argv[]) } else # endif // HAVE_TAGLIB_H + if (myScreen == myLyrics) + { + myLyrics->Edit(); + } if (myScreen == myBrowser && myBrowser->Main()->Current().type == itDirectory) { string old_dir = myBrowser->Main()->Current().name; diff --git a/src/settings.cpp b/src/settings.cpp index a16cb7f8..8ac91f9d 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -508,6 +508,11 @@ void ReadConfiguration(ncmpcpp_config &conf) if (!v.empty()) conf.tag_editor_album_format = v; } + else if (cl.find("external_editor") != string::npos) + { + if (!v.empty()) + conf.external_editor = v; + } else if (cl.find("browser_playlist_prefix") != string::npos) { if (!v.empty()) diff --git a/src/settings.h b/src/settings.h index b46d8772..1d76a6f8 100644 --- a/src/settings.h +++ b/src/settings.h @@ -109,6 +109,7 @@ struct ncmpcpp_config std::string song_library_format; std::string media_lib_album_format; std::string tag_editor_album_format; + std::string external_editor; std::string pattern;