diff --git a/flake.lock b/flake.lock
index bba9137..c1eb4c9 100644
--- a/flake.lock
+++ b/flake.lock
@@ -38,11 +38,11 @@
"nixpkgs": "nixpkgs"
},
"locked": {
- "lastModified": 1745006048,
- "narHash": "sha256-4ONXaEwnyZGPp84d6wjiqoR4xyTWygUobBTcSkILPzU=",
+ "lastModified": 1750153510,
+ "narHash": "sha256-NYHXXJZ9m4fJpKk9tKn/EExX87SqcBcRINOGF7hKRLI=",
"owner": "catppuccin",
"repo": "nix",
- "rev": "592094a02c4e43a9fa33559ade84d1ca015e8ada",
+ "rev": "4e95eaf8a351956d75cc400318579967ca2b6d0f",
"type": "github"
},
"original": {
@@ -494,11 +494,11 @@
"systems": "systems_3"
},
"locked": {
- "lastModified": 1739049114,
- "narHash": "sha256-jD9W4OHcn1sJ+xbwNFbGN9heSE6v2v3U+FtGf8Cul6k=",
+ "lastModified": 1749155770,
+ "narHash": "sha256-gsdM6QEHSpzj1Vgw03t5INA+kSZzBWm0qxdofcBp8Qo=",
"owner": "hyprwm",
"repo": "hyprsysteminfo",
- "rev": "6769e50fcfcfd56548e9b17b9a02641ab4826e38",
+ "rev": "3feb86f866b428ee1b78968e222cee6570a38658",
"type": "github"
},
"original": {
@@ -1052,11 +1052,11 @@
"nixpkgs": "nixpkgs_6"
},
"locked": {
- "lastModified": 1748377319,
- "narHash": "sha256-X4lsXJaGVvWnsnhPE2GdQX48BGJOyh8VIziIZT99oiM=",
+ "lastModified": 1750152169,
+ "narHash": "sha256-XN5OBCCXKmPBL+UXyyScI5HGgs4U8OFGQTnKuxurBFI=",
"owner": "0xc000022070",
"repo": "zen-browser-flake",
- "rev": "4d69a89a06542fcc0f4ff7d3fa45e49e7ce691f8",
+ "rev": "ed811ab0d0b407b59cda1023820e9986fd28c8c3",
"type": "github"
},
"original": {
diff --git a/scripts/bin/r2Upload.ts b/scripts/bin/r2Upload.ts
index 86280f0..fbd6dfc 100644
--- a/scripts/bin/r2Upload.ts
+++ b/scripts/bin/r2Upload.ts
@@ -1,11 +1,12 @@
-import { $, S3Client } from "bun";
+import { $ } from "bun";
import { configDotenv } from "dotenv";
import { homedir } from "os";
import { readdirSync, readFileSync, statSync } from "fs";
import { join } from "path";
import { setConsoleTitle } from "@ocbwoy3/libocbwoy3";
+import { UploadToEZ } from "../lib/EZUploader";
-setConsoleTitle("R2 Uploader");
+setConsoleTitle("Screenshot Uploader");
try {
const start = Date.now();
@@ -14,15 +15,6 @@ try {
path: `${homedir()}/.ocbwoy3-dotfiles-SECRET-DO-NOT-TOUCH.env`
});
- const bucket = new S3Client({
- accessKeyId: process.env.S3_ACCESS_KEY,
- secretAccessKey: process.env.S3_SECRET_KEY,
- bucket: process.env.S3_BUCKET_NAME,
- endpoint: process.env.S3_ENDPOINT_URL,
- });
-
- let urlParams = "";
-
const screenshotsDir = join(homedir(), "Pictures", "Screenshots");
const files = readdirSync(screenshotsDir);
@@ -35,29 +27,11 @@ try {
const filePath = join(screenshotsDir, latestFile);
- let [ _, regretevator, floorNum ] = latestFile.match(/\-(regretevator)\-?([0-9]+)?\.png$/) || [];
+ const url = await UploadToEZ(readFileSync(filePath));
- // the devs changed rich presence, what's the point of parsing the filename if tuxstrap doesn't update the state file anymore?
- if (regretevator === "regretevator") {
- latestFile = latestFile.replace(`-regretevator${floorNum ? `-${floorNum}` : ""}.png`,".png")
- // OR i could keep the filename and have my worker parse the filename
- if (floorNum) {
- urlParams = `?floor=${floorNum}`
- }
- }
-
- const file = bucket.file(latestFile)
- await file.write(readFileSync(filePath), {
- type: "image/png"
- })
- $`echo "https://i.darktru.win/${encodeURIComponent(latestFile)}${urlParams}" | wl-copy -n`.nothrow().catch(a => { });
- $`notify-send "Screenshot" "Uploaded in ${Date.now() - start}ms
${latestFile}"`.nothrow().catch(a => { });
+ $`echo "${url}" | wl-copy -n`.nothrow().catch(a => { });
+ $`notify-send "Screenshot" "Uploaded to e-z.host in ${Date.now() - start}ms, URL copied to clipboard"`.nothrow().catch(a => { });
} catch (e_) {
- const cx = `${e_}`.toLowerCase();
- if (cx.includes("enable r2") && cx.includes("cloudflare dashboard")) {
- $`notify-send "Screenshot" "YOU OWE CLOUDFLARE MONEY!!!!"`.nothrow().catch(a => { });
- process.exit(0);
- }
$`notify-send "Screenshot" "${`${e_}`}"`.nothrow().catch(a => { });
}
diff --git a/scripts/lib/EZUploader.ts b/scripts/lib/EZUploader.ts
new file mode 100644
index 0000000..407f81e
--- /dev/null
+++ b/scripts/lib/EZUploader.ts
@@ -0,0 +1,49 @@
+import { homedir } from "os";
+const API_URL = "https://api.e-z.host/files";
+
+/**
+ * Uploads a PNG image to e-z and returns the embed URL.
+ * Throws an error if the file is not a PNG.
+ *
+ * @param content Image content as a Buffer
+ * @returns The uploaded image's URL
+ */
+export async function UploadToEZ(content: Buffer): Promise {
+ 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\`!`)
+ }
+
+ if (!(content[0] === 0x89 && content[1] === 0x50 && content[2] === 0x4e)) {
+ throw new Error("File is not a PNG.");
+ }
+
+ const form = new FormData();
+ form.append(
+ "file",
+ new Blob([content], { type: "image/png" }),
+ "screenshot.png"
+ );
+
+ const res = await fetch(API_URL, {
+ method: "POST",
+ headers: {
+ key: process.env.EZ_API_KEY,
+ },
+ body: form,
+ });
+
+ if (!res.ok) {
+ throw new Error(
+ `Upload failed with status ${res.status}: ${await res.text()}`
+ );
+ }
+
+ const json = await res.json();
+
+ if (!json.imageUrl) {
+ console.warn(json);
+ throw new Error("Malformed response from e-z.gg");
+ }
+
+ return json.url;
+}