contact-qr.sh (1193B)
1 #!/bin/sh 2 set -eu 3 4 # Contact information 5 FIRST_NAME="Anders" 6 LAST_NAME="Damsgaard" 7 TITLE="Team Lead" 8 ORG="GEUS: Geological Survey of Denmark and Greenland" 9 10 PHONE="+4591333533" 11 EMAIL="andam@geus.dk" 12 13 WEBSITE="https://andersdamsgaard.dk" 14 LINKEDIN="https://www.linkedin.com/in/anders-damsgaard-225075261/" 15 16 OUTPUT="${1:-$USER}" 17 18 if ! command -v qrencode >/dev/null 2>&1; then 19 echo "Error: qrencode is required" >&2 20 exit 1 21 fi 22 23 # Generate vCard 3.0 24 # CRLF line endings are required by the vCard format. 25 { 26 printf 'BEGIN:VCARD\r\n' 27 printf 'VERSION:3.0\r\n' 28 printf 'N:%s;%s;;;\r\n' "$LAST_NAME" "$FIRST_NAME" 29 printf 'FN:%s %s\r\n' "$FIRST_NAME" "$LAST_NAME" 30 printf 'ORG:%s\r\n' "$ORG" 31 printf 'TITLE:%s\r\n' "$TITLE" 32 printf 'TEL;TYPE=WORK,CELL,VOICE:%s\r\n' "$PHONE" 33 printf 'URL;TYPE=WhatsApp:https://wa.me/%s\r\n' "${PHONE#+}" 34 printf 'EMAIL;TYPE=WORK:%s\r\n' "$EMAIL" 35 printf 'URL;TYPE=WORK:%s\r\n' "$WEBSITE" 36 printf 'URL;TYPE=LinkedIn:%s\r\n' "$LINKEDIN" 37 printf 'END:VCARD\r\n' 38 } > "${OUTPUT}.vcf" 39 40 qrencode -t PNG -s 10 -m 4 -l M \ 41 -o "${OUTPUT}.png" < "${OUTPUT}.vcf" 42 43 qrencode -t SVG -m 4 -l M \ 44 -o "${OUTPUT}.svg" < "${OUTPUT}.vcf"