Skip to content

Instantly share code, notes, and snippets.

@radgeRayden
Created September 8, 2020 03:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save radgeRayden/644066802f0dea4e99eb2da0cc482da3 to your computer and use it in GitHub Desktop.
Save radgeRayden/644066802f0dea4e99eb2da0cc482da3 to your computer and use it in GitHub Desktop.
#!/bin/fish
set -l MONTH (date +"%B")
set -l YEAR (date +"%Y")
set -l SSDIR "$HOME/Pictures/Screenshots/$YEAR-$MONTH"
mkdir -p $SSDIR
if test "$argv[1]" = "display"
if maim /tmp/screenshot.png
xclip -selection clipboard -t image/png -i /tmp/screenshot.png
set -l SSPATH $SSDIR/(date +%s)-(identify -format '%wx%h' /tmp/screenshot.png).png
mv /tmp/screenshot.png $SSPATH
end
end
if test "$argv[1]" = "window"
if maim -i (xdotool getactivewindow) /tmp/screenshot.png
xclip -selection clipboard -t image/png -i /tmp/screenshot.png
set -l SSPATH $SSDIR/(date +%s)-(identify -format '%wx%h' /tmp/screenshot.png).png
mv /tmp/screenshot.png $SSPATH
end
end
if test "$argv[1]" = "area"
maim /tmp/screenshotbg.png
sxiv -fbZ /tmp/screenshotbg.png &
sleep 0.5 #ensure sxiv won't override slop
if maim -s -b 1920 -r blur1,blur2 /tmp/screenshot.png
xclip -selection clipboard -t image/png -i /tmp/screenshot.png
set -l SSPATH $SSDIR/(date +%s)-(identify -format '%wx%h' /tmp/screenshot.png).png
mv /tmp/screenshot.png $SSPATH
end
#time to kill
xdotool key q
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment