Add screenshot thingy

This commit is contained in:
Sasha Koshka 2023-12-12 00:38:16 -05:00
parent b8eb80d232
commit d0dd41c080
1 changed files with 35 additions and 0 deletions

35
session/src/xmd-screenshot Executable file
View File

@ -0,0 +1,35 @@
#!/bin/sh
if ! type scrot > /dev/null; then
>&2 echo "!!! scrot is not installed"
exit 1
fi
picturesDir=`xdg-user-dir PICTURES`
test -z "$picturesDir" && picturesDir="$HOME/Pictures"
picturesDir="$picturesDir/Screen Shots"
if ! mkdir -p "$picturesDir"; then
>&2 echo "!!! can't create $picturesDir"
exit 1
fi
output="$picturesDir/`date -Iseconds`.png"
case "$1" in
"selection")
scrot --select --line style=dash --freeze --file "$output"
clipArg="$2"
;;
"window")
scrot --focused --border --file "$output"
clipArg="$2"
;;
*)
scrot --file "$output"
clipArg="$1"
;;
esac
if test "$clipArg" = "clipboard"; then
xclip -selection clipboard -target image/png -i "$output"
fi