diff options
author | Andrzej Rybczak <andrzej@rybczak.net> | 2021-01-03 23:55:06 +0100 |
---|---|---|
committer | Andrzej Rybczak <andrzej@rybczak.net> | 2021-01-03 23:55:06 +0100 |
commit | b902a2a6bf79963c6d7299b5e9ec7788ff792daf (patch) | |
tree | 82460786430a0c49e5e1046ddcb441c0b2d802b0 | |
parent | dd0eac69f8bc58e5ce8c604aaa2b5b54ec68d8cf (diff) |
Don't block when executing external commands
-rw-r--r-- | src/macro_utilities.cpp | 5 | ||||
-rw-r--r-- | src/status.cpp | 6 |
2 files changed, 8 insertions, 3 deletions
diff --git a/src/macro_utilities.cpp b/src/macro_utilities.cpp index 4e3c5108..c3655bba 100644 --- a/src/macro_utilities.cpp +++ b/src/macro_utilities.cpp @@ -87,7 +87,7 @@ RunExternalCommand::RunExternalCommand(std::string &&command) void RunExternalCommand::run() { - runExternalCommand(m_command, false); + runExternalCommand(m_command, true); } RunExternalConsoleCommand::RunExternalConsoleCommand(std::string &&command) @@ -118,5 +118,6 @@ void runExternalCommand(const std::string &cmd, bool block) if (block) std::system(cmd.c_str()); else - std::system(("nohup " + cmd + " &").c_str()); + // If we don't block, disregard any output. + std::system(("nohup " + cmd + " >/dev/null 2>&1 &").c_str()); } diff --git a/src/status.cpp b/src/status.cpp index adbdc1a3..9a3cacb1 100644 --- a/src/status.cpp +++ b/src/status.cpp @@ -570,7 +570,11 @@ void Status::Changes::songID(int song_id) if (!s.empty()) { if (!Config.execute_on_song_change.empty()) - runExternalCommand(Config.execute_on_song_change, false); + { + // We need to block to allow sending output to the terminal so a script + // can e.g. set the album art. + runExternalCommand(Config.execute_on_song_change, true); + } if (Config.fetch_lyrics_in_background) myLyrics->fetchInBackground(s, false); |