summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2019-10-09 09:16:04 +0200
committerGravatar Christian Hesse <mail@eworm.de>2019-10-09 09:16:04 +0200
commit1f90c40b2b026d8d2b26e13ef1fee4a8fe96b532 (patch)
tree0ca7cfc2f40f6a70415ecb95dfa0b05f7afa9679
parenta07925971bef1da821260068e1ba9dc3c244fe28 (diff)
downloadmpd-notification-1f90c40b2b026d8d2b26e13ef1fee4a8fe96b532.tar.gz
mpd-notification-1f90c40b2b026d8d2b26e13ef1fee4a8fe96b532.tar.zst
drop retry code, just fail and let the service restart
-rw-r--r--mpd-notification.c23
-rw-r--r--systemd/mpd-notification.service1
2 files changed, 4 insertions, 20 deletions
diff --git a/mpd-notification.c b/mpd-notification.c
index f0d27b4..9796a7d 100644
--- a/mpd-notification.c
+++ b/mpd-notification.c
@@ -226,7 +226,6 @@ int main(int argc, char ** argv) {
char * notifystr = NULL;
GdkPixbuf * pixbuf = NULL;
GError * error = NULL;
- unsigned short int errcount = 0;
enum mpd_state state = MPD_STATE_UNKNOWN, last_state = MPD_STATE_UNKNOWN;
const char * mpd_host, * mpd_port_str, * music_dir, * uri = NULL;
unsigned mpd_port = MPD_PORT, mpd_timeout = MPD_TIMEOUT, notification_timeout = NOTIFICATION_TIMEOUT;
@@ -484,27 +483,11 @@ int main(int argc, char ** argv) {
notify_notification_set_image_from_pixbuf(notification, pixbuf);
while(notify_notification_show(notification, &error) == FALSE) {
- if (errcount > 1 || doexit) {
- fprintf(stderr, "%s: Looks like we can not reconnect to notification daemon... Exiting.\n", program);
- goto out10;
- } else {
- g_printerr("%s: Error \"%s\" while trying to show notification. Trying to reconnect.\n", program, error->message);
- errcount++;
+ g_printerr("%s: Error showing notification: %s\n", program, error->message);
+ g_error_free(error);
- g_error_free(error);
- error = NULL;
-
- notify_uninit();
-
- usleep(500 * 1000);
-
- if(notify_init(PROGNAME) == FALSE) {
- fprintf(stderr, "%s: Could not initialize notify.\n", program);
- goto out10;
- }
- }
+ goto out10;
}
- errcount = 0;
nonotification:
if (notifystr != NULL) {
diff --git a/systemd/mpd-notification.service b/systemd/mpd-notification.service
index 0920cad..55cf057 100644
--- a/systemd/mpd-notification.service
+++ b/systemd/mpd-notification.service
@@ -14,6 +14,7 @@ ConditionUser=!@system
[Service]
Type=notify
+Restart=on-failure
ExecStart=/usr/bin/mpd-notification
[Install]