added r2 <3
This commit is contained in:
@@ -17,7 +17,7 @@ exec-once = bash ~/config/config/scripts/xdg.sh
|
|||||||
exec-once = bash ~/config/config/scripts/gtk.sh
|
exec-once = bash ~/config/config/scripts/gtk.sh
|
||||||
|
|
||||||
# Start Hot Reload
|
# Start Hot Reload
|
||||||
exec-once = bash ~/config/config/scripts/hot-reload.sh
|
exec-once = sleep 1000 & bash ~/config/config/scripts/hot-reload.sh
|
||||||
|
|
||||||
# Start arRPC
|
# Start arRPC
|
||||||
exec-once = arrpc
|
exec-once = arrpc
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ bind = CTRL SUPER ALT, L, exec, hyprlock
|
|||||||
bind = $mainMod ALT CTRL, mouse_down, exec, hyprctl keyword cursor:zoom_factor "$(hyprctl getoption cursor:zoom_factor | awk 'NR==1 {factor = $2; if (factor < 1) {factor = 1}; print factor * 1.25}')"
|
bind = $mainMod ALT CTRL, mouse_down, exec, hyprctl keyword cursor:zoom_factor "$(hyprctl getoption cursor:zoom_factor | awk 'NR==1 {factor = $2; if (factor < 1) {factor = 1}; print factor * 1.25}')"
|
||||||
bind = $mainMod ALT CTRL, mouse_up, exec, hyprctl keyword cursor:zoom_factor "$(hyprctl getoption cursor:zoom_factor | awk 'NR==1 {factor = $2; if (factor < 1) {factor = 1}; print factor / 1.25}')"
|
bind = $mainMod ALT CTRL, mouse_up, exec, hyprctl keyword cursor:zoom_factor "$(hyprctl getoption cursor:zoom_factor | awk 'NR==1 {factor = $2; if (factor < 1) {factor = 1}; print factor / 1.25}')"
|
||||||
|
|
||||||
bind = $mainMod SHIFT, M, exec, bun run $HOME/config/scripts/bin/r2UploadScreenshot.ts
|
bind = $mainMod SHIFT, M, exec, bun run $HOME/config/scripts/bin/r2Upload.ts
|
||||||
bind = $mainMod, F1, exec, bash $HOME/config/scripts/roblox-fullscreen.sh
|
bind = $mainMod, F1, exec, bash $HOME/config/scripts/roblox-fullscreen.sh
|
||||||
bind = $mainMod, F2, exec, bash -c "xdg-open roblox://"
|
bind = $mainMod, F2, exec, bash -c "xdg-open roblox://"
|
||||||
bind = $mainMod, F5, exec, notify-send -u critical "Hyprland" "Enabled debug overlay" && hyprctl keyword debug:overlay 1
|
bind = $mainMod, F5, exec, notify-send -u critical "Hyprland" "Enabled debug overlay" && hyprctl keyword debug:overlay 1
|
||||||
|
|||||||
@@ -11,8 +11,10 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/commander": "^2.12.5",
|
"@types/commander": "^2.12.5",
|
||||||
|
"@types/dotenv": "^8.2.3",
|
||||||
"@types/sharp": "^0.32.0",
|
"@types/sharp": "^0.32.0",
|
||||||
"commander": "^13.1.0",
|
"commander": "^13.1.0",
|
||||||
|
"dotenv": "^16.4.7",
|
||||||
"sharp": "^0.33.5"
|
"sharp": "^0.33.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
# Plant this in your home dir
|
||||||
|
S3_ACCESS_KEY=xxxxxxxxxxxxxxxx
|
||||||
|
S3_SECRET_KEY=xxxxxxxxxxxxxxxx
|
||||||
|
S3_BUCKET_NAME=dotfiles-screenshot
|
||||||
|
S3_ENDPOINT_URL="https://xxxxxxxxxxxxxxxx.r2.cloudflarestorage.com"
|
||||||
@@ -3,6 +3,12 @@ import { Command } from "commander";
|
|||||||
import sharp from "sharp";
|
import sharp from "sharp";
|
||||||
import { writeFileSync } from "fs";
|
import { writeFileSync } from "fs";
|
||||||
|
|
||||||
|
async function getFilename(): Promise<string> {
|
||||||
|
const _d = new Date();
|
||||||
|
const windowClass = await $`hyprctl activewindow -j`.json();
|
||||||
|
return `${windowClass.initialClass || "Hyprland"}-${_d.getTime()}`;
|
||||||
|
}
|
||||||
|
|
||||||
const program = new Command("handle-screenshot");
|
const program = new Command("handle-screenshot");
|
||||||
|
|
||||||
const SCREENSHOT_PATH = `/home/ocbwoy3/Pictures/Screenshots`;
|
const SCREENSHOT_PATH = `/home/ocbwoy3/Pictures/Screenshots`;
|
||||||
@@ -48,8 +54,7 @@ async function transformImage(b: Buffer): Promise<Buffer> {
|
|||||||
const _BUF = await $`grim -t png -l 0 -g ${selection.stdout.toString().trim()} -`.arrayBuffer();
|
const _BUF = await $`grim -t png -l 0 -g ${selection.stdout.toString().trim()} -`.arrayBuffer();
|
||||||
let BUF = Buffer.from(_BUF) as Buffer;
|
let BUF = Buffer.from(_BUF) as Buffer;
|
||||||
|
|
||||||
const _d = new Date();
|
const FILENAME = `${SCREENSHOT_PATH}/${await getFilename()}.png`;
|
||||||
const FILENAME = `${SCREENSHOT_PATH}/${_d.toISOString()}-${_d.getTime()}.png`
|
|
||||||
|
|
||||||
// BUF = await transformImage(BUF);
|
// BUF = await transformImage(BUF);
|
||||||
writeFileSync(FILENAME,BUF);
|
writeFileSync(FILENAME,BUF);
|
||||||
@@ -66,8 +71,7 @@ async function transformImage(b: Buffer): Promise<Buffer> {
|
|||||||
const _BUF = await $`grim -t png -l 0 -o ${selection.trim()} -`.arrayBuffer();
|
const _BUF = await $`grim -t png -l 0 -o ${selection.trim()} -`.arrayBuffer();
|
||||||
let BUF = Buffer.from(_BUF) as Buffer;
|
let BUF = Buffer.from(_BUF) as Buffer;
|
||||||
|
|
||||||
const _d = new Date();
|
const FILENAME = `${SCREENSHOT_PATH}/${await getFilename()}.png`;
|
||||||
const FILENAME = `${SCREENSHOT_PATH}/${_d.toISOString()}-${_d.getTime()}.png`
|
|
||||||
|
|
||||||
// BUF = await transformImage(BUF);
|
// BUF = await transformImage(BUF);
|
||||||
writeFileSync(FILENAME,BUF);
|
writeFileSync(FILENAME,BUF);
|
||||||
|
|||||||
41
scripts/bin/r2Upload.ts
Normal file
41
scripts/bin/r2Upload.ts
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import { $, S3Client } from "bun";
|
||||||
|
import { configDotenv } from "dotenv";
|
||||||
|
import { homedir } from "os";
|
||||||
|
import { readdirSync, readFileSync, statSync } from "fs";
|
||||||
|
import { join } from "path";
|
||||||
|
|
||||||
|
try {
|
||||||
|
configDotenv({
|
||||||
|
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,
|
||||||
|
});
|
||||||
|
|
||||||
|
const screenshotsDir = join(homedir(), "Pictures", "Screenshots");
|
||||||
|
const files = readdirSync(screenshotsDir);
|
||||||
|
|
||||||
|
const latestFile = files
|
||||||
|
.map(file => ({
|
||||||
|
file,
|
||||||
|
time: statSync(join(screenshotsDir, file)).mtime.getTime()
|
||||||
|
}))
|
||||||
|
.sort((a, b) => b.time - a.time)[0].file;
|
||||||
|
|
||||||
|
const filePath = join(screenshotsDir, latestFile);
|
||||||
|
|
||||||
|
const start = Date.now();
|
||||||
|
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 => { });
|
||||||
|
} catch (e_) {
|
||||||
|
$`notify-send "Screenshot" "${`${e_}`}"`.nothrow().catch(a => { });
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
pkill -9 waybar
|
trap "pkill -9 waybar" EXIT
|
||||||
|
|
||||||
hyprctl dispatch exec "GTK_THEME=Adwaita waybar -c ~/config/config/waybar/config -s ~/config/config/waybar/style.css" &
|
hyprctl dispatch exec "GTK_THEME=Adwaita waybar -c ~/config/config/waybar/config -s ~/config/config/waybar/style.css" &
|
||||||
hyprctl reload
|
hyprctl reload
|
||||||
|
|||||||
Reference in New Issue
Block a user