File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,12 +16,12 @@ if [ ! -f "$clipboard_file" ]; then
1616 END;"
1717fi
1818
19-
2019listen () {
20+ echo " $( basename $0 ) watching for clipboard changes"
2121 wl-paste -w wl-clipboard-history
2222}
2323
24- helpusage () {
24+ helpusage () {
2525 echo " Usage: $( basename $0 ) OPTION [ARG]"
2626 echo " "
2727 echo " Without any arguments the command will insert contents of stdin in the database"
@@ -30,15 +30,27 @@ helpusage () {
3030 echo " -p [INDEX] Print clipboard entry at INDEX (defaults to the last entry)"
3131}
3232
33+ mime_type () {
34+ file --mime-type - | sed -E ' s|.*: (.*)|\1|'
35+ }
36+
3337if [ $# = 0 ]; then
3438 contents=" $( < /dev/stdin sed " s/'/''/g" ) "
3539 if [ " $contents " = " " ]; then
3640 helpusage
3741 exit 1
38- else
39- query " INSERT INTO c (contents) VALUES ('${contents} ');"
40- exit 0
4142 fi
43+
44+ mime_type=" $( echo " ${contents} " | mime_type) "
45+ case ${mime_type} in
46+ text/* )
47+ query " INSERT INTO c (contents) VALUES ('${contents} ');"
48+ ;;
49+ * )
50+ echo " Got mime type ${mime_type} , not inserting."
51+ ;;
52+ esac
53+ exit 0
4254fi
4355
4456
You can’t perform that action at this time.
0 commit comments