Skip to content

Instantly share code, notes, and snippets.

@christopherdolan
Created March 18, 2019 20:52
Show Gist options
  • Save christopherdolan/8da299e1c36a12ecb3a06e71f1acfd0d to your computer and use it in GitHub Desktop.
Save christopherdolan/8da299e1c36a12ecb3a06e71f1acfd0d to your computer and use it in GitHub Desktop.
Just like vanilla i3-scrot, except this one uses xclip to load your clipboard with the saved screenshot
#!/bin/sh
# /usr/bin/i3-scrot
#
# simple screenshot-script using scrot for manjaro-i3 by oberon@manjaro.org
_conf=$HOME/.config/i3-scrot.conf
if ! [ -f $_conf ]; then
echo "scrot_dir=$(xdg-user-dir PICTURES)" > $_conf
fi
source $_conf
if ! [ -d $scrot_dir ]; then
mkdir -p $scrot_dir
fi
if ! [[ -z "$2" ]]; then
cmd="scrot -d $2"
else
cmd="scrot"
fi
case "$1" in
--desk|-d|$NULL)
cd $scrot_dir
$cmd -e 'xclip -selection clipboard -t image/png -i $f' &&
sleep 1 &&
notify-send "screenshot has been saved in $scrot_dir"
;;
--window|-w)
cd $scrot_dir
$cmd -u -e 'xclip -selection clipboard -t image/png -i $f' &&
sleep 1 &&
notify-send "screenshot has been saved in $scrot_dir"
;;
--select|-s)
cd $scrot_dir
notify-send 'select an area for the screenshot' &
scrot -s -e 'xclip -selection clipboard -t image/png -i $f' &&
sleep 1 && notify-send "screenshot has been saved in $scrot_dir"
;;
--help|-h)
echo "
available options:
-d | --desk full screen
-w | --window active window
-s | --select selection
-h | --help display this information
The -d or -w options can be used with a delay
by adding the number of seconds, like for example:
'i3-scrot -w 5'
Default option is 'full screen'.
The file destination can be set in ${_conf}.
Default is $scrot_dir
"
;;
*)
echo "
== ! i3-scrot: missing or wrong argument ! ==
available options:
-d | --desk full screen
-w | --window active window
-s | --select selection
-h | --help display this information
Default option is 'full screen'.
The file destination can be set in ${_conf}.
Default is $scrot_dir
"
exit 2
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment