wayshot.sh (768B)
1 #!/bin/sh 2 # 3 # Take screenshots on wayland 4 5 OUTPUT_PREFIX="$(xdg-user-dir PICTURES)/screenshots/" 6 7 # Create output folder if it doesn't exist 8 test ! -d $OUTPUT_PREFIX && mkdir -p $OUTPUT_PREFIX 9 10 # Take the screenshot, save to a file & copy to clipboard 11 shoot() { 12 # Get current date and time 13 timestamp=$(date +"%Y-%m-%d_%H-%M-%S") 14 15 # Name screenshot 16 input=$(printf "" | wmenu -p "Filename: " -S 222222) 17 test -n "$input" && filename="${OUTPUT_PREFIX}${input}.png" 18 # Take timesramp if input/name is empty 19 test ! -n "$input" && filename="${OUTPUT_PREFIX}${timestamp}.png" 20 21 # Save screenshot to file & copy to clipboard 22 grim -g "$(slurp)" - | wl-copy --type image/png 23 test ! -n "$filename" && exit 1 24 wl-paste > $filename 25 } 26 27 shoot