Skip to content

Instantly share code, notes, and snippets.

@rasmusmerzin
Created December 26, 2025 00:30
Show Gist options
  • Select an option

  • Save rasmusmerzin/626289b80effc83921ad9c45b9a5b087 to your computer and use it in GitHub Desktop.

Select an option

Save rasmusmerzin/626289b80effc83921ad9c45b9a5b087 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -euo pipefail
main() {
install_deps
write_config
reload_wlmod
connect_wifi
echo SUCCESS
}
detect_firmware() {
if dmesg | grep -qi b43legacy; then echo b43legacy-firmwareAUR
elif dmesg | grep -qi b43; then echo b43-firmwareAUR
else echo broadcom-wl-dkms
fi
}
install_yay() {
git clone https://aur.archlinux.org/yay.git /tmp/yay
cd /tmp/yay && makepkg -si --noconfirm
alias pacman=yay
}
install_deps() {
firmware_pkg=$(detect_firmware)
pacman -Sy --noconfirm base-devel linux-headers wpa_supplicant dhcpcd git
[[ $firmware_pkg != *AUR* ]] || install_yay
pacman -S --noconfirm $firmware_pkg
}
write_config() {
printf %s\\n blacklist\ {b43,b43legacy,bcma,brcmsmac,ssb} > /etc/modprobe.d/blackcom-wifi.conf
}
reload_wlmod() {
modprobe -r wl || true
if [[ $firmware_pkg == 43* ]]; then modprobe b43
else modprobe wl
fi
}
setup_dhcpd() {
iface=$(iw dev | awk '$1=="Interface"{print $2}' | head -1)
[[ -n "$iface" ]] && dhcpcd "$iface"
}
connect_wifi() {
read -p "SSID: " ssid; read -sp "Password: " pass; echo
wpa_supplicant -Bi"$iface" -c<(wpa_passphrase "$ssid" "$pass")
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment