mirror of
https://github.com/Theaninova/TheaninovOS.git
synced 2025-12-12 11:36:20 +00:00
feat: monitor brightness control
This commit is contained in:
@@ -56,8 +56,7 @@ export default () =>
|
|||||||
children: [
|
children: [
|
||||||
Row([Volume()], [SinkSelector(), AppMixer()]),
|
Row([Volume()], [SinkSelector(), AppMixer()]),
|
||||||
Microhone(),
|
Microhone(),
|
||||||
/*Brightness()*/
|
Brightness(),
|
||||||
,
|
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
Row(
|
Row(
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
import Widget from "resource:///com/github/Aylur/ags/widget.js";
|
import Widget from "resource:///com/github/Aylur/ags/widget.js";
|
||||||
import icons from "../../icons.js";
|
import icons from "../../icons.js";
|
||||||
import Brightness from "../../services/brightness.js";
|
import Brightness from "../../services/brightness.js";
|
||||||
|
import * as Utils from "resource:///com/github/Aylur/ags/utils.js";
|
||||||
|
|
||||||
|
const CanSupportBrightness = () => Utils.exec("which gbmonctl");
|
||||||
|
|
||||||
const BrightnessSlider = () =>
|
const BrightnessSlider = () =>
|
||||||
Widget.Slider({
|
Widget.Slider({
|
||||||
|
|||||||
@@ -42,13 +42,18 @@ class Brightness extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
set screen(percent) {
|
set screen(percent) {
|
||||||
if (!dependencies(["brightnessctl"])) return;
|
if (!dependencies(["gbmonctl"])) return;
|
||||||
|
|
||||||
if (percent < 0) percent = 0;
|
if (percent < 0) percent = 0;
|
||||||
|
|
||||||
if (percent > 1) percent = 1;
|
if (percent > 1) percent = 1;
|
||||||
|
|
||||||
Utils.execAsync(`brightnessctl s ${percent * 100}% -q`)
|
Utils.execAsync(
|
||||||
|
`gbmonctl --prop brightness -val ${Math.min(
|
||||||
|
Math.max(Math.floor(percent * 100), 0),
|
||||||
|
100,
|
||||||
|
)}`,
|
||||||
|
)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.#screen = percent;
|
this.#screen = percent;
|
||||||
this.changed("screen");
|
this.changed("screen");
|
||||||
|
|||||||
Reference in New Issue
Block a user