2024-01-15 14:17:58 -03:00
|
|
|
#!/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 ()
|
|
|
|
{
|
2024-09-09 23:09:39 -03:00
|
|
|
curl -F'file=@'"${save_dir}/${save_file}" -H 'X-Auth: '$(cat ~/.key) https://paste.jabuxas.xyz | wl-copy
|
2024-01-15 14:17:58 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
function print_error
|
|
|
|
{
|
|
|
|
cat << "EOF"
|
2024-09-09 23:09:39 -03:00
|
|
|
./way-print.sh <action>
|
2024-01-15 14:17:58 -03:00
|
|
|
...valid actions are...
|
|
|
|
p : print all screens
|
|
|
|
s : snip current screen
|
|
|
|
m : print focused monitor
|
2024-09-09 23:09:39 -03:00
|
|
|
t : tmp print
|
|
|
|
cw: current window
|
2024-01-15 14:17:58 -03:00
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
case $1 in
|
|
|
|
p) # print all outputs
|
2024-09-09 23:09:39 -03:00
|
|
|
grim $temp_screenshot && swappy -f $temp_screenshot ;;
|
2024-01-15 14:17:58 -03:00
|
|
|
s) # drag to manually snip an area / click on a window to print it
|
2024-09-09 23:09:39 -03:00
|
|
|
grim -g "$(slurp)" $temp_screenshot && swappy -f $temp_screenshot ;;
|
2024-01-15 14:17:58 -03:00
|
|
|
m) # print focused monitor
|
2024-09-09 23:09:39 -03:00
|
|
|
grim -o $(swaymsg -t get_workspaces | jq -r '.[] | select(.focused==true).output') $temp_screenshot && swappy -f $temp_screenshot ;;
|
|
|
|
t) #upload to paste temporarily
|
|
|
|
grim -g "$(slurp)" $temp_screenshot && swappy -f $temp_screenshot && upload ;;
|
|
|
|
cw) #current window
|
|
|
|
~/.local/bin/print-window.sh ;;
|
2024-01-15 14:17:58 -03:00
|
|
|
*) # invalid option
|
|
|
|
print_error ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
rm "$temp_screenshot"
|