Skip to content

Commit

Permalink
Adds a shift-middle click action to the sound applet.
Browse files Browse the repository at this point in the history
When discussing the MuteToggler@jebeaudet.com spice in
linuxmint/cinnamon-spices-applets#5090, we
noticed that most of its functionality is already there. I noticed that
it might be a good idea to be able to start/stop the player but also
mute/unmute the microphone by mouse without diving into the right-click
menu. So I added a option for shift-middle-click very similar to the
middle-click option.
  • Loading branch information
sphh authored and mtwebster committed Feb 9, 2024
1 parent 6461e1c commit b8dd765
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 9 deletions.
34 changes: 25 additions & 9 deletions files/usr/share/cinnamon/applets/sound@cinnamon.org/applet.js
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,7 @@ class CinnamonSoundApplet extends Applet.TextIconApplet {
this.settings = new Settings.AppletSettings(this, metadata.uuid, instanceId);
this.settings.bind("showtrack", "showtrack", this.on_settings_changed);
this.settings.bind("middleClickAction", "middleClickAction");
this.settings.bind("middleShiftClickAction", "middleShiftClickAction");
this.settings.bind("horizontalScroll", "horizontalScroll")
this.settings.bind("showalbum", "showalbum", this.on_settings_changed);
this.settings.bind("truncatetext", "truncatetext", this.on_settings_changed);
Expand Down Expand Up @@ -1220,19 +1221,34 @@ class CinnamonSoundApplet extends Applet.TextIconApplet {

_onButtonPressEvent (actor, event) {
let buttonId = event.get_button();
let modifiers = Cinnamon.get_event_state(event);
let shiftPressed = (modifiers & Clutter.ModifierType.SHIFT_MASK);

//mute or play / pause players on middle click
if (buttonId === 2) {
if (this.middleClickAction === "mute") {
if (this._output.is_muted === this._input.is_muted)
if (shiftPressed) {
if (this.middleShiftClickAction === "mute") {
if (this._output.is_muted === this._input.is_muted)
this._toggle_in_mute();
this._toggle_out_mute();
} else if (this.middleShiftClickAction === "out_mute")
this._toggle_out_mute();
else if (this.middleShiftClickAction === "in_mute")
this._toggle_in_mute();
this._toggle_out_mute();
} else if (this.middleClickAction === "out_mute")
this._toggle_out_mute();
else if (this.middleClickAction === "in_mute")
this._toggle_in_mute();
else if (this.middleClickAction === "player")
this._players[this._activePlayer]._mediaServerPlayer.PlayPauseRemote();
else if (this.middleShiftClickAction === "player")
this._players[this._activePlayer]._mediaServerPlayer.PlayPauseRemote();
} else {
if (this.middleClickAction === "mute") {
if (this._output.is_muted === this._input.is_muted)
this._toggle_in_mute();
this._toggle_out_mute();
} else if (this.middleClickAction === "out_mute")
this._toggle_out_mute();
else if (this.middleClickAction === "in_mute")
this._toggle_in_mute();
else if (this.middleClickAction === "player")
this._players[this._activePlayer]._mediaServerPlayer.PlayPauseRemote();
}
} else if (buttonId === 8) { // previous and next track on mouse buttons 4 and 5 (8 and 9 by X11 numbering)
this._players[this._activePlayer]._mediaServerPlayer.PreviousRemote();
} else if (buttonId === 9) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,17 @@
},
"description": "Action on middle click"
},
"middleShiftClickAction": {
"type": "combobox",
"default": "in_mute",
"options": {
"Toggle Mute": "mute",
"Toggle Mute output": "out_mute",
"Toggle Mute input": "in_mute",
"Toggle Play / Pause": "player"
},
"description": "Action on shift+middle click"
},
"horizontalScroll": {
"type": "switch",
"default": false,
Expand Down

0 comments on commit b8dd765

Please sign in to comment.