bar: use nf icons for os icon

This commit is contained in:
2 * r + 2 * t 2025-01-31 14:58:18 +11:00
parent 21e9d1fcb5
commit 82e31b6d8d
2 changed files with 48 additions and 34 deletions

View file

@ -2,33 +2,49 @@ import { Apps } from "@/services/apps";
import { Gio } from "astal"; import { Gio } from "astal";
import type AstalApps from "gi://AstalApps"; import type AstalApps from "gi://AstalApps";
// Code points from https://www.github.com/lukas-w/font-logos export const osIcons: Record<string, string> = {
export const osIcons: Record<string, number> = { almalinux: "",
almalinux: 0xf31d, alpine: "",
alpine: 0xf300, arch: "",
arch: 0xf303, archcraft: "",
arcolinux: 0xf346, arcolinux: "",
centos: 0x304, artix: "",
debian: 0xf306, centos: "",
elementary: 0xf309, debian: "",
endeavouros: 0xf322, devuan: "",
fedora: 0xf30a, elementary: "",
gentoo: 0xf30d, endeavouros: "",
kali: 0xf327, fedora: "",
linuxmint: 0xf30e, freebsd: "",
mageia: 0xf310, garuda: "",
manjaro: 0xf312, gentoo: "",
nixos: 0xf313, hyperbola: "",
opensuse: 0xf314, kali: "",
suse: 0xf314, linuxmint: "󰣭",
sles: 0xf314, mageia: "",
sles_sap: 0xf314, openmandriva: "",
pop: 0xf32a, manjaro: "",
raspbian: 0xf315, neon: "",
rhel: 0xf316, nixos: "",
rocky: 0xf32b, opensuse: "",
slackware: 0xf318, suse: "",
ubuntu: 0xf31b, sles: "",
sles_sap: "",
"opensuse-tumbleweed": "",
parrot: "",
pop: "",
raspbian: "",
rhel: "",
rocky: "",
slackware: "",
solus: "",
steamos: "",
tails: "",
trisquel: "",
ubuntu: "",
vanilla: "",
void: "",
zorin: "",
}; };
export const desktopEntrySubs: Record<string, string> = { export const desktopEntrySubs: Record<string, string> = {

View file

@ -56,13 +56,11 @@ export const notify = (props: {
export const osId = GLib.get_os_info("ID") ?? "unknown"; export const osId = GLib.get_os_info("ID") ?? "unknown";
export const osIdLike = GLib.get_os_info("ID_LIKE"); export const osIdLike = GLib.get_os_info("ID_LIKE");
export const osIcon = String.fromCodePoint( export const osIcon = (() => {
(() => { if (osIcons.hasOwnProperty(osId)) return osIcons[osId];
if (osIcons.hasOwnProperty(osId)) return osIcons[osId]; if (osIdLike) for (const id of osIdLike.split(" ")) if (osIcons.hasOwnProperty(id)) return osIcons[id];
if (osIdLike) for (const id of osIdLike.split(" ")) if (osIcons.hasOwnProperty(id)) return osIcons[id]; return "";
return 0xf31a; })();
})()
);
export const currentTime = Variable(GLib.DateTime.new_now_local()).poll(1000, () => GLib.DateTime.new_now_local()); export const currentTime = Variable(GLib.DateTime.new_now_local()).poll(1000, () => GLib.DateTime.new_now_local());
export const bindCurrentTime = (format: string, fallback?: (time: GLib.DateTime) => string) => export const bindCurrentTime = (format: string, fallback?: (time: GLib.DateTime) => string) =>