@@ -394,3 +394,54 @@ configure-boot-to-windows:
394394 mkdir -p $HOME/.local/share/applications
395395 cp -r /usr/share/applications/boot-to-windows.desktop $HOME/.local/share/applications
396396 sed -i 's/Hidden=true/Hidden=false/' $HOME/.local/share/applications/boot-to-windows.desktop
397+
398+ # Toggle IWD
399+ [group('System')]
400+ toggle-iwd :
401+ # !/usr/bin/bash
402+ echo -e "This script manages enabling or disabling iwd as a replacement for wpa_supplicant for Wi-Fi networking."
403+ echo -e "Enabling this can improve throughput, mesh networking, and reduce latency increases when scanning for networks"
404+ echo -e "Disabling this can improve corporate or eduroam network compatibility"
405+ echo -e ""
406+ echo -e "WARNING : Changing this will remove all saved wifi networks"
407+ get_current_status() {
408+ if [[ -f "/etc/NetworkManager/conf.d/iwd.conf" ]]; then
409+ echo "Enabled"
410+ else
411+ echo "Disabled"
412+ fi
413+ }
414+ remove_saved_networks() {
415+ nmcli -t -f NAME connection show | while read -r line; do sudo nmcli connection delete "$line"; done
416+ }
417+ enable_iwd() {
418+ sudo mkdir -p "/etc/NetworkManager/conf.d/"
419+ sudo rm -f "/etc/NetworkManager/conf.d/iwd.conf"
420+ printf "[device]\nwifi.backend=iwd" | sudo tee /etc/NetworkManager/conf.d/iwd.conf > /dev/null
421+ remove_saved_networks
422+ echo -e "iwd enabled. Reboot required to apply changes."
423+ }
424+ disable_iwd() {
425+ sudo rm -f "/etc/NetworkManager/conf.d/iwd.conf"
426+ remove_saved_networks
427+ echo -e "iwd disabled. Reboot required to apply changes."
428+ }
429+ # Display current status
430+ current_status =$(get_current_status )
431+ echo -e "\nCurrent iwd status : $current_status\n"
432+ # Prompt user for action
433+ CHOICE =$(ugum choose "Enable iwd" "Disable iwd" "Exit without changes" )
434+ case "$CHOICE" in
435+ "Enable iwd")
436+ enable_iwd
437+ ;;
438+ "Disable iwd")
439+ disable_iwd
440+ ;;
441+ "Exit without changes")
442+ echo "No changes made."
443+ ;;
444+ *)
445+ echo "Invalid choice. Exiting without changes."
446+ ;;
447+ esac
0 commit comments