[AGS] Brightness: Fix, add CLI

This commit is contained in:
2025-04-27 10:48:07 +02:00
parent 364b5cb0ef
commit 710eeb7fb4
2 changed files with 33 additions and 7 deletions

View File

@@ -3,8 +3,7 @@ import style from "./style.scss"
import Bar from "./components/bar/Bar";
import AstalHyprland from "gi://AstalHyprland?version=0.1";
import { hyprToGdk } from "./util/hyprland";
import { writeFile } from "astal";
import Launcher from "./components/launcher/Launcher";
import Brightness from "./util/brightness";
App.start({
instanceName: "runner",
@@ -58,6 +57,32 @@ App.start({
// res( notifications.cliHandler( args ) );
} else if ( args[ 0 ] === 'bar' ) {
res( Bar.cliHandler( args ) );
} else if ( args[ 0 ] === 'brightness' ) {
try {
const brightness = Brightness.get_default();
if ( brightness.screenAvailable ) {
if ( args[ 1 ] === 'increase' ) {
brightness.screen += args.length > 1 ? parseInt( args[ 2 ] ) / 100 : 1;
} else if ( args[ 1 ] === 'decrease' ) {
brightness.screen -= args.length > 1 ? parseInt( args[ 2 ] ) / 100 : 1;
} else if ( args[ 1 ] === 'set' ) {
if ( args.length > 1 ) {
brightness.screen = parseInt( args[ 2 ] ) / 100;
} else {
res( 'Argument <brightness> unspecified' );
return;
}
} else {
res( 'Unknown command ' + args[ 1 ] );
return;
}
res( 'Ok' );
} else {
res( 'No controllable screen available' );
}
} catch ( e ) {
res( 'Error running brightness change' );
}
}
// } else if ( args[ 0 ] === 'launcher' ) {
// if ( args[ 1 ] === 'show' ) {