From cbf17a524ad51bef7fb034ca929f6f0da3fdb611 Mon Sep 17 00:00:00 2001 From: Robert Tari Date: Wed, 23 Feb 2022 02:28:41 +0100 Subject: Get Lomiri sounds path from lomiri-sounds pkg-config --- CMakeLists.txt | 7 ++++++- src/notifier.c | 12 ++++++++---- tests/test-notify.cc | 7 +++++-- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b8df4a8..a3eeb2e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,8 +79,13 @@ if (ENABLE_LOMIRI_FEATURES) APPEND SERVICE_DEPS lomiri-schemas + lomiri-sounds + ) + pkg_get_variable(LOMIRI_SOUNDSDIR lomiri-sounds soundsdir) + add_definitions ( + -DLOMIRI_FEATURES_ENABLED + -DLOMIRI_SOUNDSDIR="${LOMIRI_SOUNDSDIR}" ) - add_definitions (-DLOMIRI_FEATURES_ENABLED) endif () pkg_check_modules (SERVICE_DEPS REQUIRED ${SERVICE_DEPS}) diff --git a/src/notifier.c b/src/notifier.c index ba30ae5..e833e72 100644 --- a/src/notifier.c +++ b/src/notifier.c @@ -1,6 +1,6 @@ /* * Copyright 2014-2016 Canonical Ltd. - * Copyright 2021 Robert Tari + * Copyright 2021-2022 Robert Tari * * 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 @@ -22,7 +22,11 @@ #include "datafiles.h" #ifdef LOMIRI_FEATURES_ENABLED -#include "dbus-accounts-sound.h" + #include "dbus-accounts-sound.h" +#endif + +#ifndef LOMIRI_SOUNDSDIR + #define LOMIRI_SOUNDSDIR "" #endif #include "dbus-battery.h" @@ -322,8 +326,8 @@ notification_show(IndicatorPowerNotifier * self) } else { - g_message("Unable to find '%s' in XDG data dirs, falling back to /usr/share/sounds/lomiri/notifications/", LOW_BATTERY_SOUND); - notify_notification_set_hint(nn, "sound-file", g_variant_new_string("file:///usr/share/sounds/lomiri/notifications/" LOW_BATTERY_SOUND)); + g_message("Unable to find '%s' in XDG data dirs, falling back to %s/notifications/", LOMIRI_SOUNDSDIR, LOW_BATTERY_SOUND); + notify_notification_set_hint(nn, "sound-file", g_variant_new_string("file://" LOMIRI_SOUNDSDIR "/notifications/" LOW_BATTERY_SOUND)); } } diff --git a/tests/test-notify.cc b/tests/test-notify.cc index 0732ece..815b5d7 100644 --- a/tests/test-notify.cc +++ b/tests/test-notify.cc @@ -1,6 +1,6 @@ /* * Copyright 2014-2016 Canonical Ltd. - * Copyright 2021 Robert Tari + * Copyright 2021-2022 Robert Tari * * 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 @@ -19,6 +19,9 @@ * Robert Tari */ +#ifndef LOMIRI_SOUNDSDIR + #define LOMIRI_SOUNDSDIR "" +#endif #include "glib-fixture.h" @@ -391,7 +394,7 @@ TEST_F(NotifyFixture, EventsThatChangeNotifications) TRUE); // the file we expect to play on a low battery notification... - const char* expected_file = "/usr/share/sounds/lomiri/notifications/" LOW_BATTERY_SOUND; + const char* expected_file = LOMIRI_SOUNDSDIR "/notifications/" LOW_BATTERY_SOUND; char* tmp = g_filename_to_uri(expected_file, nullptr, nullptr); const std::string low_power_uri {tmp}; g_clear_pointer(&tmp, g_free); -- cgit v1.2.3 From 0a4e2ee68299b15e43651e265ead1cf6d1d5e419 Mon Sep 17 00:00:00 2001 From: Robert Tari Date: Wed, 23 Feb 2022 02:33:38 +0100 Subject: .build.yml: Add lomiri-sounds dependency and pull it from git fixes https://github.com/AyatanaIndicators/ayatana-indicator-power/issues/58 --- .build.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.build.yml b/.build.yml index 1add2ae..4284dc4 100644 --- a/.build.yml +++ b/.build.yml @@ -34,6 +34,7 @@ requires: - intltool # - libayatana-common-dev # - lomiri-schemas +# - lomiri-sounds - liblomiri-url-dispatcher-dev - gobject-introspection - libgirepository1.0-dev @@ -135,6 +136,17 @@ before_scripts: - make install - cd - - rm -Rf lomiri-schemas-build/ + - + - cd ${START_DIR} + - if [ ! -d lomiri-sounds-build ]; then + - git clone --depth 1 https://gitlab.com/ubports/core/lomiri-sounds.git lomiri-sounds-build + - fi + - cd lomiri-sounds-build + - cmake . -DCMAKE_INSTALL_PREFIX=/usr + - make + - make install + - cd - + - rm -Rf lomiri-sounds-build/ build_scripts: - if [ ${DISTRO_NAME} == "debian" ];then -- cgit v1.2.3