From 83c085702555e614db18e74376bfd1dc2df23c41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Guzm=C3=A1n?= <ark@switnet.org> Date: Sat, 9 Sep 2023 17:24:06 +0000 Subject: [PATCH] ayatana-indicator-sound: apply fix volume change notification on MATE and XFCE --- .../fix_volume_change_notification.patch | 214 ++++++++++++++++++ helpers/make-ayatana-indicator-sound | 31 +++ 2 files changed, 245 insertions(+) create mode 100644 helpers/DATA/ayatana-indicator-sound/fix_volume_change_notification.patch create mode 100644 helpers/make-ayatana-indicator-sound diff --git a/helpers/DATA/ayatana-indicator-sound/fix_volume_change_notification.patch b/helpers/DATA/ayatana-indicator-sound/fix_volume_change_notification.patch new file mode 100644 index 00000000..92b62593 --- /dev/null +++ b/helpers/DATA/ayatana-indicator-sound/fix_volume_change_notification.patch @@ -0,0 +1,214 @@ +Patch based on https://github.com/AyatanaIndicators/ayatana-indicator-sound/pull/92 +For Trisquel 11.0, Aramo - ayatana-indicator-sound - 22.2.0-2 + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index ac370b2..095c953 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,5 +1,5 @@ +-project(ayatana-indicator-sound C CXX) +-cmake_minimum_required(VERSION 3.13) ++cmake_minimum_required (VERSION 3.13) ++project (ayatana-indicator-sound VERSION 22.2.0 LANGUAGES C CXX) + + if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + SET(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "..." FORCE) +@@ -7,8 +7,6 @@ endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + + set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" "${CMAKE_MODULE_PATH}") + +-set(PACKAGE ${CMAKE_PROJECT_NAME}) +-set(PROJECT_VERSION 22.2.0) + find_package(PkgConfig REQUIRED) + include(GNUInstallDirs) + include(UseVala) +diff --git a/src/info-notification.vala b/src/info-notification.vala +index ce92a2a..3a36e52 100644 +--- a/src/info-notification.vala ++++ b/src/info-notification.vala +@@ -1,6 +1,6 @@ + /* + * Copyright 2015 Canonical Ltd. +- * Copyright 2021 Robert Tari ++ * Copyright 2021-2023 Robert Tari + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by +@@ -30,22 +30,26 @@ public class IndicatorSound.InfoNotification: Notification + public void show (VolumeControl.ActiveOutput active_output, + double volume, + bool is_high_volume) { +- if (!notify_server_supports ("x-canonical-private-synchronous")) +- return; + + /* Determine Label */ +- unowned string volume_label = get_notification_label (active_output); ++ string volume_label = get_notification_label (active_output); + + /* Choose an icon */ + unowned string icon = get_volume_notification_icon (active_output, volume, is_high_volume); + + /* Reset the notification */ + var n = _notification; ++ ++ uint nChars = ((int32)((volume * 20) + 0.5)).clamp(0, 20); ++ volume_label += "\n"; ++ ++ for (uint nChar = 0; nChar < nChars; nChar++) ++ { ++ volume_label += "â—¼"; ++ } ++ + n.update (_("Volume"), volume_label, icon); + n.clear_hints(); +- n.set_hint ("x-lomiri-non-shaped-icon", "true"); +- n.set_hint ("x-canonical-private-synchronous", "true"); +- n.set_hint ("x-lomiri-value-bar-tint", is_high_volume ? "true" : "false"); + n.set_hint ("value", ((int32)((volume * 100.0) + 0.5)).clamp(0, 100)); + show_notification (); + } +diff --git a/src/warn-notification.vala b/src/warn-notification.vala +index 6a08431..203758e 100644 +--- a/src/warn-notification.vala ++++ b/src/warn-notification.vala +@@ -1,5 +1,6 @@ + /* + * Copyright 2015 Canonical Ltd. ++ * Copyright 2021-2023 Robert Tari + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by +@@ -15,6 +16,7 @@ + * + * Authors: + * Charles Kerr <charles.kerr@canonical.com> ++ * Robert Tari <robert@tari.in> + */ + + public class IndicatorSound.WarnNotification: Notification +@@ -31,9 +33,6 @@ public class IndicatorSound.WarnNotification: Notification + _("Volume"), + _("Allow volume above safe level?\nHigh volume can damage your hearing."), + "audio-volume-high"); +- n.set_hint ("x-lomiri-non-shaped-icon", "true"); +- n.set_hint ("x-lomiri-snap-decisions", "true"); +- n.set_hint ("x-lomiri-private-affirmative-tint", "true"); + n.closed.connect ((n) => { + n.clear_actions (); + }); +diff --git a/tests/integration/indicator-sound-test-base.cpp b/tests/integration/indicator-sound-test-base.cpp +index 3ecd856..eb4ee8c 100644 +--- a/tests/integration/indicator-sound-test-base.cpp ++++ b/tests/integration/indicator-sound-test-base.cpp +@@ -1,6 +1,6 @@ + /* + * Copyright 2015 Canonical Ltd. +- * Copyright 2021 Robert Tari ++ * Copyright 2021-2023 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 +@@ -72,7 +72,7 @@ void IndicatorSoundTestBase::SetUp() + "GetCapabilities", + "", + "as", +- "ret = ['actions', 'body', 'body-markup', 'icon-static', 'image/svg+xml', 'x-canonical-private-synchronous', 'x-canonical-append', 'x-canonical-private-icon-only', 'x-canonical-truncation', 'private-synchronous', 'append', 'private-icon-only', 'truncation']" ++ "ret = ['actions', 'body', 'body-markup', 'icon-static', 'image/svg+xml', 'private-synchronous', 'append', 'private-icon-only', 'truncation']" + ).waitForFinished(); + + int waitedTime = 0; +@@ -647,14 +647,8 @@ void IndicatorSoundTestBase::checkVolumeNotification(double volume, QString cons + QVariantMap hints; + ASSERT_TRUE(qDBusArgumentToMap(args.at(6), hints)); + ASSERT_TRUE(hints.contains("value")); +- ASSERT_TRUE(hints.contains("x-lomiri-non-shaped-icon")); +- ASSERT_TRUE(hints.contains("x-lomiri-value-bar-tint")); +- ASSERT_TRUE(hints.contains("x-canonical-private-synchronous")); + + EXPECT_EQ(volume*100, hints["value"]); +- EXPECT_EQ(true, hints["x-lomiri-non-shaped-icon"]); +- EXPECT_EQ(isLoud, hints["x-lomiri-value-bar-tint"]); +- EXPECT_EQ(true, hints["x-canonical-private-synchronous"]); + } + + void IndicatorSoundTestBase::checkHighVolumeNotification(QVariantList call) +diff --git a/tests/notifications-mock.h b/tests/notifications-mock.h +index 49b2e66..3ae8da5 100644 +--- a/tests/notifications-mock.h ++++ b/tests/notifications-mock.h +@@ -1,6 +1,6 @@ + /* + * Copyright 2015 Canonical Ltd. +- * Copyright 2021 Robert Tari ++ * Copyright 2021-2023 Robert Tari + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by +@@ -31,7 +31,7 @@ class NotificationsMock + DbusTestDbusMockObject * baseobj = nullptr; + + public: +- NotificationsMock (const std::vector<std::string>& capabilities = {"actions", "body", "body-markup", "icon-static", "image/svg+xml", "x-canonical-private-synchronous", "x-canonical-append", "x-canonical-private-icon-only", "x-canonical-truncation", "private-synchronous", "append", "private-icon-only", "truncation"}) { ++ NotificationsMock (const std::vector<std::string>& capabilities = {"actions", "body", "body-markup", "icon-static", "image/svg+xml", "private-synchronous", "append", "private-icon-only", "truncation"}) { + mock = dbus_test_dbus_mock_new("org.freedesktop.Notifications"); + dbus_test_task_set_bus(DBUS_TEST_TASK(mock), DBUS_TEST_SERVICE_BUS_SESSION); + dbus_test_task_set_name(DBUS_TEST_TASK(mock), "Notify"); +diff --git a/tests/notifications-test.cc b/tests/notifications-test.cc +index a9fa55d..92f4672 100644 +--- a/tests/notifications-test.cc ++++ b/tests/notifications-test.cc +@@ -1,6 +1,6 @@ + /* + * Copyright 2015-2016 Canonical Ltd. +- * Copyright 2021 Robert Tari ++ * Copyright 2021-2023 Robert Tari + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by +@@ -259,7 +259,6 @@ TEST_F(NotificationsTest, VolumeChanges) { + EXPECT_EQ("ayatana-indicator-sound", notev[0].app_name); + EXPECT_EQ("Volume", notev[0].summary); + EXPECT_EQ(0, notev[0].actions.size()); +- EXPECT_GVARIANT_EQ("@s 'true'", notev[0].hints["x-canonical-private-synchronous"]); + EXPECT_GVARIANT_EQ("@i 50", notev[0].hints["value"]); + + /* Set a different volume */ +@@ -432,7 +431,6 @@ TEST_F(NotificationsTest, DISABLED_HighVolume) { + ASSERT_EQ(1, notev.size()); + EXPECT_EQ("Volume", notev[0].summary); + EXPECT_EQ("Speakers", notev[0].body); +- EXPECT_GVARIANT_EQ("@s 'false'", notev[0].hints["x-lomiri-value-bar-tint"]); + + /* Set high volume with volume change */ + notifications->clearNotifications(); +@@ -443,7 +441,6 @@ TEST_F(NotificationsTest, DISABLED_HighVolume) { + ASSERT_LT(0, notev.size()); /* This passes with one or two since it would just be an update to the first if a second was sent */ + EXPECT_EQ("Volume", notev[0].summary); + EXPECT_EQ("Speakers", notev[0].body); +- EXPECT_GVARIANT_EQ("@s 'true'", notev[0].hints["x-lomiri-value-bar-tint"]); + + /* Move it back */ + volume_warning_mock_set_high_volume(VOLUME_WARNING_MOCK(volumeWarning.get()), false); +@@ -513,7 +510,6 @@ TEST_F(NotificationsTest, DISABLED_ExtendendVolumeNotification) { + EXPECT_EQ("ayatana-indicator-sound", notev[0].app_name); + EXPECT_EQ("Volume", notev[0].summary); + EXPECT_EQ(0, notev[0].actions.size()); +- EXPECT_GVARIANT_EQ("@s 'true'", notev[0].hints["x-canonical-private-synchronous"]); + EXPECT_GVARIANT_EQ("@i 50", notev[0].hints["value"]); + + /* Allow an amplified volume */ +@@ -628,14 +624,10 @@ TEST_F(NotificationsTest, DISABLED_TriggerWarning) { + if (warning_expected) { + EXPECT_TRUE(volume_warning_get_active(volumeWarning.get())); + ASSERT_EQ(1, notev.size()); +- EXPECT_GVARIANT_EQ("@s 'true'", notev[0].hints["x-lomiri-snap-decisions"]); +- EXPECT_GVARIANT_EQ(nullptr, notev[0].hints["x-canonical-private-synchronous"]); + } + else { + EXPECT_FALSE(volume_warning_get_active(volumeWarning.get())); + ASSERT_EQ(1, notev.size()); +- EXPECT_GVARIANT_EQ(nullptr, notev[0].hints["x-lomiri-snap-decisions"]); +- EXPECT_GVARIANT_EQ("@s 'true'", notev[0].hints["x-canonical-private-synchronous"]); + } + + } // multimedia_active diff --git a/helpers/make-ayatana-indicator-sound b/helpers/make-ayatana-indicator-sound new file mode 100644 index 00000000..600b6aad --- /dev/null +++ b/helpers/make-ayatana-indicator-sound @@ -0,0 +1,31 @@ +#!/bin/sh +# +# Copyright (C) 2023 Luis Guzman <ark@switnet.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY 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, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# + +VERSION=1 + +. ./config + +# Remove helper once upstream version is 1.5.27 or later. + +# Apply patch to fix volume change notification +patch -p1 < $DATA/fix_volume_change_notification.patch + +changelog "Fix volume change notification on MATE and XFCE." + +compile -- GitLab