* Add Wi-Fi QR sharing to network panel * Refine Wi-Fi QR sharing * Use QR glyph for Wi-Fi sharing * Add click-to-reveal password to the Wi-Fi share card Scanning the QR is the fast path, but the person typing on a laptop needs the actual password. A dimmed "Show password" hint under the QR toggles the secret in place. The password stays out of the shell until asked for: a click runs the new omarchy-network-password helper (a private pipe, never an argument), and closing the card drops it again. Open and enterprise networks never show the control. The card loses its Close button -- Escape and clicking outside already cover it -- and now sizes itself to its content. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Keep a dismissed Wi-Fi share card closed and make Escape reliable Closing the card mid-generation killed the helper, but its buffered stdout still arrived and repopulated the matrix, reopening the card the user just closed. Both collectors now honor qrExpectedStop, and the flag survives onExited because exit and stream-finished have no guaranteed order. The password fetch gets the same treatment so a reveal in flight during dismissal can't stash the secret into a closed card's state. The content's focus was claimed while the window was still unmapped, so Escape could land nowhere. Re-acquire it after mapping, the way KeyboardPanel does. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Share WEP networks correctly and restore the QR quiet zone NetworkManager models WEP as key-mgmt "none" plus a wep-key, so the QR helper encoded WEP networks as open -- a QR that scans fine and then silently fails to join. Encode them as T:WEP and let the password helper print the key. Also widen qrencode's margin from 2 to the spec's 4-module quiet zone; the card surround is dark, so that white border is all a scanner gets. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: David Heinemeier Hansson <david@hey.com> Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
66 lines
2.2 KiB
Bash
Executable File
66 lines
2.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# omarchy:summary=Generate a Wi-Fi QR matrix for the shell
|
|
# omarchy:group=network
|
|
# omarchy:args=<interface>
|
|
|
|
set -euo pipefail
|
|
|
|
interface=${1:?Usage: omarchy-network-qr <interface>}
|
|
uuid=$(nmcli --get-values GENERAL.CON-UUID device show "$interface" | head -n 1)
|
|
[[ -n $uuid && $uuid != "--" ]] || { echo "No active Wi-Fi connection" >&2; exit 1; }
|
|
|
|
mapfile -t fields < <(nmcli --show-secrets --escape no --get-values \
|
|
802-11-wireless.ssid,802-11-wireless-security.key-mgmt,802-11-wireless-security.psk,802-11-wireless.hidden,802-11-wireless-security.wep-key0 \
|
|
connection show uuid "$uuid")
|
|
|
|
ssid=${fields[0]:-}
|
|
key_management=${fields[1]:-}
|
|
password=${fields[2]:-}
|
|
hidden=${fields[3]:-no}
|
|
wep_key=${fields[4]:-}
|
|
|
|
[[ -n $ssid ]] || { echo "Could not read the Wi-Fi name" >&2; exit 1; }
|
|
[[ $key_management != *eap* && $key_management != *ieee8021x* ]] || {
|
|
echo "Enterprise Wi-Fi cannot be shared with a password QR code" >&2
|
|
exit 1
|
|
}
|
|
|
|
escape_wifi_qr() {
|
|
local value=$1
|
|
value=${value//\\/\\\\}
|
|
value=${value//;/\\;}
|
|
value=${value//,/\\,}
|
|
value=${value//:/\\:}
|
|
printf '%s' "$value"
|
|
}
|
|
|
|
if [[ -n $key_management && $key_management != "none" ]]; then
|
|
[[ -n $password ]] || { echo "Could not read the Wi-Fi password" >&2; exit 1; }
|
|
security=WPA
|
|
elif [[ -n $wep_key ]]; then
|
|
# NetworkManager models WEP as key-mgmt "none" plus a wep-key; encoding it
|
|
# as an open network would produce a QR that silently fails to join.
|
|
password=$wep_key
|
|
security=WEP
|
|
else
|
|
security=nopass
|
|
fi
|
|
|
|
payload="WIFI:T:$security;S:$(escape_wifi_qr "$ssid");P:$(escape_wifi_qr "$password");"
|
|
[[ $hidden == "yes" ]] && payload+="H:true;"
|
|
payload+=";"
|
|
|
|
# ASCII uses two characters per module. Collapse each pair to one 0/1 value
|
|
# so the shell can render a square matrix directly with native QML rectangles.
|
|
# Margin 4 is the spec quiet zone; the card surround is dark, so this white
|
|
# border is all the scanner gets.
|
|
ascii=$(printf '%s' "$payload" | qrencode --type ASCII --margin 4 --output -)
|
|
while IFS= read -r line; do
|
|
row=
|
|
for ((column = 0; column < ${#line}; column += 2)); do
|
|
[[ ${line:column:2} == *#* ]] && row+=1 || row+=0
|
|
done
|
|
printf '%s\n' "$row"
|
|
done <<<"$ascii"
|