nosignal-shell/utils/system.ts
2025-01-14 18:15:09 +11:00

21 lines
753 B
TypeScript

import { execAsync, GLib } from "astal";
import type AstalApps from "gi://AstalApps";
import { osIcons } from "./icons";
export const launch = (app: AstalApps.Application) => {
execAsync(["uwsm", "app", "--", app.entry]).catch(() => {
app.frequency--; // Decrement frequency cause launch also increments it
app.launch();
});
app.frequency++;
};
export const osId = GLib.get_os_info("ID") ?? "unknown";
export const osIdLike = GLib.get_os_info("ID_LIKE");
export const osIcon = String.fromCodePoint(
(() => {
if (osIcons.hasOwnProperty(osId)) return osIcons[osId];
if (osIdLike) for (const id of osIdLike.split(" ")) if (osIcons.hasOwnProperty(id)) return osIcons[id];
return 0xf31a;
})()
);