From b2f3af26e460b0cdf5adac22f43bfca11b5832db Mon Sep 17 00:00:00 2001 From: Zhang Xianwei Date: Tue, 27 Nov 2018 14:17:58 +0800 Subject: media-keys: Make sound changes quiet with Alt +volume control keys will change the sound, without playing a notification sound, which can be useful when things need to be quiet. This uses the settings stored in GSettings for those audio keys. Signed-off-by: Zhang Xianwei --- ...ettingsDaemon.plugins.media-keys.gschema.xml.in | 15 +++++++++++ plugins/media-keys/acme.h | 6 +++++ plugins/media-keys/msd-media-keys-manager.c | 31 ++++++++++++++++++---- 3 files changed, 47 insertions(+), 5 deletions(-) diff --git a/data/org.mate.SettingsDaemon.plugins.media-keys.gschema.xml.in b/data/org.mate.SettingsDaemon.plugins.media-keys.gschema.xml.in index 8cea9ee..8983272 100644 --- a/data/org.mate.SettingsDaemon.plugins.media-keys.gschema.xml.in +++ b/data/org.mate.SettingsDaemon.plugins.media-keys.gschema.xml.in @@ -40,6 +40,21 @@ Volume up Binding to raise the system volume. + + '<Alt>XF86AudioMute' + Mute the audio quietly + Binding to mute the system volume quietly. + + + '<Alt>XF86AudioLowerVolume' + Turn the volume down quietly + Binding to lower the system volume quietly. + + + '<Alt>XF86AudioRaiseVolume' + Turn the volume up quietly + Binding to raise the system volume quietly. + '<Control><Alt>Delete' Shut down diff --git a/plugins/media-keys/acme.h b/plugins/media-keys/acme.h index 8ab55fe..8d6aba2 100644 --- a/plugins/media-keys/acme.h +++ b/plugins/media-keys/acme.h @@ -32,6 +32,9 @@ enum { MUTE_KEY, VOLUME_DOWN_KEY, VOLUME_UP_KEY, + MUTE_QUIET_KEY, + VOLUME_DOWN_QUIET_KEY, + VOLUME_UP_QUIET_KEY, POWER_KEY, EJECT_KEY, HOME_KEY, @@ -74,6 +77,9 @@ static struct { { MUTE_KEY, "volume-mute", NULL, NULL }, { VOLUME_DOWN_KEY, "volume-down", NULL, NULL }, { VOLUME_UP_KEY, "volume-up", NULL, NULL }, + { MUTE_QUIET_KEY, "volume-mute-quiet", NULL, NULL }, + { VOLUME_DOWN_QUIET_KEY, "volume-down-quiet", NULL, NULL }, + { VOLUME_UP_QUIET_KEY, "volume-up-quiet", NULL, NULL }, { POWER_KEY, "power", NULL, NULL }, { EJECT_KEY, "eject", NULL, NULL }, { HOME_KEY, "home", NULL, NULL }, diff --git a/plugins/media-keys/msd-media-keys-manager.c b/plugins/media-keys/msd-media-keys-manager.c index a4e958a..33ac891 100644 --- a/plugins/media-keys/msd-media-keys-manager.c +++ b/plugins/media-keys/msd-media-keys-manager.c @@ -634,7 +634,8 @@ static void update_dialog (MsdMediaKeysManager *manager, guint volume, gboolean muted, - gboolean sound_changed) + gboolean sound_changed, + gboolean quiet) { if (muted) volume = 0.0; @@ -651,7 +652,7 @@ update_dialog (MsdMediaKeysManager *manager, dialog_show (manager); #ifdef HAVE_LIBCANBERRA - if (sound_changed != FALSE && muted == FALSE) + if (quiet == FALSE && sound_changed != FALSE && muted == FALSE) ca_gtk_play_for_widget (manager->priv->dialog, 0, CA_PROP_EVENT_ID, "audio-volume-change", CA_PROP_EVENT_DESCRIPTION, "Volume changed through key press", @@ -663,7 +664,9 @@ update_dialog (MsdMediaKeysManager *manager, } static void -do_sound_action (MsdMediaKeysManager *manager, int type) +do_sound_action (MsdMediaKeysManager *manager, + int type, + gboolean quiet) { gboolean muted; gboolean muted_last; @@ -735,7 +738,8 @@ do_sound_action (MsdMediaKeysManager *manager, int type) update_dialog (manager, CLAMP (100 * volume / (volume_max - volume_min), 0, 100), muted, - sound_changed); + sound_changed, + quiet); } static void @@ -1099,7 +1103,22 @@ do_action (MsdMediaKeysManager *manager, case VOLUME_DOWN_KEY: case VOLUME_UP_KEY: #ifdef HAVE_LIBMATEMIXER - do_sound_action (manager, type); + do_sound_action (manager, type, FALSE); +#endif + break; + case MUTE_QUIET_KEY: +#ifdef HAVE_LIBMATEMIXER + do_sound_action (manager, MUTE_KEY, TRUE); +#endif + break; + case VOLUME_DOWN_QUIET_KEY: +#ifdef HAVE_LIBMATEMIXER + do_sound_action (manager, VOLUME_DOWN_KEY, TRUE); +#endif + break; + case VOLUME_UP_QUIET_KEY: +#ifdef HAVE_LIBMATEMIXER + do_sound_action (manager, VOLUME_UP_KEY, TRUE); #endif break; case POWER_KEY: @@ -1250,6 +1269,8 @@ acme_filter_events (GdkXEvent *xevent, switch (keys[i].key_type) { case VOLUME_DOWN_KEY: case VOLUME_UP_KEY: + case VOLUME_DOWN_QUIET_KEY: + case VOLUME_UP_QUIET_KEY: /* auto-repeatable keys */ if (xev->type != KeyPress) { return GDK_FILTER_CONTINUE; -- cgit v1.2.1