✨ ags: new window management system, adjustments, use adwaita sans
This commit is contained in:
+39
-15
@@ -1,22 +1,25 @@
|
||||
import { App } from "astal/gtk3"
|
||||
import { Windows } from "./windows";
|
||||
import { Wireplumber } from "./scripts/volume";
|
||||
|
||||
import { runStyleHandler } from "./scripts/style-handler";
|
||||
import { handleArguments } from "./scripts/arg-handler";
|
||||
import { Time, timeout } from "astal/time";
|
||||
|
||||
import { OSD, OSDModes, setOSDMode } from "./window/OSD";
|
||||
import { ControlCenter } from "./window/ControlCenter";
|
||||
import { OSDModes, setOSDMode } from "./window/OSD";
|
||||
|
||||
import { Runner } from "./runner/Runner";
|
||||
import { PluginApps } from "./runner/plugins/apps";
|
||||
import { PluginShell } from "./runner/plugins/shell";
|
||||
import { PluginWebSearch } from "./runner/plugins/websearch";
|
||||
import { PluginMedia } from "./runner/plugins/media";
|
||||
import { Windows } from "./windows";
|
||||
import { Notifications } from "./scripts/notifications";
|
||||
import AstalNotifd from "gi://AstalNotifd";
|
||||
import { GObject } from "astal";
|
||||
|
||||
|
||||
let osdTimer: (Time|undefined);
|
||||
let connections = new Map<GObject.Object, (Array<number> | number)>();
|
||||
|
||||
const runnerPlugins: Array<Runner.Plugin> = [
|
||||
PluginApps,
|
||||
@@ -27,19 +30,39 @@ const runnerPlugins: Array<Runner.Plugin> = [
|
||||
|
||||
App.start({
|
||||
instanceName: "astal",
|
||||
requestHandler(request: string, response: (result: any) => void) {
|
||||
async requestHandler(request: string, response: (result: any) => void) {
|
||||
// console.log(`[LOG] Arguments received: ${request}`);
|
||||
response(handleArguments(request));
|
||||
response(await handleArguments(request));
|
||||
},
|
||||
main() {
|
||||
console.log(`[LOG] Initialized astal instance as: ${ App.instanceName || "astal" }`);
|
||||
App.vfunc_quit = () => {
|
||||
console.log("[LOG] Disconnecting stuff");
|
||||
connections.forEach((v, k) => Array.isArray(v) ?
|
||||
v.map(id => k.disconnect(id))
|
||||
: k.disconnect(v));
|
||||
};
|
||||
|
||||
console.log(`[LOG] Running Stylesheet handler`);
|
||||
|
||||
runStyleHandler();
|
||||
|
||||
//console.log(`[LOG] Starting to monitor scripts to automatically reload instance`);
|
||||
//monitorPaths(); // Only for debugging purposes(testing new widgets and stuff)
|
||||
|
||||
Wireplumber.getDefault().getDefaultSink().connect("notify::volume", () =>
|
||||
!Windows.isVisible(ControlCenter) && triggerOSD(OSDModes.SINK));
|
||||
connections.set(Wireplumber.getDefault(), [
|
||||
Wireplumber.getDefault().getDefaultSink().connect("notify::volume", () =>
|
||||
!Windows.isVisible("osd") && triggerOSD(OSDModes.SINK))
|
||||
]);
|
||||
|
||||
connections.set(Notifications.getDefault(), [
|
||||
Notifications.getDefault().connect("notification-added", (_, _notif: AstalNotifd.Notification) => {
|
||||
Windows.open("floating-notifications");
|
||||
}),
|
||||
Notifications.getDefault().connect("notification-removed", (_: Notifications, _id: number) => {
|
||||
_.notifications.length === 0 && Windows.close("floating-notifications");
|
||||
})
|
||||
]);
|
||||
|
||||
console.log(`[LOG] Adding runner plugins`);
|
||||
runnerPlugins.map(plugin => Runner.addPlugin(plugin));
|
||||
@@ -49,17 +72,18 @@ App.start({
|
||||
function triggerOSD(osdModeParam: OSDModes) {
|
||||
setOSDMode(osdModeParam);
|
||||
|
||||
Windows.open(OSD);
|
||||
if(!osdTimer) {
|
||||
Windows.open("osd");
|
||||
osdTimer = timeout(3000, () => {
|
||||
Windows.close(OSD);
|
||||
osdTimer = undefined;
|
||||
});
|
||||
} else {
|
||||
osdTimer.cancel();
|
||||
osdTimer = timeout(3000, () => {
|
||||
Windows.close(OSD);
|
||||
Windows.close("osd");
|
||||
osdTimer = undefined;
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
osdTimer.cancel();
|
||||
osdTimer = timeout(3000, () => {
|
||||
Windows.close("osd");
|
||||
osdTimer = undefined;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user