maim-utils/maim-utils

48 lines
1.6 KiB
Bash
Executable file

#!/bin/sh
savedir="${SCROTDIR:-$HOME/Pictures/Screenshots}"
filename="$savedir/$(date -Iseconds)_maim.png"
# test whether the screenshot directory exists, if not, create it.
[ -d $savedir ] || mkdir -p $savedir
fullscreen(){
maim -ui root "$filename"
notify-send 'Maim utils' "Shot entire screen and saved output to:\n\n$filename"
}
selection(){
maim -su "$filename"
notify-send 'Maim utils' "Shot selection and saved output to:\n\n$filename\n\nBe aware that the selection process can be cancelled using any keypress and that this won't show up due to xclip eating the exit status."
}
focus(){
maim -ui "$(xdotool getactivewindow)" "$filename"
notify-send 'Maim utils' "Shot focussed window and saved output to:\n\n$filename"
}
clip_fullscreen(){
maim -ui root | xclip -sel clip -t image/png
notify-send 'Maim utils' "Shot entire screen and sent it to the clipboard."
}
clip_selection(){
maim -su | xclip -sel clip -t image/png
notify-send 'Maim utils' "Shot selection and sent it to the clipboard.\nBe aware that the selection process can be cancelled using any keypress and that this won't show up due to xclip eating the exit status."
}
clip_focus(){
maim -ui "$(xdotool getactivewindow)" | xclip -sel clip -t image/png
notify-send 'Maim utils' "Shot focussed window and sent it to the clipboard."
}
case $1 in
sel|selection) selection;;
sel-clip|clip-sel|clip-selection) clip_selection;;
full|fullscreen) fullscreen;;
full-clip|clip-full|clip-fullscreen) clip_fullscreen;;
focus) foucs;;
clip-focus|focus-clip) clip_focus;;
open|show|screenshots) xdg-open $savedir;;
esac