dotfiles/.config/rofi/scripts/screenshot

45 lines
1017 B
Plaintext
Raw Normal View History

#!/bin/bash
DIR="$HOME/.config/rofi"
rofi_command="rofi -theme $DIR/themes/screenshot.rasi"
time=`date +%Y-%m-%d-%H-%M-%S`
dir="$HOME/Pictures/Screenshots"
file="Screenshot_${time}.png"
screenleft="< "
area=""
screenright=" >"
shotscreenleft() {
cd ${dir} && sleep 0.5 && maim -u -f png -g 2560x1440+0+0 | tee "$file" | xclip -selection clipboard -t image/png
}
shotscreenright() {
cd ${dir} && sleep 0.5 && maim -u -f png -g 2560x1440+2560+0 | tee "$file" | xclip -selection clipboard -t image/png
}
shotarea() {
cd ${dir} && sleep 0.5 && maim -u -f png -s -b 2 -c 0.35,0.55,0.85,0.25 -l | tee "$file" | xclip -selection clipboard -t image/png
}
if [[ ! -d "$dir" ]]; then
mkdir -p "$dir"
fi
options="$screenleft\n$area\n$screenright"
chosen="$(echo -e "$options" | $rofi_command -dmenu -selected-row 1)"
case $chosen in
$screenleft)
shotscreenleft
;;
$area)
shotarea
;;
$screenright)
shotscreenright
;;
esac