[Astal] Format
This commit is contained in:
		| @@ -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<number, string>(); | ||||
|  | ||||
|         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 <brightness> unspecified' ); | ||||
|  | ||||
|                             return; | ||||
|                         } | ||||
|                     } else { | ||||
|                         res( 'Unknown command ' + args[ 1 ] ); | ||||
|  | ||||
|                         return; | ||||
|                     } | ||||
|  | ||||
|                     res( 'Ok' ); | ||||
|                 } else { | ||||
|                     res( 'No controllable screen available' ); | ||||
| @@ -99,5 +111,4 @@ App.start({ | ||||
|         //     } | ||||
|         // } | ||||
|     }, | ||||
| }) | ||||
|  | ||||
| } ); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user