[AGS] Brightness control

This commit is contained in:
Janis Hutz 2025-04-26 13:18:00 +02:00
parent a7e6584f78
commit 1239f49cc7
3 changed files with 20 additions and 7 deletions

View File

@ -4,11 +4,22 @@ import Brightness from "../../../../util/brightness";
const brightness = Brightness.get_default(); const brightness = Brightness.get_default();
const BrightnessModule = () => { const BrightnessModule = () => {
const setBrightness = ( value: number ) => {
brightness.set_property('screen', value);
}
return ( return (
<box visible={bind(brightness, 'screenAvailable')}> <box visible={bind(brightness, 'screenAvailable')}>
<image iconName={"brightness-high-symbolic"}></image> <image iconName={"brightness-high-symbolic"}></image>
<label label={bind(brightness, "screen").as(b => b + "%")}></label> <label label={bind(brightness, "screen").as(b => b + "%")}></label>
<slider></slider> <slider
value={bind(brightness, "screen")}
hexpand
max={100}
min={0}
step={1}
vexpand
onChangeValue={self => setBrightness(self.value)}
></slider>
</box> </box>
); );
}; };

View File

@ -61,6 +61,6 @@ window.Bar {
} }
.quick-view-symbol { .quick-view-symbol {
margin: 3px; margin: 2px;
} }
} }

View File

@ -143,11 +143,13 @@ const BrightnessWidget = () => {
const screen_brightness = bind(brightness, "screen"); const screen_brightness = bind(brightness, "screen");
return ( return (
<label <box cssClasses={["quick-view-symbol"]}>
label={"🌣" + screen_brightness} <image iconName={"brightness-high-symbolic"}></image>
visible={bind(brightness, "screenAvailable")} <label
cssClasses={["quick-view-symbol"]} label={screen_brightness.as(b => '' + Math.round(100 * b))}
></label> visible={bind(brightness, "screenAvailable")}
></label>
</box>
); );
}; };