Files
colorshell/ags/scripts/utils.ts
T
retrozinndev e02f96b151 feat(control-center/network): add provisory support for wireless connections
I call it "provisory" because I don't have a Wi-Fi card to test it, but in theory, everything should work
2025-06-19 19:10:25 -03:00

32 lines
939 B
TypeScript

import { exec, execAsync, Gio, GLib } from "astal";
export const decoder = new TextDecoder("utf-8"),
encoder = new TextEncoder();
export function getHyprlandInstanceSig(): (string|null) {
return GLib.getenv("HYPRLAND_INSTANCE_SIGNATURE");
}
export function getHyprlandVersion(): string {
return exec(`${GLib.getenv("HYPRLAND_CMD") || "Hyprland"} --version | head -n1`).split(" ")[1];
}
export function makeDirectory(dir: string): void {
execAsync([ "mkdir", "-p", dir ]);
}
export function deleteFile(path: string): void {
execAsync([ "rm", "-r", path ]);
}
export function isInstalled(commandName: string): boolean {
const proc = Gio.Subprocess.new(["bash", "-c", `command -v ${commandName}`],
Gio.SubprocessFlags.STDOUT_PIPE | Gio.SubprocessFlags.STDERR_PIPE);
const [ , stdout, stderr ] = proc.communicate_utf8(null, null);
if(stdout && !stderr)
return true;
return false;
}