pretty
This commit is contained in:
@@ -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("&", "&").replaceAll("<", "<").replaceAll(">", ">"),
|
||||
text: ` ${y.artist} — ${y.song}`.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">"),
|
||||
tooltip: `${y.album}`.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">")
|
||||
}))
|
||||
process.stdout.write(
|
||||
JSON.stringify({
|
||||
// text: ` ${y.artist} — ${y.song}`.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">"),
|
||||
text: ` ${y.artist} — ${y.song}`
|
||||
.replaceAll("&", "&")
|
||||
.replaceAll("<", "<")
|
||||
.replaceAll(">", ">"),
|
||||
tooltip: `${y.album}`
|
||||
.replaceAll("&", "&")
|
||||
.replaceAll("<", "<")
|
||||
.replaceAll(">", ">"),
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
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 {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import { execSync } from "child_process";
|
||||
|
||||
const birthday = new Date(2009, 7, 16);
|
||||
const age = Math.floor(
|
||||
(Date.now() - birthday.getTime()) / (1000 * 60 * 60 * 24 * 365)
|
||||
(Date.now() - birthday.getTime()) / (1000 * 60 * 60 * 24 * 365),
|
||||
);
|
||||
|
||||
const isBirthday =
|
||||
@@ -37,14 +37,11 @@ function chooseRandom(array: string[]): string {
|
||||
return array[index];
|
||||
}
|
||||
|
||||
const splashes = [
|
||||
"大好き<b>ラルセイ</b>",
|
||||
"ハイパーランド"
|
||||
];
|
||||
const splashes = ["大好き<b>ラルセイ</b>", "ハイパーランド"];
|
||||
|
||||
const debug: boolean = true as false | true;
|
||||
|
||||
const welcome = "ハイパーランド へようこそ!" // "Sveicināti Hyprland!"
|
||||
const welcome = "ハイパーランド へようこそ!"; // "Sveicināti Hyprland!"
|
||||
|
||||
if (debug === true) {
|
||||
splashes.forEach(async (a) => {
|
||||
|
||||
@@ -48,24 +48,29 @@ import { getRegretevatorState } from "../lib/RegretevatorUtil";
|
||||
|
||||
*/
|
||||
|
||||
const windowClassFriendyName: {[windowClass: string]: string} = {
|
||||
"steam_app_1671210": "Deltarune",
|
||||
const windowClassFriendyName: { [windowClass: string]: string } = {
|
||||
steam_app_1671210: "Deltarune",
|
||||
"org.vinegarhq.Sober": "Roblox",
|
||||
"steam_app_1690940": "Deltarune", // demo
|
||||
}
|
||||
steam_app_1690940: "Deltarune", // demo
|
||||
};
|
||||
|
||||
async function getWMClass(): Promise<string> {
|
||||
const windowClass = await $`hyprctl activewindow -j`.json();
|
||||
return windowClass.initialClass
|
||||
return windowClass.initialClass;
|
||||
}
|
||||
|
||||
async function getFilename(wmClass?: string): Promise<string> {
|
||||
const _d = new Date();
|
||||
let ic = (wmClass && windowClassFriendyName[wmClass]) || wmClass || "Hyprland";
|
||||
let ic =
|
||||
(wmClass && windowClassFriendyName[wmClass]) || wmClass || "Hyprland";
|
||||
const isRoblox = wmClass === "org.vinegarhq.Sober";
|
||||
if (isRoblox) {ic = "Roblox"; };
|
||||
if (isRoblox) {
|
||||
ic = "Roblox";
|
||||
}
|
||||
const regretevatorState = isRoblox ? getRegretevatorState() : null;
|
||||
if (!!regretevatorState) {ic = "Regretevator";};
|
||||
if (!!regretevatorState) {
|
||||
ic = "Regretevator";
|
||||
}
|
||||
// console.log(isRoblox, regretevatorState)
|
||||
return `${ic}-${_d.getTime()}${
|
||||
!regretevatorState
|
||||
@@ -74,7 +79,7 @@ async function getFilename(wmClass?: string): Promise<string> {
|
||||
regretevatorState.state === "INGAME"
|
||||
? `-${regretevatorState.floor}`
|
||||
: ""
|
||||
}`
|
||||
}`
|
||||
}`;
|
||||
}
|
||||
|
||||
@@ -115,7 +120,7 @@ async function transformImage(b: Buffer): Promise<Buffer> {
|
||||
|
||||
return (await maskedImage.png().toBuffer()) as Buffer;
|
||||
*/
|
||||
return b
|
||||
return b;
|
||||
}
|
||||
|
||||
(() => {
|
||||
|
||||
@@ -5,23 +5,31 @@ import { existsSync, readFileSync, writeFileSync } from "fs";
|
||||
setConsoleTitle("Music Test");
|
||||
|
||||
try {
|
||||
const artUrl = await $`playerctl -s -p cider,chromium,OCbwoy3_s_iPhone metadata mpris:artUrl`.text();
|
||||
const title = await $`playerctl -s -p cider,chromium,OCbwoy3_s_iPhone metadata title`.text();
|
||||
const artist = await $`playerctl -s -p cider,chromium,OCbwoy3_s_iPhone metadata artist`.text();
|
||||
const album = await $`playerctl -s -p cider,chromium,OCbwoy3_s_iPhone metadata album`.text();
|
||||
|
||||
const artUrl =
|
||||
await $`playerctl -s -p cider,chromium,OCbwoy3_s_iPhone metadata mpris:artUrl`.text();
|
||||
const title =
|
||||
await $`playerctl -s -p cider,chromium,OCbwoy3_s_iPhone metadata title`.text();
|
||||
const artist =
|
||||
await $`playerctl -s -p cider,chromium,OCbwoy3_s_iPhone metadata artist`.text();
|
||||
const album =
|
||||
await $`playerctl -s -p cider,chromium,OCbwoy3_s_iPhone metadata album`.text();
|
||||
|
||||
const MT = `${artist.trim()},${album.trim()}`;
|
||||
|
||||
if (!existsSync("/tmp/.musictest-info") || readFileSync("/tmp/.musictest-info").toString("utf-8") !== MT) {
|
||||
writeFileSync("/tmp/.musictest-info",MT)
|
||||
|
||||
const x = await fetch(artUrl.trim())
|
||||
writeFileSync("/tmp/.musictest",await x.bytes())
|
||||
if (
|
||||
!existsSync("/tmp/.musictest-info") ||
|
||||
readFileSync("/tmp/.musictest-info").toString("utf-8") !== MT
|
||||
) {
|
||||
writeFileSync("/tmp/.musictest-info", MT);
|
||||
|
||||
const x = await fetch(artUrl.trim());
|
||||
writeFileSync("/tmp/.musictest", await x.bytes());
|
||||
}
|
||||
|
||||
$`notify-send ${title.trim()} ${artist.trim()} -i /tmp/.musictest`.nothrow().catch(a => { });
|
||||
$`notify-send ${title.trim()} ${artist.trim()} -i /tmp/.musictest`
|
||||
.nothrow()
|
||||
.catch((a) => {});
|
||||
} catch (e_) {
|
||||
console.error(e_)
|
||||
$`notify-send "music test" "lol"`.nothrow().catch(a => { });
|
||||
console.error(e_);
|
||||
$`notify-send "music test" "lol"`.nothrow().catch((a) => {});
|
||||
}
|
||||
|
||||
@@ -6,16 +6,16 @@ import { setConsoleTitle } from "@ocbwoy3/libocbwoy3";
|
||||
setConsoleTitle("Roblox Studio patcher");
|
||||
|
||||
const SIGNATURE = Buffer.from([
|
||||
0x48, 0x81, 0xEC, 0x40, 0x03, 0x00, 0x00, 0x84, 0xD2, 0x74, 0x05, 0xE8
|
||||
0x48, 0x81, 0xec, 0x40, 0x03, 0x00, 0x00, 0x84, 0xd2, 0x74, 0x05, 0xe8,
|
||||
]);
|
||||
|
||||
const PATCH = Buffer.from([
|
||||
0x48, 0x81, 0xEC, 0x40, 0x03, 0x00, 0x00, 0x84, 0xD2, 0x90, 0x90, 0xE8
|
||||
0x48, 0x81, 0xec, 0x40, 0x03, 0x00, 0x00, 0x84, 0xd2, 0x90, 0x90, 0xe8,
|
||||
]);
|
||||
|
||||
const baseDir = path.join(
|
||||
os.homedir(),
|
||||
".var/app/org.vinegarhq.Vinegar/data/vinegar/versions"
|
||||
".var/app/org.vinegarhq.Vinegar/data/vinegar/versions",
|
||||
);
|
||||
|
||||
function findSignature(buffer: Buffer, signature: Buffer): number {
|
||||
@@ -40,18 +40,25 @@ async function patchFile(folder: string) {
|
||||
try {
|
||||
binary = await fs.readFile(exePath);
|
||||
} catch (err) {
|
||||
console.error(`[ERROR] Could not read ${exePath}/RobloxStudioBeta.exe:`, err);
|
||||
console.error(
|
||||
`[ERROR] Could not read ${exePath}/RobloxStudioBeta.exe:`,
|
||||
err,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (findSignature(binary, PATCH)) {
|
||||
console.log(`[SKIP] ${folder}/RobloxStudioBeta.exe has already been patched`);
|
||||
console.log(
|
||||
`[SKIP] ${folder}/RobloxStudioBeta.exe has already been patched`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const offset = findSignature(binary, SIGNATURE);
|
||||
if (offset === -1) {
|
||||
console.error(`[FAIL] Signature not found in ${exePath}/RobloxStudioBeta.exe`);
|
||||
console.error(
|
||||
`[FAIL] Signature not found in ${exePath}/RobloxStudioBeta.exe`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -85,7 +92,7 @@ async function main() {
|
||||
const start = Date.now();
|
||||
await Promise.all(folders.map(patchFile));
|
||||
console.log(
|
||||
`[DONE] Patched internal Roblox Studio in ${Date.now() - start}ms`
|
||||
`[DONE] Patched internal Roblox Studio in ${Date.now() - start}ms`,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,18 +11,20 @@ setConsoleTitle("Screenshot Uploader");
|
||||
|
||||
try {
|
||||
const start = Date.now();
|
||||
$`notify-send -t 1000 "Screenshot" "Uploading.."`.nothrow().catch(a => { });
|
||||
$`notify-send -t 1000 "Screenshot" "Uploading.."`
|
||||
.nothrow()
|
||||
.catch((a) => {});
|
||||
configDotenv({
|
||||
path: `${homedir()}/.ocbwoy3-dotfiles-SECRET-DO-NOT-TOUCH.env`
|
||||
path: `${homedir()}/.ocbwoy3-dotfiles-SECRET-DO-NOT-TOUCH.env`,
|
||||
});
|
||||
|
||||
const screenshotsDir = join(homedir(), "Pictures", "Screenshots");
|
||||
const files = readdirSync(screenshotsDir);
|
||||
|
||||
let latestFile = files
|
||||
.map(file => ({
|
||||
.map((file) => ({
|
||||
file,
|
||||
time: statSync(join(screenshotsDir, file)).mtime.getTime()
|
||||
time: statSync(join(screenshotsDir, file)).mtime.getTime(),
|
||||
}))
|
||||
.sort((a, b) => b.time - a.time)[0].file;
|
||||
|
||||
@@ -31,8 +33,9 @@ try {
|
||||
const url = await UploadToEZ(readFileSync(filePath));
|
||||
|
||||
execSync(`echo "${url}" | wl-copy -n`);
|
||||
execSync(`notify-send "Ekrānuzņēmums" "Attēls augšuplādēts e-z.host ${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_}`}"`);
|
||||
}
|
||||
|
||||
|
||||
@@ -50,60 +50,61 @@ export type CiderNowPlaying = {
|
||||
[key: string]: any;
|
||||
};
|
||||
|
||||
|
||||
// cachedAlbumArt = /tmp/.ocbwoy3-ciderv2lib-md5(isrc+albumName).jpg
|
||||
|
||||
export type albumStuffF = {
|
||||
artist: string,
|
||||
album: string,
|
||||
song: string,
|
||||
artUrl?: string
|
||||
}
|
||||
artist: string;
|
||||
album: string;
|
||||
song: string;
|
||||
artUrl?: string;
|
||||
};
|
||||
|
||||
export const albumRewriteRegexes: { a: RegExp, b: string | false }[] = [
|
||||
export const albumRewriteRegexes: { a: RegExp; b: string | false }[] = [
|
||||
{
|
||||
a: / \(Original( (Video )?Game)? Soundtrack.*\)$/i,
|
||||
b: ""
|
||||
b: "",
|
||||
},
|
||||
{
|
||||
a: / - Single$/i,
|
||||
b: false
|
||||
b: false,
|
||||
},
|
||||
{
|
||||
a: / Soundtrack$/i,
|
||||
b: ""
|
||||
b: "",
|
||||
},
|
||||
{
|
||||
a: /^(DELTARUNE|Deltarune) (chapter|chapters) /i,
|
||||
b: "Deltarune $2 "
|
||||
b: "Deltarune $2 ",
|
||||
},
|
||||
{
|
||||
a: / - EP$/i,
|
||||
b: ""
|
||||
b: "",
|
||||
},
|
||||
{
|
||||
a: /^regretevator$/i,
|
||||
b: false
|
||||
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);
|
||||
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");
|
||||
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`
|
||||
const path = `/tmp/.ocbwoy3-ciderv2lib-md5-${special}.jpg`;
|
||||
|
||||
// console.log(existsSync(path), `hyprctl dispatch exec ${`wget -q --unlink -O ${path} ${info.artwork.url}`}`);
|
||||
|
||||
@@ -116,15 +117,15 @@ export async function fetchAlbumStuff(): Promise<albumStuffF> {
|
||||
writeFileSync(path, data);
|
||||
// writeFileSync(path,await ct.body?.pipeTo)
|
||||
} catch {
|
||||
rmSync(path)
|
||||
rmSync(path);
|
||||
}
|
||||
}
|
||||
return {
|
||||
artist: info.artistName,
|
||||
album: doRewritesRn(info.albumName),
|
||||
song: info.name,
|
||||
artUrl: existsSync(path) ? path : undefined
|
||||
}
|
||||
artUrl: existsSync(path) ? path : undefined,
|
||||
};
|
||||
}
|
||||
|
||||
// await fetchAlbumStuff();
|
||||
|
||||
@@ -10,7 +10,9 @@ const API_URL = "https://api.e-z.host/files";
|
||||
*/
|
||||
export async function UploadToEZ(content: Buffer): Promise<string> {
|
||||
if (!process.env.EZ_API_KEY) {
|
||||
throw new Error(`Missing EZ_API_KEY, make sure you're loading the env from ${homedir()}/.ocbwoy3-dotfiles-SECRET-DO-NOT-TOUCH.env!`)
|
||||
throw new Error(
|
||||
`Missing EZ_API_KEY, make sure you're loading the env from ${homedir()}/.ocbwoy3-dotfiles-SECRET-DO-NOT-TOUCH.env!`,
|
||||
);
|
||||
}
|
||||
|
||||
if (!(content[0] === 0x89 && content[1] === 0x50 && content[2] === 0x4e)) {
|
||||
@@ -21,7 +23,7 @@ export async function UploadToEZ(content: Buffer): Promise<string> {
|
||||
form.append(
|
||||
"file",
|
||||
new Blob([content as any], { type: "image/png" }),
|
||||
"screenshot.png"
|
||||
"screenshot.png",
|
||||
);
|
||||
|
||||
const res = await fetch(API_URL, {
|
||||
@@ -34,7 +36,7 @@ export async function UploadToEZ(content: Buffer): Promise<string> {
|
||||
|
||||
if (!res.ok) {
|
||||
throw new Error(
|
||||
`Upload failed with status ${res.status}: ${await res.text()}`
|
||||
`Upload failed with status ${res.status}: ${await res.text()}`,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,26 +24,28 @@ export type RegretevatorState = DeadUnknownState | InElevatorState;
|
||||
export function getRegretevatorState(): null | RegretevatorState {
|
||||
if (!existsSync(STATE_FILE_PATH)) return null;
|
||||
try {
|
||||
const {text, tooltip}: { text: string, tooltip: string } = JSON.parse(readFileSync(STATE_FILE_PATH).toString('utf-8'))
|
||||
const { text, tooltip }: { text: string; tooltip: string } = JSON.parse(
|
||||
readFileSync(STATE_FILE_PATH).toString("utf-8"),
|
||||
);
|
||||
if (/^On Floor ([0-9]+)$/.test(tooltip)) {
|
||||
const floorNum = tooltip.match(/^On Floor ([0-9]+)$/)![1]
|
||||
const floorNum = tooltip.match(/^On Floor ([0-9]+)$/)![1];
|
||||
return {
|
||||
floor: Number(floorNum),
|
||||
state: "INGAME",
|
||||
isGoingUp: false
|
||||
}
|
||||
isGoingUp: false,
|
||||
};
|
||||
}
|
||||
if (/^Floor ([0-9]+)/.test(tooltip)) {
|
||||
const floorNum = tooltip.match(/^Floor ([0-9]+)/)![1]
|
||||
const floorNum = tooltip.match(/^Floor ([0-9]+)/)![1];
|
||||
return {
|
||||
floor: Number(floorNum),
|
||||
state: "INGAME",
|
||||
isGoingUp: true
|
||||
}
|
||||
isGoingUp: true,
|
||||
};
|
||||
}
|
||||
return {
|
||||
state: "UNKNOWN"
|
||||
}
|
||||
state: "UNKNOWN",
|
||||
};
|
||||
} catch {}
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user