aboutsummaryrefslogtreecommitdiffstats
path: root/notify.h
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2013-01-21 16:09:02 -0500
committerDave Reisner <dreisner@archlinux.org>2013-01-22 21:05:39 -0500
commit0027e9422fa7205d0a50b995fbe172c35c9ce379 (patch)
tree6ace11eb26204dffe902bc722ee604ab94d7a67e /notify.h
parent4aa7581f9dc97e3c8b01a9411cf665158895f4c0 (diff)
downloadmirror-ponymix-0027e9422fa7205d0a50b995fbe172c35c9ce379.tar.gz
mirror-ponymix-0027e9422fa7205d0a50b995fbe172c35c9ce379.tar.bz2
mirror-ponymix-0027e9422fa7205d0a50b995fbe172c35c9ce379.zip
add support for libnotify based notifier
Diffstat (limited to 'notify.h')
-rw-r--r--notify.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/notify.h b/notify.h
index 03f6775..4718f20 100644
--- a/notify.h
+++ b/notify.h
@@ -2,6 +2,10 @@
#include <stdio.h>
+#ifdef HAVE_NOTIFY
+#include <libnotify/notify.h>
+#endif
+
enum NotificationType {
NOTIFY_VOLUME,
NOTIFY_BALANCE,
@@ -35,4 +39,52 @@ class CommandLineNotifier : public Notifier {
}
};
+#ifdef HAVE_NOTIFY
+class LibnotifyNotifier : public Notifier {
+ public:
+ LibnotifyNotifier() {
+ notify_init("ponymix");
+ }
+
+ virtual ~LibnotifyNotifier() {
+ notify_uninit();
+ }
+
+ virtual void Notify(enum NotificationType type, long value, bool mute) {
+ switch (type) {
+ case NOTIFY_BALANCE:
+ break;
+ case NOTIFY_VOLUME:
+ case NOTIFY_UNMUTE:
+ case NOTIFY_MUTE:
+ volchange(value, mute);
+ break;
+ }
+ }
+
+ private:
+ void volchange(long vol, bool mute) {
+ const char* icon = "notification-audio-volume-muted";
+
+ if (!mute) {
+ if (vol > 67) {
+ icon = "notification-audio-volume-high";
+ } else if (vol > 33) {
+ icon = "notification-audio-volume-medium";
+ } else if (vol > 0) {
+ icon = "notification-audio-volume-low";
+ }
+ }
+
+ NotifyNotification* notification = notify_notification_new("ponymix", "", icon);
+ notify_notification_set_timeout(notification, 1000);
+ notify_notification_set_urgency(notification, NOTIFY_URGENCY_NORMAL);
+ notify_notification_set_hint_int32(notification, "value", vol);
+ notify_notification_set_hint_string(notification, "synchronous", "volume");
+ notify_notification_show(notification, NULL);
+ g_object_unref(G_OBJECT(notification));
+ }
+};
+#endif
+
// vim: set et ts=2 sw=2: