Last active
October 3, 2020 04:38
-
-
Save Vresod/292931eb2e713d44aaa0a3fb536a3bc0 to your computer and use it in GitHub Desktop.
This file contains 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 | |
# Requirements: | |
# Rofi/dmenu | |
# Zenity (for file saving dialog) | |
# Scrot/maim | |
[ -x /usr/bin/rofi ] && selector="rofi -dmenu" || selector="dmenu" | |
[ -x /usr/bin/maim ] && scrot="maim -lc 0.5,0.2,0.7,0.3" || scrot="scrot" | |
# get wanted form of screenshot from an argument or from rofi | |
[ $1 = "select" ] 2> /dev/null && type="select" | |
[ $1 = "fullscreen" ] 2> /dev/null && type="fullscreen" | |
[ $type ] || type=$(echo "select\nfullscreen"|$selector) | |
# take screenshot and save it to /tmp/screenshot.png | |
[ $type = "select" ] && $scrot -s /tmp/screenshot.png | |
[ $type = "fullscreen" ] && $scrot /tmp/screenshot.png | |
# get wanted way to save screenshot from an argument or from rofi | |
[ $2 = "clip" ] 2> /dev/null && save="clip" | |
[ $2 = "save" ] 2> /dev/null && save="save" | |
[ $2 = "primary" ] 2> /dev/null && save="primary" | |
[ $2 = "secondary" ] 2> /dev/null && save="secondary" | |
[ $save ] || save=$(echo "save\nclip\nprimary\nsecondary"|$selector) | |
# copy/save screenshot | |
[ $save = "clip" ] && cat /tmp/screenshot.png|xclip -se c -t image/png -i | |
[ $save = "primary" ] && cat /tmp/screenshot.png|xclip -se p -t image/png -i | |
[ $save = "secondary" ] && cat /tmp/screenshot.png|xclip -se s -t image/png -i | |
[ $save = "save" ] && loc=$(zenity --file-selection --save) && cp /tmp/screenshot.png $loc | |
[ $loc ] && saveto=$loc || saveto=$save | |
notify-send "screenshot taken and saved to $saveto" | |
rm /tmp/screenshot.png |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment