majorly enhance my stuff

This commit is contained in:
2025-03-12 21:25:53 +02:00
parent 2e01b26e5a
commit 6fafc566ae
15 changed files with 216 additions and 21 deletions

View File

@@ -0,0 +1,79 @@
import { $ } from "bun";
import { Command } from "commander";
import sharp from "sharp";
import { writeFileSync } from "fs";
const program = new Command("handle-screenshot");
const SCREENSHOT_PATH = `/home/ocbwoy3/Pictures/Screenshots`;
async function transformImage(b: Buffer): Promise<Buffer> {
const image = sharp(b).ensureAlpha();
const { width, height } = await image.metadata();
// console.log(width, height);
const mask = Buffer.from(
`<svg width="${width}" height="${height}">
<rect x="0" y="0" width="${width}" height="${height}" rx="16" fill="white"/>
</svg>`
);
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();
}
(() => {
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();
const BUF = Buffer.from(_BUF);
const _d = new Date();
const FILENAME = `${SCREENSHOT_PATH}/${_d.toISOString()}-${_d.getTime()}.png`
const cb = await transformImage(BUF);
writeFileSync(FILENAME,cb);
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();
const _BUF = await $`grim -t png -l 0 -o ${selection.trim()} -`.arrayBuffer();
const BUF = Buffer.from(_BUF);
const _d = new Date();
const FILENAME = `${SCREENSHOT_PATH}/${_d.toISOString()}-${_d.getTime()}.png`
console.log(FILENAME)
const cb = await transformImage(BUF);
writeFileSync(FILENAME,cb);
});
})();
program.parse(process.argv);

14
scripts/dev/notif-test.sh Normal file
View File

@@ -0,0 +1,14 @@
hyprctl notify 1 5000 0 " Loading OCbwoy3's Dotfiles"
# Dotfiles
notify-send "Welcome to 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."
notify-send "Regretevator" "Do I see Regretevator?"
notify-send "Regretevator" "Floor 729"
notify-send "Regretevator" "Floor 729 - 49/50"
notify-send -i /tmp/.tuxstrap.png "Roblox" "Regretevator [ELEVATOR SIMULATOR]\n(UDMUX Protected)"
notify-send -i /tmp/pest.png -a "regretevator-npc-chat" "Pest" "いいえ! これは許されません! パンタロンのコンパートメント を空にしましょう。"

View File

@@ -0,0 +1,23 @@
# run roblox in fullscreen with mouse sensitivity of the os default and not some value set by roblox
#!/usr/bin/env sh
HYPRGAMEMODE=$(hyprctl getoption animations:enabled | awk 'NR==1{print $2}')
if [ "$HYPRGAMEMODE" = 1 ] ; then
hyprctl --batch "\
keyword animations:enabled 0;\
keyword decoration:drop_shadow 0;\
keyword decoration:blur:enabled 0;\
keyword general:gaps_in 0;\
keyword general:gaps_out 0;\
keyword general:border_size 0;\
keyword decoration:rounding 0;\
keyword decoration:active_opacity 1;\
keyword decoration:inactive_opacity 1;\
keyword decoration:fullscreen_opacity 1;"
notify-send -t 5000 -u critical "OCbwoy3's Dotfiles" "Enabled game mode"
pkill -9 waybar
exit
fi
bash ~/config/scripts/hot-reload.sh
# hyprctl reload
notify-send -t 5000 -u critical "OCbwoy3's Dotfiles" "Disabled game mode"

View File

@@ -0,0 +1,11 @@
#!/bin/bash
# do NOT use $PATH for this!!
SS_PATH=$(timeout 30s bun run ~/config/scripts/bin/handleScreenshot.ts fullscreen)
echo "$SS_PATH"
if [[ -n "$SS_PATH" && "$SS_PATH" == /home/ocbwoy3/Pictures/Screenshots/* ]]; then
wl-copy < "$SS_PATH"
notify-send "Screenshot" "Successfully captured screenshot to clipboard"
fi

11
scripts/screenshot-selection.sh Executable file
View File

@@ -0,0 +1,11 @@
#!/bin/bash
# do NOT use $PATH for this!!
SS_PATH=$(timeout 30s bun run ~/config/scripts/bin/handleScreenshot.ts selection)
echo "$SS_PATH"
if [[ -n "$SS_PATH" && "$SS_PATH" == /home/ocbwoy3/Pictures/Screenshots/* ]]; then
wl-copy < "$SS_PATH"
notify-send "Screenshot" "Successfully captured screenshot to clipboard"
fi

View File

@@ -0,0 +1,17 @@
KBLANG=$(hyprctl getoption input:kb_layout | awk 'NR==1{print $2}')
if [ "$KBLANG" = "us" ] ; then
hyprctl --batch "\
keyword input:kb_layout lv;\
keyword input:kb_variant apostrophe;"
# keyword input:kb_options compose:apostrophe;"
notify-send -u low "OCbwoy3's Dotfiles" "Keyboard Layout: Latvian"
exit
elif [ "$KBLANG" = "lv" ] ; then
# hyprctl --batch "\
# keyword input:kb_layout us;\
# keyword input:kb_variant;"
# i have no fucking idea how to unset input:kb_variant with hyprctl
hyprctl reload
notify-send -u low "OCbwoy3's Dotfiles" "Keyboard Layout: English"
exit
fi