Fixes #46 - Battery and Volume percentage values are now rounded to the nearest whole rather than down. (#52)
This commit is contained in:
@@ -35,7 +35,7 @@ const Volume = () => {
|
||||
|
||||
const volPct = Widget.Label({
|
||||
vpack: "center",
|
||||
label: audio.speaker.bind("volume").as((v) => `${Math.floor(v * 100)}%`),
|
||||
label: audio.speaker.bind("volume").as((v) => `${Math.round(v * 100)}%`),
|
||||
class_name: "bar-button-label volume",
|
||||
});
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ const renderActiveInput = () => {
|
||||
vpack: "end",
|
||||
label: audio.microphone
|
||||
.bind("volume")
|
||||
.as((v) => `${Math.floor(v * 100)}%`),
|
||||
.as((v) => `${Math.round(v * 100)}%`),
|
||||
}),
|
||||
],
|
||||
}),
|
||||
|
||||
@@ -57,7 +57,7 @@ const renderActivePlayback = () => {
|
||||
class_name: "menu-active-percentage playback",
|
||||
label: audio.speaker
|
||||
.bind("volume")
|
||||
.as((v) => `${Math.floor(v * 100)}%`),
|
||||
.as((v) => `${Math.round(v * 100)}%`),
|
||||
}),
|
||||
],
|
||||
}),
|
||||
|
||||
@@ -47,7 +47,7 @@ const Brightness = () => {
|
||||
class_name: "brightness-slider-label",
|
||||
label: brightness
|
||||
.bind("screen")
|
||||
.as((b) => `${Math.floor(b * 100)}%`),
|
||||
.as((b) => `${Math.round(b * 100)}%`),
|
||||
}),
|
||||
],
|
||||
}),
|
||||
|
||||
@@ -15,14 +15,14 @@ export const OSDLabel = (ort: OSDOrientation) => {
|
||||
vpack: "center",
|
||||
setup: self => {
|
||||
self.hook(brightness, () => {
|
||||
self.label = `${Math.floor(brightness.screen * 100)}`;
|
||||
self.label = `${Math.round(brightness.screen * 100)}`;
|
||||
}, "notify::screen")
|
||||
self.hook(brightness, () => {
|
||||
self.label = `${Math.floor(brightness.kbd * 100)}`;
|
||||
self.label = `${Math.round(brightness.kbd * 100)}`;
|
||||
}, "notify::kbd")
|
||||
self.hook(audio, () => {
|
||||
self.toggleClassName("overflow", audio.speaker.volume > 1)
|
||||
self.label = `${Math.floor(audio.speaker.volume * 100)}`;
|
||||
self.label = `${Math.round(audio.speaker.volume * 100)}`;
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
@@ -41,7 +41,7 @@ class Brightness extends Service {
|
||||
if (percent > 1)
|
||||
percent = 1
|
||||
|
||||
sh(`brightnessctl set ${Math.floor(percent * 100)}% -q`).then(() => {
|
||||
sh(`brightnessctl set ${Math.round(percent * 100)}% -q`).then(() => {
|
||||
this.#screen = percent
|
||||
this.changed("screen")
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user