mirror of
https://github.com/KDE/kde-linux.git
synced 2026-05-24 16:30:18 -04:00
Automatically set the wireless regulatory domain
Automatically sets the wireless regulatory domain when a wireless device is connected, or on timezone change. Resolves #464
This commit is contained in:
committed by
Nate Graham
parent
60b0d5453d
commit
8cc8ad3989
5
LICENSES/ISC.txt
Normal file
5
LICENSES/ISC.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
<copyright notice>
|
||||
|
||||
Permission to use, copy, modify, and /or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
83
mkosi.extra/usr/lib/iw-set-regdomain
Executable file
83
mkosi.extra/usr/lib/iw-set-regdomain
Executable file
@@ -0,0 +1,83 @@
|
||||
#!/bin/sh
|
||||
|
||||
# SPDX-License-Identifier: ISC
|
||||
# SPDX-FileCopyrightText: 2025 Thomas Duckworth <tduck@filotimoproject.org>
|
||||
# SPDX-FileCopyrightText: 2009-2014 Red Hat, Inc.
|
||||
# SPDX-FileCopyrightText: 2025 Velocity Limitless, LLC.
|
||||
|
||||
# See https://gitlab.com/VelocityLimitless/Projects/iw-setregdomain
|
||||
|
||||
# Copyright 2009-2014 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# Permission to use, copy, modify, and/or distribute this software for any
|
||||
# purpose with or without fee is hereby granted, provided that the above
|
||||
# copyright notice and this permission notice appear in all copies.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
#
|
||||
|
||||
REGDOMAIN=/etc/iw-regdomain
|
||||
LOCALTIME=/etc/localtime
|
||||
|
||||
LOGGER="/usr/bin/logger -t iw-set-regdomain"
|
||||
|
||||
getcountry() {
|
||||
while read c a z r
|
||||
do
|
||||
if [ "$z" = "$ZONE" ]
|
||||
then
|
||||
echo $c
|
||||
break
|
||||
fi
|
||||
done < /usr/share/zoneinfo/zone.tab
|
||||
}
|
||||
|
||||
if [ -f $REGDOMAIN ]
|
||||
then
|
||||
# This should set COUNTRY
|
||||
. $REGDOMAIN
|
||||
if [ -n "$COUNTRY" ]
|
||||
then
|
||||
/usr/bin/iw reg set $COUNTRY
|
||||
exit
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -f "$LOCALTIME" ]
|
||||
then
|
||||
ZONE=$(readlink -f $LOCALTIME)
|
||||
ZONE=${ZONE#/usr/share/zoneinfo/}
|
||||
else
|
||||
$LOGGER -s "Timezone information not found. Unable to set wireless regulatory domain."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$ZONE" -o "$ZONE" = "$LOCALTIME" ]
|
||||
then
|
||||
$LOGGER -s "Could not determine timezone. Unable to set wireless regulatory domain."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
COUNTRY=$(getcountry)
|
||||
|
||||
if [ -z "$COUNTRY" ]
|
||||
then
|
||||
case "$ZONE" in
|
||||
UTC|UCT|Universal|Zulu|GMT|Etc/UTC|Etc/UCT|Etc/Universal|Etc/Zulu|Etc/GMT)
|
||||
$LOGGER "Timezone is $ZONE, with no associated country. Not setting wireless regulatory domain."
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
$LOGGER -s "Could not determine country for $ZONE. Unable to set wireless regulatory domain."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
$LOGGER "Setting regulatory domain to $COUNTRY based on timezone ($ZONE)."
|
||||
/usr/bin/iw reg set $COUNTRY
|
||||
@@ -43,6 +43,7 @@ enable switcheroo-control.service
|
||||
enable kde-linux-bootloader-visibility.service
|
||||
enable kde-linux-btrfs.service
|
||||
enable kde-linux-configure-firefox.path
|
||||
enable kde-linux-iw-set-regdomain.path
|
||||
enable kde-linux-live-setup.service
|
||||
enable kde-linux-powertop.service
|
||||
enable kde-linux-volatile-var-lib-flatpak.service
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
||||
# SPDX-FileCopyrightText: 2025 Thomas Duckworth <tduck@filotimoproject.org>
|
||||
|
||||
[Unit]
|
||||
Description=Monitor Timezone Changes to Set Wireless Regulatory Domain
|
||||
|
||||
[Path]
|
||||
PathChanged=/etc/localtime
|
||||
Unit=kde-linux-iw-set-regdomain.service
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -0,0 +1,9 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
||||
# SPDX-FileCopyrightText: 2025 Thomas Duckworth <tduck@filotimoproject.org>
|
||||
|
||||
[Unit]
|
||||
Description=Set Wireless Regulatory Domain on Timezone Change
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/lib/iw-set-regdomain
|
||||
9
mkosi.extra/usr/lib/udev/rules.d/85-iw-regulatory.rules
Normal file
9
mkosi.extra/usr/lib/udev/rules.d/85-iw-regulatory.rules
Normal file
@@ -0,0 +1,9 @@
|
||||
# SPDX-License-Identifier: ISC
|
||||
# SPDX-FileCopyrightText: 2025 Thomas Duckworth <tduck@filotimoproject.org>
|
||||
# SPDX-FileCopyrightText: 2009-2014 Red Hat, Inc.
|
||||
# SPDX-FileCopyrightText: 2025 Velocity Limitless, LLC.
|
||||
|
||||
# Set wireless regulatory domain at device creation
|
||||
# For more information see https://gitlab.com/VelocityLimitless/Projects/iw-setregdomain
|
||||
|
||||
SUBSYSTEM=="ieee80211", ACTION=="add", RUN+="/usr/lib/iw-set-regdomain"
|
||||
Reference in New Issue
Block a user