Skip to content

Instantly share code, notes, and snippets.

@geolaw
Created April 12, 2022 12:07
Show Gist options
  • Save geolaw/009a5014dbd11d244617c56ee04b5341 to your computer and use it in GitHub Desktop.
Save geolaw/009a5014dbd11d244617c56ee04b5341 to your computer and use it in GitHub Desktop.
Watch xclip clipboard for http links, shove them into a sqlite database
#!/bin/bash -f
# capture URLS from the clipboard and push them into the urls sqlite db
while [ 1 ]; do
t=`xclip -o `
echo "clip board is $t"
echo $t | grep http > /dev/null
if [ "$?" == "0" ]; then
# query the database to see if its already there
uid=$(sqlite3 ~/urls.db "select uid from urls where url='$t';")
if [ "$uid" == "" ]; then
sqlite3 ~/urls.db "insert into urls (url) values ('$t');"
notify-send "Added $t to download db"
fi
fi
sleep 5
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment