From 194a4280d695f558301a3ad17db55d5325454a74 Mon Sep 17 00:00:00 2001 From: jabuxas Date: Tue, 26 Nov 2024 08:54:20 -0300 Subject: [PATCH] feat(desktop): add way-print script --- desktop/configs/scripts/scripts/way-print.sh | 45 ++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 desktop/configs/scripts/scripts/way-print.sh diff --git a/desktop/configs/scripts/scripts/way-print.sh b/desktop/configs/scripts/scripts/way-print.sh new file mode 100755 index 0000000..77a02c7 --- /dev/null +++ b/desktop/configs/scripts/scripts/way-print.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env sh + +swpy_dir="${XDG_CONFIG_HOME:-$HOME/.config}/swappy" +save_dir="$HOME/pics/screenshots" +save_file="screenshot-$(date -Iseconds | cut -d '+' -f1).png" +temp_screenshot="/tmp/screenshot.png" + +mkdir -p $save_dir +mkdir -p $swpy_dir +echo -e "[Default]\nsave_dir=$save_dir\nsave_filename_format=$save_file" > $swpy_dir/config + +upload () +{ + curl -F'file=@'"${save_dir}/${save_file}" -Fsecret= -H 'X-Auth: '$(cat ~/.key) https://paste.jabuxas.xyz | wl-copy +} + +function print_error +{ +cat << "EOF" + ./way-print.sh + ...valid actions are... + p : print all screens + s : snip current screen + m : print focused monitor + t : tmp print + cw: current window +EOF +} + +case $1 in +p) # print all outputs + grim $temp_screenshot && wl-copy < $temp_screenshot && swappy -f $temp_screenshot ;; +s) # drag to manually snip an area / click on a window to print it + grim -g "$(slurp)" $temp_screenshot && wl-copy < $temp_screenshot && swappy -f $temp_screenshot ;; +m) # print focused monitor + grim -o $(swaymsg -t get_workspaces | jq -r '.[] | select(.focused==true).output') $temp_screenshot && wl-copy < $temp_screenshot && swappy -f $temp_screenshot ;; +t) #upload to paste + grim -g "$(slurp)" $temp_screenshot && wl-copy < $temp_screenshot && swappy -f $temp_screenshot && upload ;; +cw) #current window + ~/.local/bin/print-window.sh ;; +*) # invalid option + print_error ;; +esac + +rm "$temp_screenshot"