#!/bin/bash # # Trigger xfce4-screenshooter on PrtSc/SysRq key # Doesn't consume the key!! # Arguments, if given, is a command to use for processing the screenshot, # instead of getting a dialog about it. The capture is added as an # additional final argument, as a file in /tmp. # # Example for simply saving it in the ~/Pictures directory. # kbdo cp -t $HOME/Pictures # # Example for custom copying by inline scripting (same effect): # kbdo 'bash -c "X(){ cp $1 $HOME/Pictures; }; X $1"' CP # # Note above, that bash needs CP as the $0 for the -c scripting # # Example for post-processing with convert into fix resolution # kbdo 'bash -c "X(){ convert $1 -resize 800x600 ${1#.*}-x.png; }; X $1"' CVT # # Example for running custom script # kbdo $HOME/bin/mycp arg1 arg2 # # Note above, that the temporary snapshot file is added as an additional # last argument ("arg3" as it were); something like /tmp/Screenshot-date.png ARGS="$*" if [ -z "$ARGS" ] ; then PRG=( /usr/bin/xfce4-screenshooter -w ) else PRG=( /usr/bin/xfce4-screenshooter -w -o "$ARGS" ) fi EVL="" stdbuf -o0 xxd -c 24 -p < /dev/input/event0 | \ stdbuf -o0 sed 's/.\{32\}//;s/\(.\{12\}\).*/\1/' | \ while read EV ; do if [ "$EV" != "000000000000" ] ; then EVL+=" $EV" continue fi # echo "$EVL" >&2 if [ -z "${EVL%%*010063000100}" ] ; then # Act on the [PrtSc/SysRq] key echo "${PRG[@]}" >&2 "${PRG[@]}" & fi EVL="" done