summaryrefslogtreecommitdiff
path: root/utils/system.ts
blob: 9a328d5ec6af07f7b839d45d22e7b66e6f1b0f78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { exec, GLib } from "astal";
import { osIcons } from "./icons";

export const inPath = (bin: string) => {
    try {
        exec(`which ${bin}`);
    } catch {
        return false;
    }
    return true;
};

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;
    })()
);