Skip to content

Commit 520b4db

Browse files
committed
1 parent 1e43299 commit 520b4db

File tree

2 files changed

+26
-31
lines changed

2 files changed

+26
-31
lines changed

files/usr/share/cinnamon/applets/[email protected]/applet.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const VOLUME_ADJUSTMENT_STEP = 0.05; /* Volume adjustment step in % */
3939
const ICON_SIZE = 28;
4040

4141
const CINNAMON_DESKTOP_SOUNDS = "org.cinnamon.desktop.sound";
42-
const MAXIMUM_VOLUME_KEY = "maximum-volume";
42+
const OVERAMPLIFICATION_KEY = "allow-amplified-volume";
4343

4444
class ControlButton {
4545
constructor(icon, tooltip, callback, small = false) {
@@ -1023,8 +1023,8 @@ class CinnamonSoundApplet extends Applet.TextIconApplet {
10231023
this._control.connect('stream-removed', (...args) => this._onStreamRemoved(...args));
10241024

10251025
this._sound_settings = new Gio.Settings({ schema_id: CINNAMON_DESKTOP_SOUNDS });
1026-
this._volumeMax = this._sound_settings.get_int(MAXIMUM_VOLUME_KEY) / 100 * this._control.get_vol_max_norm();
10271026
this._volumeNorm = this._control.get_vol_max_norm();
1027+
this._volumeMax = this._volumeNorm;
10281028

10291029
this._streams = [];
10301030
this._devices = [];
@@ -1088,23 +1088,21 @@ class CinnamonSoundApplet extends Applet.TextIconApplet {
10881088
let appsys = Cinnamon.AppSystem.get_default();
10891089
appsys.connect("installed-changed", () => this._updateLaunchPlayer());
10901090

1091-
if (this._volumeMax > this._volumeNorm) {
1092-
this._outputVolumeSection.set_mark(this._volumeNorm / this._volumeMax);
1093-
}
1094-
1095-
this._sound_settings.connect("changed::" + MAXIMUM_VOLUME_KEY, () => this._on_sound_settings_change());
1091+
this._sound_settings.connect("changed::" + OVERAMPLIFICATION_KEY, () => this._on_overamplification_change());
1092+
this._on_overamplification_change();
10961093
}
10971094

10981095
_setKeybinding() {
10991096
Main.keybindingManager.addHotKey("sound-open-" + this.instance_id, this.keyOpen, Lang.bind(this, this._openMenu));
11001097
}
11011098

1102-
_on_sound_settings_change () {
1103-
this._volumeMax = this._sound_settings.get_int(MAXIMUM_VOLUME_KEY) / 100 * this._control.get_vol_max_norm();
1104-
if (this._volumeMax > this._volumeNorm) {
1105-
this._outputVolumeSection.set_mark(this._volumeNorm / this._volumeMax);
1099+
_on_overamplification_change () {
1100+
if (this._sound_settings.get_boolean(OVERAMPLIFICATION_KEY)) {
1101+
this._volumeMax = 1.5 * this._volumeNorm;
1102+
this._outputVolumeSection.set_mark(1/1.5);
11061103
}
11071104
else {
1105+
this._volumeMax = this._volumeNorm;
11081106
this._outputVolumeSection.set_mark(0);
11091107
}
11101108
this._outputVolumeSection._update();

files/usr/share/cinnamon/cinnamon-settings/modules/cs_sound.py

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
CINNAMON_SOUNDS = "org.cinnamon.sounds"
1212
CINNAMON_DESKTOP_SOUNDS = "org.cinnamon.desktop.sound"
13-
MAXIMUM_VOLUME_KEY = "maximum-volume"
13+
OVERAMPLIFICATION_KEY = "allow-amplified-volume"
1414

1515
DECAY_STEP = .15
1616

@@ -538,8 +538,7 @@ def buildLayout(self):
538538
sizeGroup = Gtk.SizeGroup.new(Gtk.SizeGroupMode.HORIZONTAL)
539539

540540
# output volume
541-
max_volume = self.sound_settings.get_int(MAXIMUM_VOLUME_KEY)
542-
self.outVolume = VolumeBar(self.controller.get_vol_max_norm(), max_volume, sizeGroup=sizeGroup)
541+
self.outVolume = VolumeBar(self.controller.get_vol_max_norm(), 100, sizeGroup=sizeGroup)
543542
devSettings.add_row(self.outVolume)
544543

545544
# balance
@@ -550,6 +549,11 @@ def buildLayout(self):
550549
self.woofer = BalanceBar("lfe", 0, self.controller.get_vol_max_norm(), sizeGroup=sizeGroup)
551550
devSettings.add_row(self.woofer)
552551

552+
# overamplification
553+
switch = GSettingsSwitch(_("Overamplification"), CINNAMON_DESKTOP_SOUNDS, OVERAMPLIFICATION_KEY)
554+
switch.set_tooltip_text(_("Allow the volume to exceed 100%, with reduced sound quality."))
555+
devSettings.add_row(switch)
556+
553557
## Input page
554558
page = SettingsPage()
555559
self.sidePage.stack.add_titled(page, "input", _("Input"))
@@ -569,7 +573,7 @@ def buildLayout(self):
569573
sizeGroup = Gtk.SizeGroup.new(Gtk.SizeGroupMode.HORIZONTAL)
570574

571575
# input volume
572-
self.inVolume = VolumeBar(self.controller.get_vol_max_norm(), max_volume, sizeGroup=sizeGroup)
576+
self.inVolume = VolumeBar(self.controller.get_vol_max_norm(), 100, sizeGroup=sizeGroup)
573577
devSettings.add_row(self.inVolume)
574578

575579
# input level
@@ -626,24 +630,17 @@ def buildLayout(self):
626630
noAppsMessage.pack_start(box, True, True, 0)
627631
self.appStack.add_named(noAppsMessage, "noAppsMessage")
628632

629-
## Settings page
630-
page = SettingsPage()
631-
self.sidePage.stack.add_titled(page, "settings", _("Settings"))
632-
633-
amplificationSection = page.add_section(_("Amplification"))
634-
self.maxVolume = Slider(_("Maximum volume: %d") % max_volume + "%", _("Reduced"), _("Amplified"), 1, 150, None, step=1, page=10, value=max_volume, gicon=None, iconName=None)
635-
self.maxVolume.adjustment.connect("value-changed", self.onMaxVolumeChanged)
636-
self.maxVolume.setMark(100)
637-
amplificationSection.add_row(self.maxVolume)
638-
639-
def onMaxVolumeChanged(self, adjustment):
640-
newValue = int(round(adjustment.get_value()))
641-
self.sound_settings.set_int(MAXIMUM_VOLUME_KEY, newValue)
642-
self.maxVolume.label.set_label(_("Maximum volume: %d") % newValue + "%")
643-
self.outVolume.adjustment.set_upper(newValue)
633+
self.sound_settings.connect(f"changed::{OVERAMPLIFICATION_KEY}", self.onOverAmplificationChanged)
634+
self.onOverAmplificationChanged()
635+
636+
def onOverAmplificationChanged(self, settings=None, key=None):
637+
overamplification = self.sound_settings.get_boolean(OVERAMPLIFICATION_KEY)
644638
self.outVolume.slider.clear_marks()
645-
if newValue > 100:
639+
if overamplification:
640+
self.outVolume.adjustment.set_upper(150)
646641
self.outVolume.setMark(100)
642+
else:
643+
self.outVolume.adjustment.set_upper(100)
647644

648645
def inializeController(self):
649646
self.controller = Cvc.MixerControl(name = "cinnamon")

0 commit comments

Comments
 (0)