Created
September 24, 2021 07:36
-
-
Save stbuehler/370ddbed646ff4f4c6fbe336e613154b to your computer and use it in GitHub Desktop.
scrot to clipboard with automatic cleanup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# example config for i3 (.config/i3/config): | |
# # select window with mouse | |
# bindsym Print exec --no-startup-id scrot-xclip.sh --select --freeze | |
# # current window | |
# bindsym $mod+Print exec --no-startup-id scrot-xclip.sh --focused | |
set -e | |
tmpdir=$(mktemp --tmpdir -d scrot-xclip-XXXXXXX) | |
trap 'rm -rf "${tmpdir}"' EXIT | |
setxkbmap -option grab:break_actions | |
xdotool key XF86Ungrab | |
scrot "$@" "${tmpdir}"/'screenshot-%Y-%m-%d_%H:%M:%S.png' -e \ | |
'exec xclip -quiet -t image/png -selection clipboard -i $f' | |
echo "Clipboard got overwritten" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment