Advertisement
Guest User

clipcode v2.0

a guest
Jan 20th, 2012
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.50 KB | None | 0 0
  1. #!/bin/bash
  2. # Empty clipboard to specified file every $WAIT seconds
  3.  
  4. WAIT=1 # Time to wait (in seconds)
  5. CLIP_COMMAND="xclip -sel clip -o" #Command to execute
  6.  
  7. # If no file is given, print usage and exit
  8. if [ "x$1" = "x" ];
  9.     then
  10.         echo "Usage: $(basename $0) <file>"
  11.         exit 1
  12. fi
  13.  
  14. # Create file if it doesn't exist
  15. if [ ! -a "$1" ];
  16.     then
  17.         touch "$1"
  18. fi
  19.  
  20. while true; do
  21.     if [ "$(echo $($CLIP_COMMAND))" != "$(tail -1 "$1")" ];
  22.         then
  23.             echo $($CLIP_COMMAND) >> "$1"
  24.     fi
  25. sleep ${WAIT}s
  26. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement