Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- ## ho: the GNU vanity tool ##
- # Options
- HODIR="$HOME/whore"
- DEVICE="/dev/video0"
- VIEWER="gpicview"
- DELAY="0.1s"
- # User friendliness
- [ "$1" = "-h" ] && { echo "Usage: press 's' to save, convert and view your ugly fucking face. Use keys 1-8 for stupid tricks."; exit 0; }
- for dep in mplayer convert xwininfo fuser $VIEWER; do
- [ ! -x "$(which $dep)" ] && { echo "Make sure mplayer, imagemagick, x11-utils, psmisc and $VIEWER are installed."; exit 1; }
- done
- # Init
- mkdir -p "$HODIR"
- TEMPDIR=$(mktemp -d)
- cd $TEMPDIR
- for f in $(ls $HODIR/shot*.jpg); do
- touch $(basename ${f%.*}.png) # Mplayer needs dummy files to continue screenshot numbering
- done
- trap 'rm $TEMPDIR/*; rmdir $TEMPDIR; exit' INT QUIT TERM # Cleanup on exit
- # Webcam interface
- { nice mplayer tv:// -tv driver=v4l2:width=640:height=480:device=$DEVICE:fps=30:contrast=35:brightness=35:hue=-35:saturation=17 -vf hue,mirror,screenshot,scale=-2:$(xwininfo -root | grep Height: | awk '{print $2}'); kill $$; }&
- # Picture manager loop
- while sleep $DELAY; do
- for pic in shot*.png; do # For all new shots
- if [ -s $pic ]; then # if there are any
- until [ -z $(fuser $pic) ]; do sleep $DELAY; done # wait for mplayer to finish writing
- JPEG=$HODIR/${pic%.*}.jpg
- convert $pic -interlace PLANE -quality 90 $JPEG # convert to jpeg
- rm $pic # remove png
- $VIEWER $JPEG # show to the user
- fi
- done
- done
Add Comment
Please, Sign In to add comment