Created
July 12, 2021 18:44
-
-
Save theagoliveira/8cd955f2a6532b0daedf895ef1b0217a to your computer and use it in GitHub Desktop.
Generate Wi-Fi QR Code (https://news.ycombinator.com/item?id=27803146)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1 | |
qrencode -t utf8 'WIFI:T:WPA;S:network;P:password;;' | |
# 2 | |
read -rp "SSID: " ssid | |
read -rsp "Password: " pass | |
echo -e "\n" | |
qrencode -t utf8 "WIFI:T:WPA;S:$ssid;P:$pass;;" | |
echo "SSID: $ssid" | |
# 3 | |
#!/usr/bin/env bash | |
out="${1:-wifi-card.pdf}" | |
read -rp "SSID: " ssid | |
read -rsp "Password: " pass | |
echo -e "\nGenerating PDF..." | |
{ | |
cat << EOF | |
<table> | |
<tr> | |
<td><img src="data:image/png;base64,$(qrencode -o - -t png "WIFI:T:WPA;S:$ssid;P:$pass;;" | base64)"></td> | |
<td><span>SSID: $ssid</span><br><span>Password: $pass</span></td> | |
</tr> | |
</table> | |
<p> | |
<img width=16 height=16 src="https://raw.githubusercontent.com/iamcal/emoji-data/master/img-apple-64/1f4f8.png"> | |
<img width=16 height=16 src="https://raw.githubusercontent.com/iamcal/emoji-data/master/img-apple-64/1f4f1.png"> | |
Point your phone's camera at the QR Code to connect automatically. | |
</p> | |
EOF | |
} | pandoc --pdf-engine=xelatex -f html -t pdf -o "$out" | |
echo "$out" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment