Last active
June 25, 2023 20:56
-
-
Save adam-zethraeus/5561139e581d89e751d7bd9e495ddae1 to your computer and use it in GitHub Desktop.
Generate a WiFi-auto-connect qrcode
This file contains 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 | |
usage() { echo "Usage: $0 [-o <output file>] [-n <wifi name>] [-p <password>] [-t <WPA|WEP>]" 1>&2; exit 1; } | |
while getopts ":n:p:t:o:h" param; do | |
case "${param}" in | |
n) | |
n="${OPTARG}" | |
;; | |
p) | |
p="${OPTARG}" | |
;; | |
t) | |
t="${OPTARG^^}" | |
[[ "${t^^}" == "WPA" ]] || [[ "${t^^}" == "WEP" ]] || usage | |
;; | |
o) | |
o="${OPTARG}" | |
;; | |
*) | |
usage | |
;; | |
esac | |
done | |
shift $((OPTIND-1)) | |
[ ! -z "${n}" ] || read -p "WiFi name: " n | |
[ ! -z "${p}" ] || read -p "WiFi password: " p | |
if [ -z "${t}" ]; then | |
read -p "Security type. WPA or WEP: " t | |
[ "${t^^}" == 'WPA'] || [ "${t^^}" == 'WEP' ] || usage | |
t=$(echo "${t^^}") | |
fi | |
[ ! -z "${o}" ] || read -p "Output file path: " o | |
qrencode -o "${o}" "WIFI:S:${n};T:${t};P:${p};;" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment