diff --git a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp index a46c9907ed4fae..b7018946860634 100644 --- a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp @@ -192,7 +192,7 @@ class NotificationData final : public base::has_weak_ptr { const not_null _manager; NotificationId _id; - //Media::Audio::LocalDiskCache _sounds; + Media::Audio::LocalDiskCache _sounds; Gio::Application _application; Gio::Notification _notification; @@ -222,7 +222,7 @@ NotificationData::NotificationData( NotificationId id) : _manager(manager) , _id(id) -//, _sounds(cWorkingDir() + u"tdata/audio_cache"_q) +, _sounds(cWorkingDir() + u"tdata/audio_cache"_q) , _application(UseGNotification() ? Gio::Application::get_default() : nullptr) @@ -236,8 +236,7 @@ NotificationData::NotificationData( bool NotificationData::init(const Info &info) { const auto &title = info.title; const auto &subtitle = info.subtitle; - //const auto sound = info.sound ? info.sound() : Media::Audio::LocalSound(); - //const auto path = sound ? _sounds.path(sound) : QString(); + if (_application) { _notification = Gio::Notification::new_( subtitle.isEmpty() @@ -365,18 +364,23 @@ bool NotificationData::init(const Info &info) { _hints.insert_value("action-icons", GLib::Variant::new_boolean(true)); } - // suppress system sound if telegram sound activated, - // otherwise use system sound if (HasCapability("sound")) { - if (Core::App().settings().soundNotify()) { + const auto sound = info.sound + ? info.sound() + : Media::Audio::LocalSound(); + + const auto path = sound + ? _sounds.path(sound).toStdString() + : std::string(); + + if (!path.empty()) { _hints.insert_value( - "suppress-sound", - GLib::Variant::new_boolean(true)); + "sound-file", + GLib::Variant::new_string(path)); } else { - // sound name according to http://0pointer.de/public/sound-naming-spec.html _hints.insert_value( - "sound-name", - GLib::Variant::new_string("message-new-instant")); + "suppress-sound", + GLib::Variant::new_boolean(true)); } } @@ -624,8 +628,9 @@ bool ByDefault() { "actions", // To have quick reply "inline-reply", + }, HasCapability) && ranges::any_of(std::array{ // To not to play sound with Don't Disturb activated - // (no, using sound capability is not a way) + "sound", "inhibitions", }, HasCapability); } @@ -963,7 +968,9 @@ bool Manager::doSkipToast() const { } void Manager::doMaybePlaySound(Fn playSound) { - _private->invokeIfNotInhibited(std::move(playSound)); + if (UseGNotification() || !HasCapability("sound")) { + _private->invokeIfNotInhibited(std::move(playSound)); + } } void Manager::doMaybeFlashBounce(Fn flashBounce) {