diff options
author | charles kerr <charlesk@canonical.com> | 2016-01-01 12:34:41 -0600 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2021-08-28 10:17:14 +0200 |
commit | 4fc7a4e4d0346e1aad32057536301620e138bf30 (patch) | |
tree | 2c9b43f774ef21ab40fe7560f9c0c8016159e507 /src/notifier.c | |
parent | c5f9fe4e21d24581aad7bfd7b73fb060aaf440ff (diff) | |
download | ayatana-indicator-power-4fc7a4e4d0346e1aad32057536301620e138bf30.tar.gz ayatana-indicator-power-4fc7a4e4d0346e1aad32057536301620e138bf30.tar.bz2 ayatana-indicator-power-4fc7a4e4d0346e1aad32057536301620e138bf30.zip |
add logic to call sound_play_file() when the low battery notification is shown
Diffstat (limited to 'src/notifier.c')
-rw-r--r-- | src/notifier.c | 30 |
1 files changed, 30 insertions, 0 deletions
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)) { |