Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
executable file 59 lines (50 sloc) 1.24 KB
#!/bin/bash
# c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t
# vi: set shiftwidth=4 tabstop=4 noexpandtab:
# :indentSize=4:tabSize=4:noTabs=false:
set -o nounset
set -o errexit
set -o pipefail
# shellcheck disable=SC1090
source "$HOME/bin/common.bash"
screenshotdir="$HOME/t/grabs"
filename="$(date +%Y%m%d-%H%M%S)"
imagefile="${screenshotdir}/${filename}.png"
swappyimagefile="${screenshotdir}/${filename}-swappy.png"
util="/usr/bin/grimshot save"
mkdir -p $screenshotdir
action="${1:-select}"
notify_debug "Got action '${action}'"
case ${action} in
select)
options="area"
;;
window)
options="active"
;;
screen)
options="output"
;;
full)
options="screen"
;;
*)
errexit "Unknown action ${action}"
;;
esac
grabcommand="${util} ${options} ${imagefile}"
notify_debug "executing ${grabcommand}"
if ifdebug3
then
grabcommand="echo ${grabcommand}"
fi
notify2 "${grabcommand}"
if ${grabcommand}
then
notify2 "Screenshot ${action} saved to ${imagefile}"
echo -n ${imagefile} | wl-copy
else
errexit "Screenshot ${action} failed"
fi
notify2 "swappy --file ${imagefile} --output-file ${swappyimagefile}"
swappy --file "${imagefile}" --output-file - | tee "${swappyimagefile}" | wl-copy