Guest User

Untitled

a guest
Jun 17th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.56 KB | None | 0 0
  1. #!/bin/sh
  2. ## ho: the GNU vanity tool ##
  3.  
  4. # Options
  5. HODIR="$HOME/whore"
  6. DEVICE="/dev/video0"
  7. VIEWER="gpicview"
  8. DELAY="0.1s"
  9.  
  10. # User friendliness
  11. [ "$1" = "-h" ] && { echo "Usage: press 's' to save, convert and view your ugly fucking face. Use keys 1-8 for stupid tricks."; exit 0; }
  12. for dep in mplayer convert xwininfo fuser $VIEWER; do
  13.  [ ! -x "$(which $dep)" ] && { echo "Make sure mplayer, imagemagick, x11-utils, psmisc and $VIEWER are installed."; exit 1; }
  14. done
  15.  
  16. # Init
  17. mkdir -p "$HODIR"
  18. TEMPDIR=$(mktemp -d)
  19. cd $TEMPDIR
  20. for f in $(ls $HODIR/shot*.jpg); do
  21.  touch $(basename ${f%.*}.png)                            # Mplayer needs dummy files to continue screenshot numbering
  22. done
  23. trap 'rm $TEMPDIR/*; rmdir $TEMPDIR; exit' INT QUIT TERM  # Cleanup on exit
  24.  
  25. # Webcam interface
  26. { 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 $$; }&
  27.  
  28. # Picture manager loop
  29. while sleep $DELAY; do
  30.  for pic in shot*.png; do                              # For all new shots
  31.   if [ -s $pic ]; then                                 # if there are any
  32.    until [ -z $(fuser $pic) ]; do sleep $DELAY; done   # wait for mplayer to finish writing
  33.    JPEG=$HODIR/${pic%.*}.jpg
  34.    convert $pic -interlace PLANE -quality 90 $JPEG     # convert to jpeg
  35.    rm $pic                                             # remove png
  36.    $VIEWER $JPEG                                       # show to the user
  37.   fi
  38.  done
  39. done
Add Comment
Please, Sign In to add comment