fix(msg): use stdout when exiting with code 0
This commit is contained in:
parent
c650513b67
commit
0740382851
@ -15,8 +15,8 @@ using namespace std;
|
|||||||
#define IPC_CHANNEL_PREFIX "/tmp/polybar_mqueue."
|
#define IPC_CHANNEL_PREFIX "/tmp/polybar_mqueue."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void log(const string& msg) {
|
void display(const string& msg) {
|
||||||
fprintf(stderr, "polybar-msg: %s\n", msg.c_str());
|
fprintf(stdout, "%s\n", msg.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void log(int exit_code, const string& msg) {
|
void log(int exit_code, const string& msg) {
|
||||||
@ -33,7 +33,7 @@ void remove_pipe(const string& handle) {
|
|||||||
if (unlink(handle.c_str()) == -1) {
|
if (unlink(handle.c_str()) == -1) {
|
||||||
log(1, "Could not remove stale ipc channel: "s + strerror(errno));
|
log(1, "Could not remove stale ipc channel: "s + strerror(errno));
|
||||||
} else {
|
} else {
|
||||||
log("Removed stale ipc channel: " + handle);
|
display("Removed stale ipc channel: " + handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ int main(int argc, char** argv) {
|
|||||||
file_descriptor fd(channel, O_WRONLY | O_NONBLOCK);
|
file_descriptor fd(channel, O_WRONLY | O_NONBLOCK);
|
||||||
string payload{ipc_type + ':' + ipc_payload};
|
string payload{ipc_type + ':' + ipc_payload};
|
||||||
if (write(fd, payload.c_str(), payload.size()) != -1) {
|
if (write(fd, payload.c_str(), payload.size()) != -1) {
|
||||||
log("Successfully wrote \"" + payload + "\" to \"" + channel + "\"");
|
display("Successfully wrote \"" + payload + "\" to \"" + channel + "\"");
|
||||||
exit_status = 0;
|
exit_status = 0;
|
||||||
} else {
|
} else {
|
||||||
log(E_WRITE, "Failed to write \"" + payload + "\" to \"" + channel + "\" (err: " + strerror(errno) + ")");
|
log(E_WRITE, "Failed to write \"" + payload + "\" to \"" + channel + "\" (err: " + strerror(errno) + ")");
|
||||||
|
Loading…
Reference in New Issue
Block a user