File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1818
1919
2020listen () {
21+ echo " $( basename $0 ) watching for clipboard changes"
2122 wl-paste -w wl-clipboard-history
2223}
2324
@@ -30,15 +31,27 @@ helpusage () {
3031 echo " -p [INDEX] Print clipboard entry at INDEX (defaults to the last entry)"
3132}
3233
34+ mime_type () {
35+ file --mime-type - | sed -E ' s|.*: (.*)|\1|'
36+ }
37+
3338if [ $# = 0 ]; then
3439 contents=" $( < /dev/stdin sed " s/'/''/g" ) "
3540 if [ " $contents " = " " ]; then
3641 helpusage
3742 exit 1
38- else
39- query " INSERT INTO c (contents) VALUES ('${contents} ');"
40- exit 0
4143 fi
44+
45+ mime_type=" $( echo " ${contents} " | mime_type) "
46+ case ${mime_type} in
47+ text/* )
48+ query " INSERT INTO c (contents) VALUES ('${contents} ');"
49+ ;;
50+ * )
51+ echo " Got mime type ${mime_type} , not inserting."
52+ ;;
53+ esac
54+ exit 0
4255fi
4356
4457
You can’t perform that action at this time.
0 commit comments