Starts adding wayland support to my screenshot script

master
Jonathan Hodgson 3 years ago
parent cc94b994b5
commit 5252713d76
  1. 44
      bin/.bin/screenshot

@ -31,14 +31,26 @@ file="${path}/${filename}"
case $1 in case $1 in
"window") "window")
maim -i $(xdotool getactivewindow) "$file" if [ -n "$WAYLAND_DISPLAY" ]; then
notify-send "Can't get current window yet in wayland"
else
maim -i $(xdotool getactivewindow) "$file"
fi
;; ;;
"select") "select")
#maim -s -r crosshair "$file" if [ -n "$WAYLAND_DISPLAY" ]; then
maim -s -c 0.41,0.62,0.42,0.2 -l -u "$file" grim -g "$(slurp)" "$file"
else
#maim -s -r crosshair "$file"
maim -s -c 0.41,0.62,0.42,0.2 -l -u "$file"
fi
;; ;;
*) *)
maim "$file" if [ -n "$WAYLAND_DISPLAY" ]; then
grim "$file"
else
maim "$file"
fi
;; ;;
esac esac
@ -52,13 +64,25 @@ if [ -f "$file" ]; then
notify-send "ocr" "no text was detected\nimage file at $file" notify-send "ocr" "no text was detected\nimage file at $file"
exit 1 exit 1
fi fi
cat "${file}.txt" | xclip -selection clipboard if [ -n "$WAYLAND_DISPLAY" ]; then
echo -n "${file}.txt" | xclip -selection primary cat "${file}.txt" | wl-copy
echo -n "${file}.txt" | wl-copy --primary
else
cat "${file}.txt" | xclip -selection clipboard
echo -n "${file}.txt" | xclip -selection primary
fi
else else
# Copies the image to your clipboard (ctrl + v) if [ -n "$WAYLAND_DISPLAY" ]; then
xclip -selection clipboard -target image/png -i "$file" # Copies the image to your clipboard (ctrl + v)
# Copies the filename to primary selection (shift + insert or middle mouse) wl-copy < "$file"
echo -n "$file" | xclip -selection primary # Copies the filename to primary selection (shift + insert or middle mouse)
echo -n "$file" | wl-copy --primary
else
# Copies the image to your clipboard (ctrl + v)
xclip -selection clipboard -target image/png -i "$file"
# Copies the filename to primary selection (shift + insert or middle mouse)
echo -n "$file" | xclip -selection primary
fi
# Creates notification with file name # Creates notification with file name
notify-send "New Screenshot" "$file" notify-send "New Screenshot" "$file"
fi fi

Loading…
Cancel
Save