From e79cfa76a8b77c9882e6b64a3c4d6039ba05d7e3 Mon Sep 17 00:00:00 2001 From: Nirav Patel <28994301+eclecticc@users.noreply.github.com> Date: Tue, 9 Sep 2025 11:13:14 -0700 Subject: [PATCH] Include wireless-regdb to resolve #1083 (#1279) * Add wireless-regdb alongside iwd Needed for regulatory compliance for Wi-Fi and enabling some bands on some chipsets * Add wireless-regdb * Changed location of wireless-regdb install * configure the wireless-regdom during install * remove extra newline * don't unset the variable too early * also set the region as part of the script * writing to wireless-regdom requires root * need to use tee * changing logic since this is brought in as source * handle timezones that start with country code already --------- Co-authored-by: Nirav Patel --- install.sh | 1 + .../config/hardware/set-wireless-regdom.sh | 36 +++++++++++++++++++ install/packages.sh | 1 + 3 files changed, 38 insertions(+) create mode 100755 install/config/hardware/set-wireless-regdom.sh diff --git a/install.sh b/install.sh index 8dd39a3e..3e86f2ef 100755 --- a/install.sh +++ b/install.sh @@ -41,6 +41,7 @@ source $OMARCHY_INSTALL/config/mimetypes.sh source $OMARCHY_INSTALL/config/localdb.sh source $OMARCHY_INSTALL/config/sudoless-asdcontrol.sh source $OMARCHY_INSTALL/config/hardware/network.sh +source $OMARCHY_INSTALL/config/hardware/set-wireless-regdom.sh source $OMARCHY_INSTALL/config/hardware/fix-fkeys.sh source $OMARCHY_INSTALL/config/hardware/bluetooth.sh source $OMARCHY_INSTALL/config/hardware/printer.sh diff --git a/install/config/hardware/set-wireless-regdom.sh b/install/config/hardware/set-wireless-regdom.sh new file mode 100755 index 00000000..d4a93629 --- /dev/null +++ b/install/config/hardware/set-wireless-regdom.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +# First check that wireless-regdb is there +if [ -f "/etc/conf.d/wireless-regdom" ]; then + unset WIRELESS_REGDOM + . /etc/conf.d/wireless-regdom +fi + +# If the region is already set, we're done +if [ ! -n "${WIRELESS_REGDOM}" ]; then + # Get the current timezone + if [ -e "/etc/localtime" ]; then + TIMEZONE=$(readlink -f /etc/localtime) + TIMEZONE=${TIMEZONE#/usr/share/zoneinfo/} + + # Some timezones are formatted with the two letter country code at the start + COUNTRY="${TIMEZONE%%/*}" + + # If we don't have a two letter country, get it from the timezone table + if [[ ! "$COUNTRY" =~ ^[A-Z]{2}$ ]] && [ -f "/usr/share/zoneinfo/zone.tab" ]; then + COUNTRY=$(awk -v tz="$TIMEZONE" '$3 == tz {print $1; exit}' /usr/share/zoneinfo/zone.tab) + fi + + # Check if we have a two letter country code + if [[ "$COUNTRY" =~ ^[A-Z]{2}$ ]]; then + # Append it to the wireless-regdom conf file that is used at boot + echo "WIRELESS_REGDOM=\"$COUNTRY\"" | sudo tee -a /etc/conf.d/wireless-regdom > /dev/null + + # Also set it one off now + if command -v iw &> /dev/null; then + sudo iw reg set ${COUNTRY} + fi + fi + fi +fi + diff --git a/install/packages.sh b/install/packages.sh index ca9621ac..e1fd977f 100644 --- a/install/packages.sh +++ b/install/packages.sh @@ -114,6 +114,7 @@ sudo pacman -S --noconfirm --needed \ waybar \ wf-recorder \ whois \ + wireless-regdb \ wiremix \ wireplumber \ wl-clip-persist \