Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only handle plaintext #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions wl-clipboard-history
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,40 @@ fi


listen () {
echo "$(basename $0) watching for clipboard changes"
wl-paste -w wl-clipboard-history
}

helpusage () {
echo "Usage: $0 OPTION [ARG]"
echo "Usage: $(basename $0) OPTION [ARG]"
echo ""
echo "Without any arguments the command will insert contents of stdin in the database"
echo " -t Track clipboard changes"
echo " -l [NUMBER] Print last NUMBER of clipboard entries (defaults to 10 entries)"
echo " -p [INDEX] Print clipboard entry at INDEX (defaults to the last entry)"
}

mime_type () {
file --mime-type - | sed -E 's|.*: (.*)|\1|'
}

if [ $# = 0 ]; then
contents="$(< /dev/stdin sed "s/'/''/g")"
if [ "$contents" = "" ]; then
helpusage
exit 1
else
query "INSERT INTO c (contents) VALUES ('${contents}');"
exit 0
fi

mime_type="$(echo "${contents}" | mime_type)"
case ${mime_type} in
text/*)
query "INSERT INTO c (contents) VALUES ('${contents}');"
;;
*)
echo "Got mime type ${mime_type}, not inserting."
;;
esac
exit 0
fi


Expand Down