Skip to content

Commit

Permalink
User can set maximum volume
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiux committed Oct 12, 2024
1 parent d15b36e commit bd494b6
Show file tree
Hide file tree
Showing 13 changed files with 4,267 additions and 3,099 deletions.
54 changes: 32 additions & 22 deletions sound150@claudiux/files/sound150@claudiux/6.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) {
// ~ logDebug("volume: "+volume);
//~ logDebug("volume: "+volume);
Main.osdWindowManager.show(-1, icon, Math.round(volume/this.applet._volumeNorm * 100), null);
}

Expand Down Expand Up @@ -1814,8 +1814,7 @@ class Sound150Applet extends Applet.TextIconApplet {
this.settings.bind("volumeSoundFile", "volumeSoundFile", this.on_volumeSoundFile_changed);
this.settings.setValue("volumeSoundEnabled", this._sounds_settings.get_boolean(VOLUME_SOUND_ENABLED_KEY));
this.settings.bind("volumeSoundEnabled", "volumeSoundEnabled", this.on_volumeSoundEnabled_changed);
this.settings.setValue("allowOveramplification", this._sounds_settings.get_boolean(OVERAMPLIFICATION_KEY));
this.settings.bind("allowOveramplification", "allowOveramplification", this._on_overamplification_change);
this.settings.bind("maxVolume", "maxVolume", (value) => this._on_maxVolume_changed(value));

this.settings.setValue("showMediaKeysOSD", global.settings.get_string(SHOW_MEDIA_KEYS_OSD_KEY));
this.settings.bind("showMediaKeysOSD", "showMediaKeysOSD", this.on_showMediaKeysOSD_changed);
Expand Down Expand Up @@ -1996,7 +1995,7 @@ class Sound150Applet extends Applet.TextIconApplet {
//~ this._loopArtId = null;
//~ this.loopArt();
}

on_volumeSoundFile_changed() {
this._sounds_settings.set_string(VOLUME_SOUND_FILE_KEY, this.volumeSoundFile);
}
Expand Down Expand Up @@ -2167,21 +2166,32 @@ class Sound150Applet extends Applet.TextIconApplet {
}
});
} // End of _setKeybinding

_on_overamplification_change() {
this._sounds_settings.set_boolean(OVERAMPLIFICATION_KEY, this.allowOveramplification);
}

_on_maxVolume_changed(value) {
if (value > 100) {
this._sound_settings.set_boolean(OVERAMPLIFICATION_KEY, true);
} else {
this._sound_settings.set_boolean(OVERAMPLIFICATION_KEY, false);
}
this._on_sound_settings_change();
}

_on_sound_settings_change() {
if (this._sound_settings.get_boolean(OVERAMPLIFICATION_KEY)) {
this.allowOveramplification = true;
this._volumeMax = 1.5 * this._volumeNorm;
this._outputVolumeSection.set_mark(1/1.5);
if (!this._sound_settings.get_boolean(OVERAMPLIFICATION_KEY) && this.maxVolume > 100) {
this.maxVolume = 100;
}
this._volumeMax = this.maxVolume / 100 * this._volumeNorm;
if (this.maxVolume > 100)
this._outputVolumeSection.set_mark(100/this.maxVolume);
else {
this.allowOveramplification = false;
this._volumeMax = this._volumeNorm;
this._outputVolumeSection.set_mark(0);
if (this.maxVolume === 100)
this._volumeMax = this._volumeNorm;
}
if (parseInt(this.volume.slice(0, -1)) > this.maxVolume) {
this.volume = "" + this.maxVolume + "%";
this._volumeChange(Clutter.ScrollDirection.DOWN);
this._volumeChange(Clutter.ScrollDirection.UP);
}
this._outputVolumeSection._update();
}
Expand All @@ -2206,12 +2216,12 @@ class Sound150Applet extends Applet.TextIconApplet {
}

on_applet_added_to_panel() {
this._on_sound_settings_change();
this.showOSD = this.showOSDonStartup && (this.showMediaKeysOSD != "disabled");
this._on_sound_settings_change();

this._loopArtId = null;
this.loopArt();

this.showOSD = this.showOSDonStartup && (this.showMediaKeysOSD != "disabled");

this.volume_near_icon()
}

Expand Down Expand Up @@ -2429,8 +2439,8 @@ class Sound150Applet extends Applet.TextIconApplet {
if (this.showOSD) {
//~ Main.osdWindowManager.hideAll();
try {
Main.osdWindowManager.show(-1, icon, volume, null);
} catch(e) {}
Main.osdWindowManager.show(-1, icon, volume, null);
} catch(e) {}
//Main.osdWindowManager.show(0, icon, volume, true);
}
var intervalId = null;
Expand Down Expand Up @@ -3008,9 +3018,9 @@ class Sound150Applet extends Applet.TextIconApplet {
changeColor = true;
}
else {
color = this.color0_100; //Default is "#e4e4e4";
color = this.color0_100; //Default is "#e4e4e4";
changeColor = true;
}
}
}
let _style = "color: %s;".format(color);

Expand Down Expand Up @@ -3227,7 +3237,7 @@ class Sound150Applet extends Applet.TextIconApplet {
}

_reset_colors() {
this.color0_100 = "#e4e4e4";
this.color0_100 = "#e4e4e4";
this.color101_115 = "yellow";
this.color116_130 = "orange";
this.color131_150 = "red";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"title": "Sound Settings",
"keys": [
"openSystemSoundSettings",
"allowOveramplification",
"maxVolume",
"stepVolume",
"magneticOn",
"magnetic25On",
Expand Down Expand Up @@ -298,11 +298,13 @@
"description": "System Sound Settings",
"callback": "_onSystemSoundSettingsPressed"
},
"allowOveramplification": {
"type": "switch",
"description": "Overamplification",
"default": false,
"tooltip": "Allow the volume to exceed 100%, with reduced sound quality."
"maxVolume": {
"type": "scale",
"description": "Maximum volume (%)",
"default": 100,
"min": 30,
"max": 150,
"step": 5
},
"stepVolume": {
"type": "combobox",
Expand Down
Loading

0 comments on commit bd494b6

Please sign in to comment.