feat(dbus): Add Wi-Fi configuration support to the system config
Introduces the `configure_wifi` function to handle Wi-Fi actions such as enabling, disabling, and checking status. Updates the `ieee80211` feature to use the new function, integrating Wi-Fi management into the existing configuration framework.
This commit is contained in:
@@ -314,6 +314,34 @@ def configure_gui(action: ConfigActions):
|
||||
raise ValueError(f"action {action} not supported")
|
||||
|
||||
|
||||
def configure_wifi(action: ConfigActions):
|
||||
revpi = RevPiConfig()
|
||||
|
||||
if action is ConfigActions.ENABLE:
|
||||
if revpi.rfkill_index is not None:
|
||||
subprocess.call(["rfkill", "unblock", str(revpi.rfkill_index)])
|
||||
|
||||
elif action is ConfigActions.DISABLE:
|
||||
if revpi.rfkill_index is not None:
|
||||
subprocess.call(["rfkill", "block", str(revpi.rfkill_index)])
|
||||
|
||||
elif action is ConfigActions.AVAILABLE:
|
||||
return revpi.with_wifi and revpi.rfkill_index is not None
|
||||
|
||||
elif action is ConfigActions.STATUS:
|
||||
if revpi.rfkill_index is None:
|
||||
return False
|
||||
|
||||
with open(f"/sys/class/rfkill/rfkill{revpi.rfkill_index}/soft", "r") as f:
|
||||
buffer = f.read().strip()
|
||||
return buffer == "0"
|
||||
|
||||
else:
|
||||
raise ValueError(f"action {action} not supported")
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def simple_systemd(action: ConfigActions, unit: str):
|
||||
bus = SystemBus()
|
||||
systemd_manager = bus.get(".systemd1")
|
||||
|
||||
Reference in New Issue
Block a user