Fixes a OSD bug when un-/muting and adds a toggle to display volume as 0 when muting (#151)
* added muted_zero option to only display 0 volume in osd when enabled * Fix OSD brightness persisting overflow class * Update modules/osd/bar/index.ts * Apply suggestions from code review --------- Co-authored-by: Jas Singh <jaskiratpal.singh@outlook.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { OSDOrientation } from "lib/types/options";
|
||||
import brightness from "services/Brightness"
|
||||
import options from "options"
|
||||
const audio = await Service.import("audio")
|
||||
|
||||
export const OSDLabel = (ort: OSDOrientation) => {
|
||||
@@ -15,19 +16,29 @@ export const OSDLabel = (ort: OSDOrientation) => {
|
||||
vpack: "center",
|
||||
setup: self => {
|
||||
self.hook(brightness, () => {
|
||||
self.class_names = self.class_names.filter(c => c !== "overflow");
|
||||
self.label = `${Math.round(brightness.screen * 100)}`;
|
||||
}, "notify::screen")
|
||||
self.hook(brightness, () => {
|
||||
self.class_names = self.class_names.filter(c => c !== "overflow");
|
||||
self.label = `${Math.round(brightness.kbd * 100)}`;
|
||||
}, "notify::kbd")
|
||||
self.hook(audio.microphone, () => {
|
||||
self.toggleClassName("overflow", audio.microphone.volume > 1)
|
||||
self.label = `${Math.round(audio.microphone.volume * 100)}`;
|
||||
}, "notify::volume")
|
||||
self.hook(audio.microphone, () => {
|
||||
self.toggleClassName("overflow", audio.microphone.volume > 1 && (!options.theme.osd.muted_zero.value || audio.microphone.is_muted === false));
|
||||
self.label = `${options.theme.osd.muted_zero.value && audio.microphone.is_muted !== false ? 0 : Math.round(audio.microphone.volume * 100)}`;
|
||||
}, "notify::is-muted")
|
||||
self.hook(audio.speaker, () => {
|
||||
self.toggleClassName("overflow", audio.speaker.volume > 1)
|
||||
self.label = `${Math.round(audio.speaker.volume * 100)}`;
|
||||
}, "notify::volume")
|
||||
self.hook(audio.speaker, () => {
|
||||
self.toggleClassName("overflow", audio.speaker.volume > 1 && (!options.theme.osd.muted_zero.value || audio.speaker.is_muted === false));
|
||||
self.label = `${options.theme.osd.muted_zero.value && audio.speaker.is_muted !== false ? 0 : Math.round(audio.speaker.volume * 100)}`;
|
||||
}, "notify::is-muted")
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user