[SOLVED] Automatically turn off wifi before and back on after suspend

Questions about WIFI networks and devices
Forum rules
Before you post please read how to get help
Post Reply
yobro
Level 1
Level 1
Posts: 8
Joined: Mon Jan 08, 2018 1:11 pm

[SOLVED] Automatically turn off wifi before and back on after suspend

Post by yobro » Mon Jan 08, 2018 1:25 pm

Hello!

My network adapter is preventing my system to suspend to RAM in kernels higher than 4.8. I want to upgrade to 18.3 and am therefore looking for a workaround to suspend via command line. If I manually turn wifi off, the system suspends nicely.

I had something like this in mind:

Code: Select all

nmcli radio wifi off ; systemctl suspend ; nmcli radio wifi on
But the last command is executed before the system is suspended.

Does anyone have an idea?


After intensive research I gave up on how to get my network adapter working properly under kernels higher than 4.8. It is working, but still preventing the suspend
The output of

Code: Select all

lspci -nn
is:

Code: Select all

03:00.0 Network controller [0280]: Qualcomm Atheros QCA6174 802.11ac Wireless Network Adapter [168c:003e] (rev 20)
Last edited by yobro on Tue Jan 09, 2018 8:27 am, edited 1 time in total.

orschiro
Level 4
Level 4
Posts: 230
Joined: Mon Dec 04, 2017 2:56 am
Contact:

Re: Automatically turn off wifi before and back on after suspend

Post by orschiro » Tue Jan 09, 2018 1:54 am

But the last command is executed before the system is suspended.
You mean, WiFi is turned back on before the system had even suspended? Can you add a wait delay to this command sequence, in this case?

yobro
Level 1
Level 1
Posts: 8
Joined: Mon Jan 08, 2018 1:11 pm

Re: Automatically turn off wifi before and back on after suspend

Post by yobro » Tue Jan 09, 2018 8:26 am

orschiro wrote:
But the last command is executed before the system is suspended.
You mean, WiFi is turned back on before the system had even suspended? Can you add a wait delay to this command sequence, in this case?
Thanks for your reply!

Yes, it works, if you couple two delays:

Code: Select all

nmcli radio wifi off ; systemctl suspend ; sleep 15; sleep 2; nmcli radio wifi on
The first is necessary to wait for the system to suspend, the second to wait before turning wifi back on after waking up, because the command has no effect if executed directly after waking up.

It's not a clean solution with the absolute values for the delay, because depending on the state of the system the suspend takes different amounts of time. But I believe it will suffice until I replace my wifi module (it creates way too much trouble with both linux and windows).

Thanks, orschiro!

orschiro
Level 4
Level 4
Posts: 230
Joined: Mon Dec 04, 2017 2:56 am
Contact:

Re: [SOLVED] Automatically turn off wifi before and back on after suspend

Post by orschiro » Tue Jan 09, 2018 8:29 am

Glad I could help. :-)

Post Reply

Return to “Wireless”