feat(work): add print scripts
This commit is contained in:
parent
68011d1163
commit
392d20ce0b
30
work-laptop/configs/scripts/scripts/print-window.sh
Executable file
30
work-laptop/configs/scripts/scripts/print-window.sh
Executable file
@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
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
|
||||
if [[ $XDG_SESSION_TYPE == "x11" ]]; then
|
||||
maim -i $(xdotool getactivewindow) | xclip -sel clip -t image/png
|
||||
fi
|
||||
if [[ $XDG_SESSION_TYPE == "wayland" ]]; then
|
||||
if [[ $XDG_CURRENT_DESKTOP == "Hyprland" ]]; then
|
||||
window_info=$(hyprctl activewindow)
|
||||
coordinates=$(echo "$window_info" | grep -oP 'at: \K([0-9]+,[0-9]+)')
|
||||
size=$(echo "$window_info" | grep -oP 'size: \K([0-9]+,[0-9]+)')
|
||||
IFS=',' read -r x y <<< "$coordinates"
|
||||
IFS=',' read -r width height <<< "$size"
|
||||
grim -g "${x},${y} ${width}x${height}" ~/tmp/jabuxas.png
|
||||
wl-copy < ~/tmp/jabuxas.png
|
||||
fi
|
||||
|
||||
if [[ $XDG_CURRENT_DESKTOP == "sway" ]]; then
|
||||
rm $temp_screenshot
|
||||
grim -g "$(swaymsg -t get_tree | jq -j '.. | select(.type?) | select(.focused).rect | "\(.x),\(.y) \(.width)x\(.height)"')" $temp_screenshot
|
||||
wl-copy < ~/tmp/jabuxas.png
|
||||
swappy -f $temp_screenshot
|
||||
fi
|
||||
fi
|
@ -11,32 +11,33 @@ echo -e "[Default]\nsave_dir=$save_dir\nsave_filename_format=$save_file" > $swpy
|
||||
|
||||
upload ()
|
||||
{
|
||||
curl -F'file=@'"${save_dir}/${save_file}" -Fsecret= https://paste.jabuxas.xyz | wl-copy
|
||||
curl -F'file=@'"${save_dir}/${save_file}" -Fsecret= -H 'X-Auth: '$(cat ~/.key) https://paste.jabuxas.xyz | wl-copy
|
||||
}
|
||||
|
||||
function print_error
|
||||
{
|
||||
cat << "EOF"
|
||||
./screenshot.sh <action>
|
||||
./way-print.sh <action>
|
||||
...valid actions are...
|
||||
p : print all screens
|
||||
s : snip current screen
|
||||
sf : snip current screen (frozen)
|
||||
m : print focused monitor
|
||||
t : tmp print
|
||||
cw: current window
|
||||
EOF
|
||||
}
|
||||
|
||||
case $1 in
|
||||
p) # print all outputs
|
||||
~/.local/bin/grimblast copysave screen $temp_screenshot && swappy -f $temp_screenshot ;;
|
||||
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
|
||||
~/.local/bin/grimblast copysave area $temp_screenshot && swappy -f $temp_screenshot ;;
|
||||
sf) # frozen screen, drag to manually snip an area / click on a window to print it
|
||||
~/.local/bin/grimblast --freeze copysave area $temp_screenshot && swappy -f $temp_screenshot ;;
|
||||
grim -g "$(slurp)" $temp_screenshot && wl-copy < $temp_screenshot && swappy -f $temp_screenshot ;;
|
||||
m) # print focused monitor
|
||||
~/.local/bin/grimblast copysave output $temp_screenshot && swappy -f $temp_screenshot ;;
|
||||
t) #upload to 0x0.st temporarily
|
||||
~/.local/bin/grimblast copysave area $temp_screenshot && swappy -f $temp_screenshot && upload ;;
|
||||
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
|
||||
~/scripts/print-window.sh ;;
|
||||
*) # invalid option
|
||||
print_error ;;
|
||||
esac
|
||||
|
Loading…
Reference in New Issue
Block a user