Suppress output of all external commands
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
* Fix crash on startup with Browser as the initial screen.
|
* Fix crash on startup with Browser as the initial screen.
|
||||||
* Show the Visualizer immediately if it's the initial screen.
|
* Show the Visualizer immediately if it's the initial screen.
|
||||||
* Draw a separator between albums with the same name, but a different artist.
|
* Draw a separator between albums with the same name, but a different artist.
|
||||||
|
* Suppress output of all external commands.
|
||||||
|
|
||||||
# ncmpcpp-0.9 (2020-12-20)
|
# ncmpcpp-0.9 (2020-12-20)
|
||||||
* Fix various Mopidy specific bugs.
|
* Fix various Mopidy specific bugs.
|
||||||
|
|||||||
@@ -87,8 +87,7 @@ RunExternalCommand::RunExternalCommand(std::string &&command)
|
|||||||
|
|
||||||
void RunExternalCommand::run()
|
void RunExternalCommand::run()
|
||||||
{
|
{
|
||||||
GNUC_UNUSED int res;
|
runExternalCommandNoOutput(m_command, false);
|
||||||
res = std::system(("nohup " + m_command + " >/dev/null 2>&1 &").c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RunExternalConsoleCommand::RunExternalConsoleCommand(std::string &&command)
|
RunExternalConsoleCommand::RunExternalConsoleCommand(std::string &&command)
|
||||||
@@ -102,10 +101,23 @@ RunExternalConsoleCommand::RunExternalConsoleCommand(std::string &&command)
|
|||||||
|
|
||||||
void RunExternalConsoleCommand::run()
|
void RunExternalConsoleCommand::run()
|
||||||
{
|
{
|
||||||
GNUC_UNUSED int res;
|
runExternalConsoleCommand(m_command);
|
||||||
NC::pauseScreen();
|
|
||||||
res = std::system(m_command.c_str());
|
|
||||||
NC::unpauseScreen();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void runExternalConsoleCommand(const std::string &cmd)
|
||||||
|
{
|
||||||
|
NC::pauseScreen();
|
||||||
|
std::system(cmd.c_str());
|
||||||
|
NC::unpauseScreen();
|
||||||
|
}
|
||||||
|
|
||||||
|
void runExternalCommandNoOutput(const std::string &cmd, bool block)
|
||||||
|
{
|
||||||
|
if (block)
|
||||||
|
std::system((cmd + " >/dev/null 2>&1").c_str());
|
||||||
|
else
|
||||||
|
std::system(("nohup " + cmd + " >/dev/null 2>&1 &").c_str());
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -82,4 +82,9 @@ private:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Helpers
|
||||||
|
|
||||||
|
void runExternalConsoleCommand(const std::string &cmd);
|
||||||
|
void runExternalCommandNoOutput(const std::string &cmd, bool block);
|
||||||
|
|
||||||
#endif // NCMPCPP_MACRO_UTILITIES_H
|
#endif // NCMPCPP_MACRO_UTILITIES_H
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
#include "format_impl.h"
|
#include "format_impl.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
|
#include "macro_utilities.h"
|
||||||
#include "screens/lyrics.h"
|
#include "screens/lyrics.h"
|
||||||
#include "screens/playlist.h"
|
#include "screens/playlist.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
@@ -323,24 +324,15 @@ void Lyrics::edit()
|
|||||||
|
|
||||||
Statusbar::print("Opening lyrics in external editor...");
|
Statusbar::print("Opening lyrics in external editor...");
|
||||||
|
|
||||||
GNUC_UNUSED int res;
|
|
||||||
std::string command;
|
|
||||||
std::string filename = lyricsFilename(m_song);
|
std::string filename = lyricsFilename(m_song);
|
||||||
escapeSingleQuotes(filename);
|
escapeSingleQuotes(filename);
|
||||||
if (Config.use_console_editor)
|
if (Config.use_console_editor)
|
||||||
{
|
{
|
||||||
command = Config.external_editor + " '" + filename + "'";
|
runExternalConsoleCommand(Config.external_editor + " '" + filename + "'");
|
||||||
NC::pauseScreen();
|
|
||||||
res = system(command.c_str());
|
|
||||||
NC::unpauseScreen();
|
|
||||||
fetch(m_song);
|
fetch(m_song);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
runExternalCommandNoOutput(Config.external_editor + " '" + filename + "'", false);
|
||||||
command = "nohup " + Config.external_editor
|
|
||||||
+ " '" + filename + "' > /dev/null 2>&1 &";
|
|
||||||
res = system(command.c_str());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lyrics::toggleFetcher()
|
void Lyrics::toggleFetcher()
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#include "format_impl.h"
|
#include "format_impl.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
|
#include "macro_utilities.h"
|
||||||
#include "screens/lyrics.h"
|
#include "screens/lyrics.h"
|
||||||
#include "screens/media_library.h"
|
#include "screens/media_library.h"
|
||||||
#include "screens/outputs.h"
|
#include "screens/outputs.h"
|
||||||
@@ -489,9 +490,9 @@ void Status::Changes::playerState()
|
|||||||
}
|
}
|
||||||
throw std::logic_error("unreachable");
|
throw std::logic_error("unreachable");
|
||||||
};
|
};
|
||||||
GNUC_UNUSED int res;
|
|
||||||
setenv("MPD_PLAYER_STATE", stateToEnv(m_player_state), 1);
|
setenv("MPD_PLAYER_STATE", stateToEnv(m_player_state), 1);
|
||||||
res = system(Config.execute_on_player_state_change.c_str());
|
// Since we're setting a MPD_PLAYER_STATE, we need to block.
|
||||||
|
runExternalCommandNoOutput(Config.execute_on_player_state_change, true);
|
||||||
unsetenv("MPD_PLAYER_STATE");
|
unsetenv("MPD_PLAYER_STATE");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -568,9 +569,8 @@ void Status::Changes::songID(int song_id)
|
|||||||
const auto &s = it != pl.endV() ? *it : Mpd.GetCurrentSong();
|
const auto &s = it != pl.endV() ? *it : Mpd.GetCurrentSong();
|
||||||
if (!s.empty())
|
if (!s.empty())
|
||||||
{
|
{
|
||||||
GNUC_UNUSED int res;
|
|
||||||
if (!Config.execute_on_song_change.empty())
|
if (!Config.execute_on_song_change.empty())
|
||||||
res = system(Config.execute_on_song_change.c_str());
|
runExternalCommandNoOutput(Config.execute_on_song_change, false);
|
||||||
|
|
||||||
if (Config.fetch_lyrics_in_background)
|
if (Config.fetch_lyrics_in_background)
|
||||||
myLyrics->fetchInBackground(s, false);
|
myLyrics->fetchInBackground(s, false);
|
||||||
|
|||||||
Reference in New Issue
Block a user