Last active
March 30, 2017 14:56
-
-
Save erronjason/d78108ced0f2221ba0b03c7ce95ba53e to your computer and use it in GitHub Desktop.
Generate a QR for your network automatically
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
#!/usr/bin/env bash | |
SSID="sample\ network" # Spaces should be escaped with the backslash character "\". | |
PASSWORD="password would go here" | |
SECURITY_TYPE="WPA2" # Allowed types are "WPA", "WPA2", and "WEP"; though there may be more. | |
COLOR="9f8f68" # This is the hex value of the color you wish to generate | |
PLAINTEXT="Network Name: $SSID\nPassword: $PASSWORD\nSecurity type: $SECURITY_TYPE\n" | |
command_exists () { | |
type "$1" &> /dev/null; | |
} | |
INSTALL_WARN="Please install it before continuing" | |
if ! command_exists qrencode; then | |
echo "qrencode was not found on this system" | |
echo $INSTALL_WARN; exit 1 | |
elif ! command_exists convert; then | |
echo "imagemagick's 'convert' was not found on this system" | |
echo $INSTALL_WARN; exit 1 | |
fi | |
qrencode -t SVG -o wifi-qr.svg "WIFI:S:$SSID;T:$SECURITY_TYPE;P:$PASSWORD;;" --background=00000000 --foreground=$COLOR -m 4 -s 30 | |
echo "qrencode complete" | |
convert -background transparent -interline-spacing 8 -pointsize 26 -fill "#$COLOR" -gravity South -annotate 0 "$PLAINTEXT" -gravity Center -append wifi-qr.svg wifi-qr-pt.svg | |
echo "convert complete" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment