aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/CMakeLists.txt3
-rw-r--r--src/notifier.c30
-rw-r--r--src/sound.c29
-rw-r--r--src/sound.h31
4 files changed, 92 insertions, 1 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b68619c..ed0e0ff 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -19,7 +19,8 @@ set(SERVICE_MANUAL_SOURCES
notifier.c
testing.c
service.c
- utils.c)
+ utils.c
+ sound.c)
# generated sources
include(GdbusCodegen)
diff --git a/src/notifier.c b/src/notifier.c
index 123ee6f..47690ca 100644
--- a/src/notifier.c
+++ b/src/notifier.c
@@ -17,10 +17,16 @@
* Charles Kerr <charles.kerr@canonical.com>
*/
+#include "datafiles.h"
#include "dbus-battery.h"
#include "dbus-shared.h"
#include "notifier.h"
#include "utils.h"
+#include "sound.h"
+
+#ifdef HAS_URLDISPATCHER
+# include <lomiri-url-dispatcher.h>
+#endif
#include <libnotify/notify.h>
@@ -130,6 +136,29 @@ get_battery_power_level (IndicatorPowerDevice * battery)
}
/***
+**** Sounds
+***/
+
+static void
+play_low_battery_sound (void)
+{
+ const gchar * key;
+ gchar * filename;
+
+ key = "Low battery.ogg";
+ filename = datafile_find(DATAFILE_TYPE_SOUND, key);
+ if (filename != NULL)
+ {
+ sound_play_file(filename);
+ g_free(filename);
+ }
+ else
+ {
+ g_warning("Unable to find '%s' in XDG data dirs", key);
+ }
+}
+
+/***
**** Notifications
***/
@@ -299,6 +328,7 @@ on_battery_property_changed (IndicatorPowerNotifier * self)
((new_power_level != POWER_LEVEL_OK) && new_discharging && !old_discharging))
{
notification_show (self);
+ play_low_battery_sound();
}
else if (!new_discharging || (new_power_level == POWER_LEVEL_OK))
{
diff --git a/src/sound.c b/src/sound.c
new file mode 100644
index 0000000..d92aee8
--- /dev/null
+++ b/src/sound.c
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2015 Canonical Ltd.
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 3, as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranties of
+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Charles Kerr <charles.kerr@canonical.com>
+ */
+
+#include "sound.h"
+
+#include <gio/gio.h>
+
+void
+sound_play_file(const char* filename)
+{
+ g_message("playing sound '%s'", filename);
+}
+
diff --git a/src/sound.h b/src/sound.h
new file mode 100644
index 0000000..a241e5d
--- /dev/null
+++ b/src/sound.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2015 Canonical Ltd.
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 3, as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranties of
+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Charles Kerr <charles.kerr@canonical.com>
+ */
+
+#ifndef __INDICATOR_POWER_SOUND_H__
+#define __INDICATOR_POWER_SOUND_H__
+
+#include <gio/gio.h>
+
+G_BEGIN_DECLS
+
+void sound_play_file(const char* filename);
+
+G_END_DECLS
+
+#endif /* __INDICATOR_POWER_SOUND_H__ */