Skip to content

Commit

Permalink
v7.3.4: New option to set volume at start-up (#6701)
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiux authored Dec 21, 2024
1 parent 4ef8a0d commit f96afbd
Show file tree
Hide file tree
Showing 17 changed files with 6,724 additions and 6,569 deletions.
15 changes: 13 additions & 2 deletions sound150@claudiux/files/sound150@claudiux/6.2/applet.js
Original file line number Diff line number Diff line change
Expand Up @@ -1773,7 +1773,7 @@ class Sound150Applet extends Applet.TextIconApplet {
this.title_text = "";

this.settings = new Settings.AppletSettings(this, metadata.uuid, instanceId);

this.settings.bind("startupVolume", "startupVolume");
this.settings.bind("isOverAmplificationPresent", "isOverAmplificationPresent");
this.settings.bind("isSetAmplificationPresent", "isSetAmplificationPresent");
this.settings.bind("isOpenSoundSettingsPresent", "isOpenSoundSettingsPresent");
Expand Down Expand Up @@ -2288,6 +2288,7 @@ class Sound150Applet extends Applet.TextIconApplet {
this.old_volume = this.volume;
this._toggle_out_mute();
this.volume = this.old_volume;
this.volume_near_icon()
}
Main.keybindingManager.removeHotKey("sound-open-" + this.instance_id);
Main.keybindingManager.removeHotKey("switch-player-" + this.instance_id);
Expand Down Expand Up @@ -2511,7 +2512,7 @@ class Sound150Applet extends Applet.TextIconApplet {
this._notifyVolumeChange(this._output);
this.setAppletTooltip();
this._applet_tooltip.show();
let volume = this.volume.slice(0, -1);
let volume = parseInt(this.volume.slice(0, -1));
let icon_name = "audio-volume";
if (volume > 100) icon_name += "-overamplified";
else if (volume <1) {
Expand Down Expand Up @@ -3169,6 +3170,16 @@ class Sound150Applet extends Applet.TextIconApplet {
this._outputVolumeSection.connectWithStream(this._output);
this._outputMutedId = this._output.connect("notify::is-muted", (...args) => this._mutedChanged(...args, "_output"));
this._mutedChanged(null, null, "_output");

if (this.startupVolume > -1) {
this.volume = ""+Math.round(this.startupVolume).toString()+"%";
this.old_volume = this.volume;

this._output.volume = Math.round(this.startupVolume) / 100 * this._volumeNorm;
this._output.push_volume();
this._volumeChange(Clutter.ScrollDirection.UP);
this._volumeChange(Clutter.ScrollDirection.DOWN);
}
} else {
this.setIcon("audio-volume-muted-symbolic", "output");
}
Expand Down
10 changes: 10 additions & 0 deletions sound150@claudiux/files/sound150@claudiux/6.2/settings-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
"openSystemSoundSettings",
"maxVolume",
"stepVolume",
"startupVolume",
"magneticOn",
"magnetic25On",
"alwaysCanChangeMic"
Expand Down Expand Up @@ -315,6 +316,15 @@
"max": 150,
"step": 5
},
"startupVolume": {
"type": "scale",
"description": "Volume at start-up (%)",
"default": -1,
"min": -1,
"max": 150,
"step": 1,
"tooltip": "Value -1 means \"No change\""
},
"stepVolume": {
"type": "combobox",
"default": 5,
Expand Down
25 changes: 18 additions & 7 deletions sound150@claudiux/files/sound150@claudiux/6.4/applet.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//"use strict";
"use strict";
const Applet = imports.ui.applet;
const Lang = imports.lang;
const Mainloop = imports.mainloop;
Expand Down Expand Up @@ -1774,6 +1774,7 @@ class Sound150Applet extends Applet.TextIconApplet {
this.title_text = "";

this.settings = new Settings.AppletSettings(this, metadata.uuid, instanceId);
this.settings.bind("startupVolume", "startupVolume");
this.settings.bind("showOSDonStartup", "showOSDonStartup");
this.showOSD = this.showOSDonStartup;
this.settings.bind("seekerTooltipDelay", "seekerTooltipDelay");
Expand Down Expand Up @@ -1834,12 +1835,13 @@ class Sound150Applet extends Applet.TextIconApplet {
this.settings.bind("volumeSoundEnabled", "volumeSoundEnabled", this.on_volumeSoundEnabled_changed);
this.settings.bind("maxVolume", "maxVolume", (value) => this._on_maxVolume_changed(value));

this.settings.bind("volume", "volume");

this.old_volume = this.volume;
this.settings.setValue("showMediaKeysOSD", global.settings.get_boolean(SHOW_MEDIA_KEYS_OSD_KEY));
this.settings.bind("showMediaKeysOSD", "showMediaKeysOSD", this.on_showMediaKeysOSD_changed);
this.showOSD = this.showOSDonStartup && this.showMediaKeysOSD;

this.settings.bind("volume", "volume");
this.old_volume = this.volume;
this.settings.bind("mic-level", "mic_level");
this.settings.bind("showVolumeLevelNearIcon", "showVolumeLevelNearIcon", this.volume_near_icon);
this.settings.bind("showMicMutedOnIcon", "showMicMutedOnIcon", () => this._on_sound_settings_change());
Expand Down Expand Up @@ -2009,10 +2011,6 @@ class Sound150Applet extends Applet.TextIconApplet {
appsys.connect("installed-changed", () => this._updateLaunchPlayer());

this._sound_settings.connect("changed::" + OVERAMPLIFICATION_KEY, () => this._on_sound_settings_change());
//~ this._on_sound_settings_change();

//~ this._loopArtId = null;
//~ this.loopArt();
}

on_volumeSoundFile_changed() {
Expand Down Expand Up @@ -2253,6 +2251,7 @@ class Sound150Applet extends Applet.TextIconApplet {
//~ this.color0_100 = color;

this.showOSD = this.showOSDonStartup && this.showMediaKeysOSD;

this._on_sound_settings_change();

this._loopArtId = null;
Expand All @@ -2270,7 +2269,9 @@ class Sound150Applet extends Applet.TextIconApplet {
this.old_volume = this.volume;
this._toggle_out_mute();
this.volume = this.old_volume;
this.volume_near_icon()
}

Main.keybindingManager.removeHotKey("sound-open-" + this.instance_id);
Main.keybindingManager.removeHotKey("switch-player-" + this.instance_id);
try {
Expand Down Expand Up @@ -3168,6 +3169,16 @@ class Sound150Applet extends Applet.TextIconApplet {
this._outputVolumeSection.connectWithStream(this._output);
this._outputMutedId = this._output.connect("notify::is-muted", (...args) => this._mutedChanged(...args, "_output"));
this._mutedChanged(null, null, "_output");

if (this.startupVolume > -1) {
this.volume = ""+Math.round(this.startupVolume).toString()+"%";
this.old_volume = this.volume;

this._output.volume = Math.round(this.startupVolume) / 100 * this._volumeNorm;
this._output.push_volume();
this._volumeChange(Clutter.ScrollDirection.UP);
this._volumeChange(Clutter.ScrollDirection.DOWN);
}
} else {
this.setIcon("audio-volume-muted-symbolic", "output");
}
Expand Down
10 changes: 10 additions & 0 deletions sound150@claudiux/files/sound150@claudiux/6.4/settings-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
"openSystemSoundSettings",
"maxVolume",
"stepVolume",
"startupVolume",
"magneticOn",
"magnetic25On",
"alwaysCanChangeMic"
Expand Down Expand Up @@ -306,6 +307,15 @@
"max": 150,
"step": 5
},
"startupVolume": {
"type": "scale",
"description": "Volume at start-up (%)",
"default": -1,
"min": -1,
"max": 150,
"step": 1,
"tooltip": "Value -1 means \"No change\""
},
"stepVolume": {
"type": "combobox",
"default": 5,
Expand Down
3 changes: 3 additions & 0 deletions sound150@claudiux/files/sound150@claudiux/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### v7.3.4~20241221
* New option to fix volume at start-up. Value -1 means "No change". (Related to #6690.)

### v7.3.3~20241212
* Improves compatibility with Cinnamon 6.4 removing "%" after volume level.

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.3.3",
"version": "7.3.4",
"cinnamon-version": [
"2.8",
"3.0",
Expand Down
Loading

0 comments on commit f96afbd

Please sign in to comment.