Fix Wifi not working after Suspend [#ubuntu]

After installing Ubunutu on my new Xiaomi Book Air 12 I hit a new bug in network-manager in ubuntu which cause the fail off wifi connection after resume from suspend because the network-manager still sleep :)

It’s a long stand bug affected many brands in Linux to have a workaround just follow these simple steps.

1- Copy and paste in terminal:

sudo gedit /etc/systemd/system/wifi-resume.service

2- Copy this code and paste it in the file you opened:

#/etc/systemd/system/wifi-resume.service
#sudo systemctl enable wifi-resume.service
[Unit]
Description=Restart networkmanager at resume
After=suspend.target
After=hibernate.target
After=hybrid-sleep.target
[Service]
Type=oneshot
ExecStart=wpa_cli resume
ExecStart=/bin/systemctl restart NetworkManager.service
[Install]
WantedBy=suspend.target
WantedBy=hibernate.target
WantedBy=hybrid-sleep.target

3- Run this command in the terminal:

sudo systemctl enable wifi-resume.service

NOTE:

after applying these settings the wifi will be connected automatically after the resume but the network manager icon will still be not active and not showing any wifi or network.

#ref: