[AGS] Fixes for bar
This commit is contained in:
@@ -2,18 +2,44 @@ 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";
|
||||
|
||||
App.start({
|
||||
instanceName: "runner",
|
||||
css: style,
|
||||
main() {
|
||||
const hypr = AstalHyprland.get_default();
|
||||
const monitors = App.get_monitors();
|
||||
for (let index = 0; index < monitors.length; index++) {
|
||||
Bar.Bar( monitors[ index ] );
|
||||
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 ) );
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Handle monitor add
|
||||
for (const monitor of hypr.monitors) {
|
||||
barCreator( monitor );
|
||||
}
|
||||
|
||||
hypr.connect( 'monitor-added', ( _, monitor ) => {
|
||||
barCreator( monitor );
|
||||
} );
|
||||
|
||||
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 );
|
||||
}
|
||||
} );
|
||||
},
|
||||
requestHandler(request, res) {
|
||||
const args = request.trimStart().split( ' ' );
|
||||
@@ -26,3 +52,4 @@ App.start({
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
|
Reference in New Issue
Block a user