initial commit
This commit is contained in:
commit
21d8054894
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
*~
|
||||
.DS_Store
|
||||
*.pkg.tar.zst
|
||||
*.pkg.tar.zst.sig
|
20
PKGBUILD
Normal file
20
PKGBUILD
Normal file
@ -0,0 +1,20 @@
|
||||
# Maintainer: Sebastian Hugentobler <shu@vanwa.ch>
|
||||
|
||||
pkgname=wifi-connect
|
||||
pkgver=0.1.0
|
||||
pkgrel=1
|
||||
pkgdesc="Connect to a wifi network with nmcli, getting the password from pass."
|
||||
arch=("any")
|
||||
url="https://code.vanwa.ch"
|
||||
license=('MIT')
|
||||
depends=("networkmanager" "pass")
|
||||
source=(
|
||||
"wifi-connect"
|
||||
)
|
||||
sha256sums=("e6709ad775505b9485243d32f2e440a5cc0e96a875174cd8438024b4e0d5bcf2")
|
||||
|
||||
package() {
|
||||
cd "$srcdir/"
|
||||
|
||||
install -Dm 755 wifi-connect "$pkgdir/usr/bin/wifi-connect"
|
||||
}
|
46
wifi-connect
Executable file
46
wifi-connect
Executable file
@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env sh
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
|
||||
ssid=""
|
||||
|
||||
display_help() {
|
||||
echo "Usage: $0 [option...] " >&2
|
||||
echo
|
||||
echo " -s, ssid of the wifi network, \"wifi/\$ssid\" is used as the path for pass."
|
||||
echo " -h, display this help and exit"
|
||||
echo
|
||||
}
|
||||
|
||||
parse_args() {
|
||||
while getopts ":hs:" opt; do
|
||||
case $opt in
|
||||
h)
|
||||
display_help
|
||||
exit 0
|
||||
;;
|
||||
s)
|
||||
ssid=$OPTARG
|
||||
;;
|
||||
\?)
|
||||
echo "Invalid option: -$OPTARG" >&2
|
||||
display_help
|
||||
exit 1
|
||||
;;
|
||||
:)
|
||||
echo "Option -$OPTARG requires an argument." >&2
|
||||
display_help
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
parse_args "$@"
|
||||
|
||||
echo "getting wifi password..."
|
||||
pw="$(pass wifi/"$ssid")"
|
||||
|
||||
nmcli device wifi list
|
||||
nmcli con delete "$ssid" >/dev/null 2>&1 || true
|
||||
nmcli device wifi connect "$ssid" password "$pw"
|
Loading…
Reference in New Issue
Block a user