From 9cf14d3b55ca302997286a2529568ad052221573 Mon Sep 17 00:00:00 2001 From: Janis Hutz Date: Fri, 17 Oct 2025 10:47:05 +0200 Subject: [PATCH] [Astal] Format --- config/astal/app.ts | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/config/astal/app.ts b/config/astal/app.ts index 8ee082d..92b46b4 100644 --- a/config/astal/app.ts +++ b/config/astal/app.ts @@ -1,26 +1,31 @@ -import { App } from "astal/gtk4" -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 Brightness from "./util/brightness"; +import { + App +} from 'astal/gtk4'; +import AstalHyprland from 'gi://AstalHyprland?version=0.1'; +import Bar from './components/bar/Bar'; +import Brightness from './util/brightness'; +import { + hyprToGdk +} from './util/hyprland'; +import style from './style.scss'; -App.start({ - instanceName: "runner", - css: style, - main() { +App.start( { + 'instanceName': 'runner', + 'css': style, + main () { const hypr = AstalHyprland.get_default(); const bars = new Map(); const barCreator = ( monitor: AstalHyprland.Monitor ) => { const gdkMonitor = hyprToGdk( monitor ); + if ( gdkMonitor ) { print( 'Bar added for screen ' + monitor.get_id() ); bars.set( monitor.get_id(), Bar.BarLauncher( gdkMonitor ) ); } - } + }; - for (const monitor of hypr.monitors) { + for ( const monitor of hypr.monitors ) { barCreator( monitor ); } @@ -30,14 +35,17 @@ App.start({ hypr.connect( 'monitor-removed', ( _, monitor ) => { const windowName = bars.get( monitor ); + if ( windowName ) { const win = App.get_window( windowName ); + if ( win ) { App.toggle_window( windowName ); win.set_child( null ); App.remove_window( win ); print( 'Bar removed for screen', monitor ); } + bars.delete( monitor ); } } ); @@ -49,7 +57,7 @@ App.start({ // } // Launcher(); }, - requestHandler(request, res) { + requestHandler ( request, res ) { const args = request.trimStart().split( ' ' ); if ( args[ 0 ] === 'notifier' ) { @@ -60,6 +68,7 @@ App.start({ } 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; @@ -70,12 +79,15 @@ App.start({ brightness.screen = parseInt( args[ 2 ] ) / 100; } else { res( 'Argument unspecified' ); + return; } } else { res( 'Unknown command ' + args[ 1 ] ); + return; } + res( 'Ok' ); } else { res( 'No controllable screen available' ); @@ -99,5 +111,4 @@ App.start({ // } // } }, -}) - +} );