Skip to content

Instantly share code, notes, and snippets.

@TethysSvensson
Created November 18, 2020 12:39
Show Gist options
  • Save TethysSvensson/d742e67d1ad04abf08a629f12a435fbb to your computer and use it in GitHub Desktop.
Save TethysSvensson/d742e67d1ad04abf08a629f12a435fbb to your computer and use it in GitHub Desktop.
{ pkgs, writeScriptBin, hacksaw, shotgun, xclip }:
writeScriptBin "screenshot" ''
#!${pkgs.bash}/bin/sh
set -e
file=$(date +/tmp/screenshot-%F-%H%M%S.png)
if [[ "$1" = "full" ]]; then
${shotgun}/bin/shotgun $file
else
selection=$(${hacksaw}/bin/hacksaw -f "-i %i -g %g")
${shotgun}/bin/shotgun $selection $file
fi
cat $file | ${xclip}/bin/xclip -t 'image/png' -selection clipboard
echo $file
''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment