From d0dd41c080c47ff49f09f668b8ca03fbd5788745 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Tue, 12 Dec 2023 00:38:16 -0500 Subject: [PATCH] Add screenshot thingy --- session/src/xmd-screenshot | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 session/src/xmd-screenshot diff --git a/session/src/xmd-screenshot b/session/src/xmd-screenshot new file mode 100755 index 0000000..d056aea --- /dev/null +++ b/session/src/xmd-screenshot @@ -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