aboutsummaryrefslogtreecommitdiffstats
path: root/mpd-notification.c
diff options
context:
space:
mode:
authorGravatar Samuel Čavoj <sammko@sammserver.com>2015-06-06 21:35:31 +0200
committerGravatar Christian Hesse <mail@eworm.de>2015-06-19 11:28:16 +0200
commitad6843464cdcc53691f7e902065d7da7f0485fba (patch)
tree21bd66a96a9248e296d823d6d3fae01886fbfb2f /mpd-notification.c
parent5bb465a32186c850c1a862e546df70fd3da3a72d (diff)
downloadmpd-notification-ad6843464cdcc53691f7e902065d7da7f0485fba.tar.gz
mpd-notification-ad6843464cdcc53691f7e902065d7da7f0485fba.tar.zst
Implement a notification-timeout option (-t)
It takes a floating point input in seconds and is converted to ms before passed to libnotify. Modified-by: Christian Hesse <mail@eworm.de>
Diffstat (limited to 'mpd-notification.c')
-rw-r--r--mpd-notification.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/mpd-notification.c b/mpd-notification.c
index 856f8b0..65dc332 100644
--- a/mpd-notification.c
+++ b/mpd-notification.c
@@ -7,13 +7,14 @@
#include "mpd-notification.h"
-const static char optstring[] = "hH:m:p:v";
+const static char optstring[] = "hH:m:p:t:v";
const static struct option options_long[] = {
/* name has_arg flag val */
{ "help", no_argument, NULL, 'h' },
{ "host", required_argument, NULL, 'H' },
{ "music-dir", required_argument, NULL, 'm' },
{ "port", required_argument, NULL, 'p' },
+ { "timeout", required_argument, NULL, 't' },
{ "verbose", no_argument, NULL, 'v' },
{ 0, 0, 0, 0 }
};
@@ -165,8 +166,8 @@ int main(int argc, char ** argv) {
char * album = NULL, * artist = NULL, * icon = NULL, * notifystr = NULL, * title = NULL;
GError * error = NULL;
unsigned short int errcount = 0, state = MPD_STATE_UNKNOWN;
- const char * mpd_host = MPD_HOST, * music_dir = NULL, * uri = NULL;;
- unsigned mpd_port = MPD_PORT, mpd_timeout = MPD_TIMEOUT;
+ const char * mpd_host = MPD_HOST, * music_dir = NULL, * uri = NULL;
+ unsigned mpd_port = MPD_PORT, mpd_timeout = MPD_TIMEOUT, notification_timeout = NOTIFICATION_TIMEOUT;
struct mpd_song * song = NULL;
unsigned int i;
@@ -194,7 +195,7 @@ int main(int argc, char ** argv) {
while ((i = getopt_long(argc, argv, optstring, options_long, NULL)) != -1) {
switch (i) {
case 'h':
- fprintf(stderr, "usage: %s [-h] [-H HOST] [-p PORT] [-m MUSIC-DIR] [-v]\n", program);
+ fprintf(stderr, "usage: %s [-h] [-H HOST] [-p PORT] [-m MUSIC-DIR] [-t TIMEOUT] [-v]\n", program);
return EXIT_SUCCESS;
case 'p':
mpd_port = atoi(optarg);
@@ -211,6 +212,11 @@ int main(int argc, char ** argv) {
if (verbose > 0)
printf("%s: using host %s\n", program, mpd_host);
break;
+ case 't':
+ notification_timeout = atof(optarg) * 1000;
+ if (verbose > 0)
+ printf("%s: using notification-timeout %d\n", program, notification_timeout);
+ break;
}
}
@@ -303,7 +309,7 @@ int main(int argc, char ** argv) {
notify_notification_update(notification, TEXT_TOPIC, notifystr, icon ? icon : ICON_SOUND);
- notify_notification_set_timeout(notification, NOTIFICATION_TIMEOUT);
+ notify_notification_set_timeout(notification, notification_timeout);
while(notify_notification_show(notification, &error) == FALSE) {
if (errcount > 1) {