idk anymore

This commit is contained in:
2025-11-08 21:18:07 +02:00
parent eda5c75a07
commit fb6ffa2e11
22 changed files with 274 additions and 173 deletions

2
scripts/bin/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
# compile it yourself
ocbwoy3-actwithmus

View File

@@ -0,0 +1,60 @@
import { $, sleep } from "bun";
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 { }
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,
song,
`${artist}<br/>`//${album !== "" ? `<small>${album}</small>` : ""}`
]);
}
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",
song,
`${artist}`//<br/>${album !== "" ? `<small>${album}</small>` : ""}`
]);
}
if (process.argv[2] === "waybar") {
if (!x) {
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;")
}))
}
if (process.argv[2] === "notif") {
const y = x as albumStuffF;
if (!x || !y.artUrl) process.exit(1);
try {
console.log(y.song, y.artUrl, y.artist, y.album);
notifyWithImage(y.song, y.artUrl, y.artist, y.album);
} catch {
notifyBasic(y.song, y.artist, y.album);
try { rmSync(y.artUrl); } catch { }
}
}

View File

@@ -37,26 +37,21 @@ function chooseRandom(array: string[]): string {
return array[index];
}
const splashes = [
"Keep on ricing yo' Hyprland...",
"Contains infinite genders!",
"You are valid!",
"Blogsy is so AWESOME!",
"I love Blogsy!",
"Whats yer favorite type o wood?",
const splashes = [
"大好き<b>ラルセイ</b>",
"ハイパーランド"
];
const debug: boolean = false as false | true;
const debug: boolean = true as false | true;
const welcome = "ハイパーランド へようこそ!" // "Sveicināti Hyprland!"
if (debug === true) {
splashes.forEach(async (a) => {
execSync(`notify-send "Welcome to Hyprland!" "${a}"`);
execSync(`notify-send "${welcome}" "${a}"`);
});
} else {
const randomSplash = chooseRandom(splashes);
execSync(`notify-send "Welcome to Hyprland!" "${randomSplash}"`);
execSync(`notify-send "${welcome}" "${randomSplash}"`);
}

View File

@@ -31,7 +31,7 @@ try {
const url = await UploadToEZ(readFileSync(filePath));
execSync(`echo "${url}" | wl-copy -n`);
execSync(`notify-send "Screenshot" "Uploaded to e-z.host in ${Date.now() - start}ms"`);
execSync(`notify-send "Ekrānuzņēmums" "Attēls augšuplādēts e-z.host ${Date.now() - start}ms"`);
} catch (e_) {
execSync(`notify-send "Error" "${`${e_}`}"`);
}

View File

@@ -1,7 +1,7 @@
hyprctl notify 1 5000 0 " Loading OCbwoy3's Dotfiles"
# Dotfiles
notify-send "Welcome to Hyprland!" "some basic startup code"
notify-send "Sveicināti Hyprland!" "some basic startup code"
notify-send "Hyprland" "Enabled debugging overlay"
notify-send "OCbwoy3's Dotfiles" "Keyboard Layout: English"
notify-send "Screenshot" "Saved and copied to clipboard."

View File

@@ -1,15 +1,130 @@
export type CiderPlaying = {
status: "ok",
import assert from "assert";
import { $, MD5 } from "bun";
import { createWriteStream, existsSync, rmSync, writeFileSync } from "fs";
export type CiderNowPlaying = {
status: string;
info: {
albumName: string,
artistName: string,
name: string
albumName: string;
artistName: string;
artwork: {
bgColor: string;
hasP3: boolean;
height: number;
textColor1: string;
textColor2: string;
textColor3: string;
textColor4: string;
url: string;
width: number;
[key: string]: any; // allow any other properties
};
contentRating: string;
discNumber: number;
durationInMillis: number;
genreNames: string[];
hasLyrics: boolean;
name: string;
playParams: {
catalogId: string;
id: string;
isLibrary: boolean;
kind: string;
reporting: boolean;
reportingId: string;
[key: string]: any;
};
releaseDate: string;
trackNumber: number;
composerName: string;
isrc: string;
previews: any[]; // empty objects or unknown preview data
currentPlaybackTime: number;
remainingTime: number;
inFavorites: boolean;
inLibrary: boolean;
shuffleMode: number;
repeatMode: number;
[key: string]: any;
};
[key: string]: any;
};
// cachedAlbumArt = /tmp/.ocbwoy3-ciderv2lib-md5(isrc+albumName).jpg
export type albumStuffF = {
artist: string,
album: string,
song: string,
artUrl?: string
}
export const albumRewriteRegexes: { a: RegExp, b: string | false }[] = [
{
a: / \(Original( (Video )?Game)? Soundtrack.*\)$/i,
b: ""
},
{
a: / - Single$/i,
b: false
},
{
a: / Soundtrack$/i,
b: ""
},
{
a: /^(DELTARUNE|Deltarune) (chapter|chapters) /i,
b: "Deltarune $2 "
},
{
a: / - EP$/i,
b: ""
},
{
a: /^regretevator$/i,
b: false
},
]
export function doRewritesRn(t: string) {
let m = t;
for (const x of albumRewriteRegexes) {
if (x.a.test(m)) {
if (x.b === false) return "";
m = m.replace(x.a,x.b);
}
}
return m;
}
export async function fetchAlbumStuff(): Promise<albumStuffF> {
const d = await fetch("http://localhost:10767/api/v1/playback/now-playing?token=z");
// console.log(d.status, d.statusText, await d.text())
const { info }: CiderNowPlaying = await d.json();
const special = MD5.hash(info.isrc + info.albumName, "hex");
const path = `/tmp/.ocbwoy3-ciderv2lib-md5-${special}.jpg`
// console.log(existsSync(path), `hyprctl dispatch exec ${`wget -q --unlink -O ${path} ${info.artwork.url}`}`);
if (!existsSync(path)) {
writeFileSync(path, "");
try {
const ct = await fetch(info.artwork.url);
assert(ct.ok);
const data = Buffer.from(await ct.arrayBuffer());
writeFileSync(path, data);
// writeFileSync(path,await ct.body?.pipeTo)
} catch {
rmSync(path)
}
}
return {
artist: info.artistName,
album: doRewritesRn(info.albumName),
song: info.name,
artUrl: existsSync(path) ? path : undefined
}
}
const d = await fetch("http://localhost:10767/api/v1/playback/now-playing?token=z");
// console.log(d.status, d.statusText, await d.text())
const {info}: CiderPlaying = await d.json();
console.log(`${info.artistName} - ${info.name} [${info.albumName}]`);
console.log(info);
// await fetchAlbumStuff();

View File

@@ -2,7 +2,7 @@
GAMES=$(cat ~/config/scripts/lib/games.txt)
SELECTED=$(echo "$GAMES" | cut -d'%' -f1 | wofi --show dmenu -p "Play something...")
SELECTED=$(echo "$GAMES" | cut -d'%' -f1 | wofi --show dmenu -p "Meklēt spēli...")
if [ -n "$SELECTED" ]; then
PLACE_ID=$(echo "$GAMES" | grep "^$SELECTED" | sed 's/.*%%% //')

View File

@@ -2,7 +2,7 @@
GAMES=$(cat ~/config/scripts/lib/gamesRoblox.txt)
SELECTED=$(echo "$GAMES" | cut -d'%' -f1 | wofi --show dmenu -p "Play Roblox...")
SELECTED=$(echo "$GAMES" | cut -d'%' -f1 | wofi --show dmenu -p "Meklēt Roblox spēli...")
if [ -n "$SELECTED" ]; then
PLACE_ID=$(echo "$GAMES" | grep "^$SELECTED" | sed 's/.*%%% //')

View File

@@ -7,5 +7,5 @@ echo "$SS_PATH"
if [[ -n "$SS_PATH" && "$SS_PATH" == /home/ocbwoy3/Pictures/Screenshots/* ]]; then
wl-copy < "$SS_PATH"
notify-send "Screenshot" "Fullscreen copied to clipboard!"
notify-send -i "$SS_PATH" "Ekrānuzņēmums" "nokopēts starpliktuvē!"
fi

View File

@@ -7,5 +7,5 @@ echo "$SS_PATH"
if [[ -n "$SS_PATH" && "$SS_PATH" == /home/ocbwoy3/Pictures/Screenshots/* ]]; then
wl-copy < "$SS_PATH"
notify-send "Screenshot" "Selection copied to clipboard!"
notify-send -i "$SS_PATH" "Ekrānuzņēmums" "nokopēts starpliktuvē!"
fi

View File

@@ -3,4 +3,4 @@ KBLANG=$(hyprctl getoption input:kb_layout | awk 'NR==1{print $2}')
# hyprctl switchxkblayout semico--usb-gaming-keyboard- next
hyprctl switchxkblayout current next
notify-send -u low "Keyboard" "Language changed"
notify-send -u low "Tastatūra" "Valoda mainīta"

2
scripts/whatsplaying.sh Executable file
View File

@@ -0,0 +1,2 @@
# bun run ~/config/scripts/bin/actWithMusic.ts notif $@
exec ~/config/scripts/bin/ocbwoy3-actwithmus notif $@