Skip to content

Commit

Permalink
Update 'iwd'.md
Browse files Browse the repository at this point in the history
  • Loading branch information
rern authored Feb 4, 2024
1 parent 12b610d commit 7a6fd22
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions 'iwd'.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,31 @@ iwctl station $DEVICE get-networks
iwctl station $DEVICE [connect|connect-hidden] $SSID --passphrase $PASSPHRASE

# #2 - connect with pre-configured profile
if [[ $SSID =~ [^a-zA-Z0-9\ _-] ]]; then # if $SSID contains special charaters
HEX_ENCODE=$( echo -n "$SSID" | od -A n -t x1 | tr -d ' ' )
PROFILE=/var/lib/iwd/=$HEX_ENCODE.psk
else
PROFILE=/var/lib/iwd/$SSID.psk # .open if no passphrase
fi
# required - both or omit both if no passphrase
# PRESHAREDKEY=$( wpa_passphrase "$ssid" "$passphrase" | grep '\spsk=' | cut -d= -f2 )
PRESHAREDKEY=$( wpa_passphrase "$ssid" "$passphrase" | grep '\spsk=' | cut -d= -f2 )
data="\
[Security]
PreSharedKey=$PRESHAREDKEY
Passphrase=$PASSPHRASE

"
# static ip - optional
data+=
[IPv4]
Address=$ADDRESS
Gateway=$GATEWAY

"
# hidden ssid - optional
data+="
[Settings]
Hidden=true

echo "$data" >> /var/lib/iwd/$SSID.psk # .open if no passphrase

# if $SSID contains special charaters - filename: /var/liv/iwd/=HEX_ENCODE.EXT
[[ $SSID =~ [^a-zA-Z0-9\ _-] ]] && HEX_ENCODE==$( echo -n "$SSID" | od -A n -t x1 | tr -d ' ' )
"
echo "$data" >> "$PROFILE"
# show current connection status
iwctl station $DEVICE show
Expand Down

0 comments on commit 7a6fd22

Please sign in to comment.