Advertisement
Guest User

clipcode

a guest
Jan 20th, 2012
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.44 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.  
  6. # If no file is given, print usage and exit
  7. if [ "x$1" = "x" ];
  8.     then
  9.         echo "Usage: $(basename $0) <file>"
  10.         exit 1
  11. fi
  12.  
  13. # Create file if it doesn't exist
  14. if [ ! -a "$1" ];
  15.     then
  16.         touch "$1"
  17. fi
  18.  
  19. while true; do
  20.     if [ "$(echo $(xclip -o))" != "$(tail -1 "$1")" ];
  21.         then
  22.             echo $(xclip -o) >> "$1"
  23.     fi
  24. sleep ${WAIT}s
  25. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement