diff --git a/config/hypr/hyprlock.conf b/config/hypr/hyprlock.conf
index b8f59df..5fe2a57 100644
--- a/config/hypr/hyprlock.conf
+++ b/config/hypr/hyprlock.conf
@@ -45,7 +45,7 @@ label {
}
label {
- text = cmd[update:1000] playerctl metadata -sf "{{artist}} - {{title}}
{{album}}"
+ text = cmd[update:1000] playerctl metadata -sf "{{artist}} - {{title}}
{{album}}"
font_family = Geist
color = rgb(255, 0, 0)
position = 10, -10
diff --git a/scripts/bin/handleScreenshot.ts b/scripts/bin/handleScreenshot.ts
index 6018578..e3f6520 100755
--- a/scripts/bin/handleScreenshot.ts
+++ b/scripts/bin/handleScreenshot.ts
@@ -2,11 +2,24 @@ import { $ } from "bun";
import { Command } from "commander";
import sharp from "sharp";
import { writeFileSync } from "fs";
+import { getRegretevatorState } from "../lib/RegretevatorUtil";
async function getFilename(): Promise {
const _d = new Date();
const windowClass = await $`hyprctl activewindow -j`.json();
- return `${windowClass.initialClass || "Hyprland"}-${_d.getTime()}`;
+ const isRoblox =
+ windowClass.initialClass === "org.vinegarhq.Sober" ? true : false;
+ const regretevatorState = isRoblox ? getRegretevatorState() : null;
+ // console.log(isRoblox, regretevatorState)
+ return `${isRoblox ? "Roblox" : (windowClass.initialClass || "Hyprland")}-${_d.getTime()}${
+ !regretevatorState
+ ? ""
+ : `-regretevator${
+ regretevatorState.state === "INGAME"
+ ? `-${regretevatorState.floor}`
+ : ""
+ }`
+ }`;
}
const program = new Command("handle-screenshot");
@@ -27,58 +40,73 @@ async function transformImage(b: Buffer): Promise {
`
);
- const maskedImage = image.composite([
- {
- input: mask,
- gravity: "center",
- blend: "dest-in"
- },
- ]).extend({
- top: 16,
- bottom: 16,
- left: 16,
- right: 16
- }).ensureAlpha();
+ const maskedImage = image
+ .composite([
+ {
+ input: mask,
+ gravity: "center",
+ blend: "dest-in",
+ },
+ ])
+ .extend({
+ top: 16,
+ bottom: 16,
+ left: 16,
+ right: 16,
+ })
+ .ensureAlpha();
- return await maskedImage.png().toBuffer() as Buffer;
+ return (await maskedImage.png().toBuffer()) as Buffer;
}
(() => {
+ program
+ .command("selection")
+ .description("Takes a screenshot from selection")
+ .action(async () => {
+ const selection = await $`slurp -w 0 -d -b "#cdd6f444"`
+ .nothrow()
+ .quiet();
+ if (
+ selection.exitCode !== 0 ||
+ selection.stdout.toString().includes("cancel")
+ ) {
+ console.log("/tmp/woah");
+ process.exit(0);
+ }
+ const _BUF = await $`grim -t png -l 0 -g ${selection.stdout
+ .toString()
+ .trim()} -`.arrayBuffer();
+ let BUF = Buffer.from(_BUF) as Buffer;
- program.command("selection").description("Takes a screenshot from selection").action(async () => {
- const selection = await $`slurp -w 0 -d -b "#cdd6f444"`.nothrow().quiet();
- if (selection.exitCode !== 0 || selection.stdout.toString().includes("cancel")) {
- console.log("/tmp/woah");
- process.exit(0);
- };
- const _BUF = await $`grim -t png -l 0 -g ${selection.stdout.toString().trim()} -`.arrayBuffer();
- let BUF = Buffer.from(_BUF) as Buffer;
-
- const FILENAME = `${SCREENSHOT_PATH}/${await getFilename()}.png`;
-
- // BUF = await transformImage(BUF);
- writeFileSync(FILENAME,BUF);
- console.log(FILENAME);
- });
+ const FILENAME = `${SCREENSHOT_PATH}/${await getFilename()}.png`;
+ // BUF = await transformImage(BUF);
+ writeFileSync(FILENAME, BUF);
+ console.log(FILENAME);
+ });
})();
(() => {
+ program
+ .command("fullscreen")
+ .description("Takes a fullsceen screenshot")
+ .action(async () => {
+ const selection =
+ await $`hyprctl monitors | awk '/Monitor/{monitor=$2} /focused: yes/{print monitor; exit}'`
+ .nothrow()
+ .text();
- program.command("fullscreen").description("Takes a fullsceen screenshot").action(async () => {
- const selection = await $`hyprctl monitors | awk '/Monitor/{monitor=$2} /focused: yes/{print monitor; exit}'`.nothrow().text();
+ const _BUF =
+ await $`grim -t png -l 0 -o ${selection.trim()} -`.arrayBuffer();
+ let BUF = Buffer.from(_BUF) as Buffer;
- const _BUF = await $`grim -t png -l 0 -o ${selection.trim()} -`.arrayBuffer();
- let BUF = Buffer.from(_BUF) as Buffer;
-
- const FILENAME = `${SCREENSHOT_PATH}/${await getFilename()}.png`;
-
- // BUF = await transformImage(BUF);
- writeFileSync(FILENAME,BUF);
- console.log(FILENAME)
- });
+ const FILENAME = `${SCREENSHOT_PATH}/${await getFilename()}.png`;
+ // BUF = await transformImage(BUF);
+ writeFileSync(FILENAME, BUF);
+ console.log(FILENAME);
+ });
})();
-
program.parse(process.argv);
diff --git a/scripts/bin/r2Upload.ts b/scripts/bin/r2Upload.ts
index faad17a..27dce1b 100644
--- a/scripts/bin/r2Upload.ts
+++ b/scripts/bin/r2Upload.ts
@@ -5,6 +5,8 @@ import { readdirSync, readFileSync, statSync } from "fs";
import { join } from "path";
try {
+ const start = Date.now();
+ $`notify-send -t 1000 "Screenshot" "Uploading.."`.nothrow().catch(a => { });
configDotenv({
path: `${homedir()}/.ocbwoy3-dotfiles-SECRET-DO-NOT-TOUCH.env`
});
@@ -16,10 +18,12 @@ try {
endpoint: process.env.S3_ENDPOINT_URL,
});
+ let urlParams = "";
+
const screenshotsDir = join(homedir(), "Pictures", "Screenshots");
const files = readdirSync(screenshotsDir);
- const latestFile = files
+ let latestFile = files
.map(file => ({
file,
time: statSync(join(screenshotsDir, file)).mtime.getTime()
@@ -28,13 +32,23 @@ try {
const filePath = join(screenshotsDir, latestFile);
- const start = Date.now();
+ let [ _, regretevator, floorNum ] = latestFile.match(/\-(regretevator)\-?([0-9]+)?\.png$/) || [];
+
+ if (regretevator === "regretevator") {
+ latestFile = latestFile.replace(`-regretevator${floorNum ? `-${floorNum}` : ""}.png`,".png")
+ if (floorNum) {
+ urlParams = `?floor=${floorNum}`
+ } else {
+ urlParams = `?regretevator`
+ }
+ }
+
const file = bucket.file(latestFile)
await file.write(readFileSync(filePath), {
type: "image/png"
})
- $`echo "https://i.darktru.win/${latestFile}" | wl-copy -n`.nothrow().catch(a => { });
- $`notify-send "Screenshot" "Uploaded in ${Date.now() - start}ms"`.nothrow().catch(a => { });
+ $`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 => { });
} catch (e_) {
$`notify-send "Screenshot" "${`${e_}`}"`.nothrow().catch(a => { });
}
diff --git a/scripts/edit-last-screenshot.sh b/scripts/edit-last-screenshot.sh
index c78e2cc..6189fcc 100755
--- a/scripts/edit-last-screenshot.sh
+++ b/scripts/edit-last-screenshot.sh
@@ -5,7 +5,7 @@ SCREENSHOTS_DIR="$HOME/Pictures/Screenshots"
LAST_SCREENSHOT=$(ls -t "$SCREENSHOTS_DIR" | head -n 1)
if [[ -n "$LAST_SCREENSHOT" ]]; then
- swappy -f "$SCREENSHOTS_DIR/$LAST_SCREENSHOT" # -o "$SCREENSHOTS_DIR/$LAST_SCREENSHOT"
+ swappy -f "$SCREENSHOTS_DIR/$LAST_SCREENSHOT" -o "$SCREENSHOTS_DIR/$LAST_SCREENSHOT"
else
notify-send -u critical -t 3 "Error" "Can't find screenshot :("
fi
diff --git a/scripts/hot-reload.sh b/scripts/hot-reload.sh
index 6f07374..2361dfa 100755
--- a/scripts/hot-reload.sh
+++ b/scripts/hot-reload.sh
@@ -1,6 +1,6 @@
#!/bin/bash
-trap "pkill -9 waybar" EXIT
+pkill -9 waybar
hyprctl dispatch exec "GTK_THEME=Adwaita waybar -c ~/config/config/waybar/config -s ~/config/config/waybar/style.css" &
hyprctl reload
diff --git a/scripts/lib/RegretevatorUtil.ts b/scripts/lib/RegretevatorUtil.ts
new file mode 100644
index 0000000..6c88d06
--- /dev/null
+++ b/scripts/lib/RegretevatorUtil.ts
@@ -0,0 +1,49 @@
+import { existsSync, readFileSync } from "fs";
+
+const STATE_FILE_PATH = "/tmp/.regretevator_state";
+
+type DeadUnknownState = { state: "DEAD" | "UNKNOWN" };
+
+type InElevatorState = {
+ floor: number;
+ state: "INGAME";
+ isGoingUp: boolean;
+};
+
+export type RegretevatorState = DeadUnknownState | InElevatorState;
+
+/*
+
+➜ config git:(main) ✗ cat /tmp/.regretevator_state
+{"text":"ý 82","tooltip":"On Floor 82"}
+➜ config git:(main) ✗ cat /tmp/.regretevator_state
+{"text":"ý ","tooltip":"Floor 82 83"}
+
+*/
+
+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'))
+ if (/^On Floor ([0-9]+)$/.test(tooltip)) {
+ const floorNum = tooltip.match(/^On Floor ([0-9]+)$/)![1]
+ return {
+ floor: Number(floorNum),
+ state: "INGAME",
+ isGoingUp: false
+ }
+ }
+ if (/^Floor ([0-9]+)/.test(tooltip)) {
+ const floorNum = tooltip.match(/^Floor ([0-9]+)/)![1]
+ return {
+ floor: Number(floorNum),
+ state: "INGAME",
+ isGoingUp: true
+ }
+ }
+ return {
+ state: "UNKNOWN"
+ }
+ } catch {}
+ return null;
+}