dotfiles/.config/wm_scripts/screenshot.sh
2021-05-23 14:30:50 +08:00

90 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
#
# Script to take screenshots or gifs
#
scrot_dir=$HOME/screenshots
gif_dir=$scrot_dir/gifs
date_format='%Y-%m-%d_%H-%M-%S'
[ -d $scrot_dir ] || mkdir $scrot_dir
[ -d $gif_dir ] || mkdir $gif_dir
main() {
prompt_main
}
# prompt with rofi
prompt_main() {
options="
1) Fullscreen\n\
2) Selection\n\
3) Record screen
"
#echo -e $options
# -i case insensitive
# -l vertical lines
option=$(echo -e $options | rofi -dmenu)
#echo "\"$option\""
case $option in
1*)
sleep 0.5
f_scrot
;;
2*)
s_scrot
;;
3*)
prompt_gif
;;
esac
}
prompt_gif() {
options="
10s\n\
30s\n\
60s
"
option=$(echo -e $options | rofi -dmenu)
case $option in
10s)
byzanz_gif 10
;;
30s)
byzanz_gif 30
;;
60s)
byzanz_gif 60
;;
esac
}
# screenshots using scrot
s_scrot() {
name=$(date +${date_format}_sel.png)
path="${scrot_dir}/${name}"
scrot -s $path &
xclip -sel clip $path -t image/png
}
f_scrot() {
name=$(date +${date_format}_full.png)
path="${scrot_dir}/${name}"
scrot $path &&
xclip -sel clip $path -t image/png
}
# screen recorder
byzanz_gif() {
name=$(date +${date_format}.gif)
path="${gif_dir}/${name}"
byzanz-record -c -d $1 --delay=0 $path
}
main "$@"