Turn off Wireless power management permanently in Ubuntu 22.04

sudo nano /etc/NetworkManager/conf.d/default-wifi-powersave-on.conf

And change wifi.powersave to 2

or

sudo sed -i 's/3/2/' /etc/NetworkManager/conf.d/*

Possible values for the wifi.powersave field are:

NM_SETTING_WIRELESS_POWERSAVE_DEFAULT (0): use the default value
NM_SETTING_WIRELESS_POWERSAVE_IGNORE  (1): don't touch existing setting
NM_SETTING_WIRELESS_POWERSAVE_DISABLE (2): disable powersave
NM_SETTING_WIRELESS_POWERSAVE_ENABLE  (3): enable powersave

References
https://askubuntu.com/questions/1403773/22-04-wifi-keeps-disconnecting-for-a-few-seconds-frequently
https://unix.stackexchange.com/questions/269661/how-to-turn-off-wireless-power-management-permanently