Skip to content
Permalink
Browse files

media-keys: Make sound changes quiet with Alt

<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 <zhang.xianwei8@zte.com.cn>
  • Loading branch information...
zhangxianwei8 authored and raveit65 committed Nov 27, 2018
1 parent 0fdb1cd commit b2f3af26e460b0cdf5adac22f43bfca11b5832db
@@ -40,6 +40,21 @@
<summary>Volume up</summary>
<description>Binding to raise the system volume.</description>
</key>
<key name="volume-mute-quiet" type="s">
<default>'&lt;Alt&gt;XF86AudioMute'</default>
<summary>Mute the audio quietly</summary>
<description>Binding to mute the system volume quietly.</description>
</key>
<key name="volume-down-quiet" type="s">
<default>'&lt;Alt&gt;XF86AudioLowerVolume'</default>
<summary>Turn the volume down quietly</summary>
<description>Binding to lower the system volume quietly.</description>
</key>
<key name="volume-up-quiet" type="s">
<default>'&lt;Alt&gt;XF86AudioRaiseVolume'</default>
<summary>Turn the volume up quietly</summary>
<description>Binding to raise the system volume quietly.</description>
</key>
<key name="power" type="s">
<default>'&lt;Control&gt;&lt;Alt&gt;Delete'</default>
<summary>Shut down</summary>
@@ -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 },
@@ -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;

0 comments on commit b2f3af2

Please sign in to comment.
You can’t perform that action at this time.