Skip to content

Commit

Permalink
[sound150@claudiux] v7.1.0 - Option to try to avoid loud cracking sou…
Browse files Browse the repository at this point in the history
…nd at shutdown (#6496)

* v7.1.0 - Option to try to avoid loud carcking sound at shutdown

* v7.1.0 - Also for Cinnamon 6.4
  • Loading branch information
claudiux authored Oct 13, 2024
1 parent d5a76f2 commit 7555cee
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 6 deletions.
12 changes: 9 additions & 3 deletions sound150@claudiux/files/sound150@claudiux/5.4/applet.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ class VolumeSlider extends PopupMenu.PopupSliderMenuItem {
let icon = Gio.Icon.new_for_string(this._volumeToIcon(this._value));

if (this.applet.showOSD) {
Main.osdWindowManager.show(-1, icon, Math.round(volume/this.applet._volumeNorm * 100), null);
Main.osdWindowManager.show(-1, icon, ""+Math.round(volume/this.applet._volumeNorm * 100), null);
}


Expand Down Expand Up @@ -1806,6 +1806,7 @@ class Sound150Applet extends Applet.TextIconApplet {
this.settings.bind("tooltipShowArtistTitle", "tooltipShowArtistTitle", this.on_settings_changed);

this.settings.bind("alwaysCanChangeMic", "alwaysCanChangeMic", this.on_settings_changed);
this.settings.bind("avoidCrackingAtShutdown", "avoidCrackingAtShutdown", null);

this._sounds_settings = new Gio.Settings({ schema_id: CINNAMON_DESKTOP_SOUNDS });
this.settings.setValue("volumeSoundFile", this._sounds_settings.get_string(VOLUME_SOUND_FILE_KEY));
Expand Down Expand Up @@ -2206,6 +2207,11 @@ class Sound150Applet extends Applet.TextIconApplet {
}

on_applet_removed_from_panel() {
if (this.avoidCrackingAtShutdown && this._output && !this._output.is_muted) {
let old_volume = this.volume;
this._toggle_out_mute();
this.volume = old_volume;
}
Main.keybindingManager.removeHotKey("sound-open-" + this.instance_id);
Main.keybindingManager.removeHotKey("switch-player-" + this.instance_id);
try {
Expand Down Expand Up @@ -2414,8 +2420,8 @@ class Sound150Applet extends Applet.TextIconApplet {
this.set_applet_icon_symbolic_name(icon_name);
if (this.showOSD) {
//~ Main.osdWindowManager.hideAll();
Main.osdWindowManager.show(-1, icon, volume, null);
//Main.osdWindowManager.show(0, icon, volume, true);
Main.osdWindowManager.show(-1, icon, ""+volume, null);
//Main.osdWindowManager.show(0, icon, ""+volume, true);
}
var intervalId = null;
intervalId = Util.setInterval(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@
"stepVolume",
"magneticOn",
"magnetic25On",
"alwaysCanChangeMic"
"alwaysCanChangeMic",
"avoidCrackingAtShutdown"
]
},
"sectionSound2": {
Expand Down Expand Up @@ -361,6 +362,11 @@
"tooltip": "Always show the 'Mute input' switch in the context menu.",
"default": true
},
"avoidCrackingAtShutdown": {
"type": "switch",
"description": "Try to avoid loud cracking sound at shutdown",
"default": true
},
"showMediaKeysOSD": {
"type": "combobox",
"default": "medium",
Expand Down
6 changes: 6 additions & 0 deletions sound150@claudiux/files/sound150@claudiux/6.4/applet.js
Original file line number Diff line number Diff line change
Expand Up @@ -1808,6 +1808,7 @@ class Sound150Applet extends Applet.TextIconApplet {
this.settings.bind("tooltipShowArtistTitle", "tooltipShowArtistTitle", this.on_settings_changed);

this.settings.bind("alwaysCanChangeMic", "alwaysCanChangeMic", this.on_settings_changed);
this.settings.bind("avoidCrackingAtShutdown", "avoidCrackingAtShutdown", null);

this._sounds_settings = new Gio.Settings({ schema_id: CINNAMON_DESKTOP_SOUNDS });
this.settings.setValue("volumeSoundFile", this._sounds_settings.get_string(VOLUME_SOUND_FILE_KEY));
Expand Down Expand Up @@ -2230,6 +2231,11 @@ class Sound150Applet extends Applet.TextIconApplet {
}

on_applet_removed_from_panel() {
if (this.avoidCrackingAtShutdown && this._output && !this._output.is_muted) {
let old_volume = this.volume;
this._toggle_out_mute();
this.volume = old_volume;
}
Main.keybindingManager.removeHotKey("sound-open-" + this.instance_id);
Main.keybindingManager.removeHotKey("switch-player-" + this.instance_id);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@
"stepVolume",
"magneticOn",
"magnetic25On",
"alwaysCanChangeMic"
"alwaysCanChangeMic",
"avoidCrackingAtShutdown"
]
},
"sectionSound2": {
Expand Down Expand Up @@ -377,6 +378,11 @@
"tooltip": "Always show the 'Mute input' switch in the context menu.",
"default": true
},
"avoidCrackingAtShutdown": {
"type": "switch",
"description": "Try to avoid loud cracking sound at shutdown",
"default": true
},
"showMediaKeysOSD": {
"type": "combobox",
"default": "medium",
Expand Down
4 changes: 4 additions & 0 deletions sound150@claudiux/files/sound150@claudiux/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### v7.1.0~20241013
* Option to try to avoid loud cracking sound at shutdown.
* Fixes https://github.com/linuxmint/cinnamon/issues/12446.

### v7.0.0~20241011
* Compatible with Cinnamon 6.4.

Expand Down
2 changes: 1 addition & 1 deletion sound150@claudiux/files/sound150@claudiux/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"max-instances": "1",
"description": "Enhanced sound applet",
"hide-configuration": false,
"version": "7.0.0",
"version": "7.1.0",
"cinnamon-version": [
"2.8",
"3.0",
Expand Down

0 comments on commit 7555cee

Please sign in to comment.