This commit is contained in:
2025-11-19 22:01:25 +02:00
parent afef35b6f6
commit 3a7686713f
16 changed files with 276 additions and 212 deletions

View File

@@ -1,49 +1,71 @@
import { $, sleep } from "bun";
import { albumStuffF, fetchAlbumStuff } from "../lib/CiderV2Playing"
import { albumStuffF, fetchAlbumStuff } from "../lib/CiderV2Playing";
import { execFile } from "child_process";
import { rmSync } from "fs";
let x: albumStuffF | any = false;
try {
x = await fetchAlbumStuff() as albumStuffF
} catch { }
x = (await fetchAlbumStuff()) as albumStuffF;
} catch {}
function notifyWithImage(song: string, artUrl: string, artist: string, album: string) {
function notifyWithImage(
song: string,
artUrl: string,
artist: string,
album: string,
) {
execFile("dunstify", [
"-t", (process.argv[3] === "rel" ? "1" : "2000"),
"-r", "67676767",
"-a", "ocbwoy3-whatsplaying",
"-I", artUrl,
"-t",
process.argv[3] === "rel" ? "1" : "2000",
"-r",
"67676767",
"-a",
"ocbwoy3-whatsplaying",
"-I",
artUrl,
song,
`${artist}<br/>`//${album !== "" ? `<small>${album}</small>` : ""}`
`${artist}<br/>`, //${album !== "" ? `<small>${album}</small>` : ""}`
]);
}
console.log(process.argv[3])
console.log(process.argv[3]);
function notifyBasic(song: string, artist: string, album: string) {
execFile("dunstify", [
"-t", (process.argv[3] === "rel" ? "1" : "2000"),
"-r", "67676767",
"-a", "ocbwoy3-whatsplaying",
"-t",
process.argv[3] === "rel" ? "1" : "2000",
"-r",
"67676767",
"-a",
"ocbwoy3-whatsplaying",
song,
`${artist}`//<br/>${album !== "" ? `<small>${album}</small>` : ""}`
`${artist}`, //<br/>${album !== "" ? `<small>${album}</small>` : ""}`
]);
}
if (process.argv[2] === "waybar") {
if (!x) {
process.stdout.write(JSON.stringify({
class: "hidden"
}))
process.stdout.write(
JSON.stringify({
class: "hidden",
}),
);
process.exit(0);
}
const y = x as albumStuffF;
process.stdout.write(JSON.stringify({
// text: ` ${y.artist} — ${y.song}`.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;"),
text: `${y.artist}${y.song}`.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;"),
tooltip: `${y.album}`.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;")
}))
process.stdout.write(
JSON.stringify({
// text: ` ${y.artist} — ${y.song}`.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;"),
text: `${y.artist}${y.song}`
.replaceAll("&", "&amp;")
.replaceAll("<", "&lt;")
.replaceAll(">", "&gt;"),
tooltip: `${y.album}`
.replaceAll("&", "&amp;")
.replaceAll("<", "&lt;")
.replaceAll(">", "&gt;"),
}),
);
}
if (process.argv[2] === "notif") {
@@ -55,6 +77,8 @@ if (process.argv[2] === "notif") {
notifyWithImage(y.song, y.artUrl, y.artist, y.album);
} catch {
notifyBasic(y.song, y.artist, y.album);
try { rmSync(y.artUrl); } catch { }
try {
rmSync(y.artUrl);
} catch {}
}
}