diff options
author | Didier Roche <didrocks@ubuntu.com> | 2018-02-09 15:10:16 +0100 |
---|---|---|
committer | Florian Müllner <florian.muellner@gmail.com> | 2018-07-31 18:14:15 +0000 |
commit | 6217c3b88d837a8d03e524f0dcb89e8b7c5ee5d5 (patch) | |
tree | c313b6d18ad54aafc04117507ba5529882fccd70 | |
parent | ddd4fd9c2435eccc8f1ba296d64354d77061faf1 (diff) | |
download | gnome-shell-6217c3b88d837a8d03e524f0dcb89e8b7c5ee5d5.tar.gz |
volume: Show overamplified icon when in overdrive
Show an overamplified volume icon if volume is louder the max normalized one.
Use a similar logic as gnome-settings-daemon to delimit values, restricted
to output.
The purpose is to help users remember that visiting some websites or
using some apps can get LOUD.
https://bugzilla.gnome.org/show_bug.cgi?id=790280.
-rw-r--r-- | js/ui/status/volume.js | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/js/ui/status/volume.js b/js/ui/status/volume.js index b337e752d..00af791a6 100644 --- a/js/ui/status/volume.js +++ b/js/ui/status/volume.js @@ -158,17 +158,24 @@ var StreamSlider = new Lang.Class({ if (!this._stream) return null; + let icons = ["audio-volume-muted-symbolic", + "audio-volume-low-symbolic", + "audio-volume-medium-symbolic", + "audio-volume-high-symbolic", + "audio-volume-overamplified-symbolic"]; + let volume = this._stream.volume; + let n; if (this._stream.is_muted || volume <= 0) { - return 'audio-volume-muted-symbolic'; + n = 0; } else { - let n = Math.floor(3 * volume / this._control.get_vol_max_norm()) + 1; - if (n < 2) - return 'audio-volume-low-symbolic'; - if (n >= 3) - return 'audio-volume-high-symbolic'; - return 'audio-volume-medium-symbolic'; + n = Math.ceil(3 * volume / this._control.get_vol_max_norm()); + if (n < 1) + n = 1; + else if (n > 3) + n = 4; } + return icons[n]; }, getLevel() { |