diff --git a/ags/scripts/reload-handler.ts b/ags/scripts/reload-handler.ts index 0f27449..3af6cbb 100644 --- a/ags/scripts/reload-handler.ts +++ b/ags/scripts/reload-handler.ts @@ -8,8 +8,8 @@ import Gio from "gi://Gio?version=2.0"; const monitoringPaths = [ "./scripts", "./window", "./app.ts", "env.d.ts" ]; -export function restartInstance(instanceName?: string): void { - execAsync(`astal -q ${ instanceName ?? App.instanceName ?? "astal" }`); +export function restartInstance(): void { + execAsync(`astal -q ${ App.instanceName ?? "astal" }`); Gio.Subprocess.new( ( uwsmIsActive ? [ "uwsm", "app", "--", "ags", "run" ] diff --git a/ags/scripts/stylesheet.ts b/ags/scripts/stylesheet.ts index d86b5cd..6fa452e 100644 --- a/ags/scripts/stylesheet.ts +++ b/ags/scripts/stylesheet.ts @@ -12,9 +12,11 @@ import GLib from "gi://GLib?version=2.0"; export class Stylesheet { private static instance: Stylesheet; #watchDelay: (AstalIO.Time|undefined); - #outputPath = Gio.File.new_for_path(`${GLib.get_user_state_dir()}/ags/style`); + #outputPath = Gio.File.new_for_path(`${GLib.get_user_cache_dir()}/colorshell/style`); #styles = [ "./style", "./style.scss" ]; + public get stylePath() { return this.#outputPath.get_path()!; } + public async compileSass(): Promise { console.log("Stylesheet: Compiling Sass"); diff --git a/ags/scripts/utils.ts b/ags/scripts/utils.ts index 62c1da1..281e01f 100644 --- a/ags/scripts/utils.ts +++ b/ags/scripts/utils.ts @@ -6,6 +6,7 @@ import { getSymbolicIcon } from "./apps"; import GLib from "gi://GLib?version=2.0"; import Gio from "gi://Gio?version=2.0"; +import Xdp from "gi://Xdp?version=1.0"; /** gnim doesn't export this, so we need to do it again */ @@ -13,9 +14,9 @@ export type WidgetNodeType = Array | JSX.Element | number | string export const decoder = new TextDecoder("utf-8"), encoder = new TextEncoder(); - export const time = createPoll(GLib.DateTime.new_now_local(), 500, () => GLib.DateTime.new_now_local()); +export const XdgPortal = Xdp.Portal.new(); export function getHyprlandInstanceSig(): (string|null) { return GLib.getenv("HYPRLAND_INSTANCE_SIGNATURE"); @@ -155,6 +156,15 @@ export function transformWidget( : fn(v)); } +export function filter( + v: Accessor>|Array, + fn: (v: ValueType, i: number, array: Array) => FilterReturnType +): Array|Accessor> { + return ((v instanceof Accessor) ? + v(v => v.filter((it, i, arr) => fn(it, i, arr))) + : v.filter((it, i, arr) => fn(it, i, arr))); +} + export function makeDirectory(dir: string): void { execAsync([ "mkdir", "-p", dir ]); }