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

Questions about Wi-Fi and other network devices, file sharing, firewalls, connection sharing etc
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
yobro

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

Post by yobro »

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: 229
Joined: Mon Dec 04, 2017 2:56 am
Contact:

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

Post by orschiro »

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

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

Post by yobro »

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: 229
Joined: Mon Dec 04, 2017 2:56 am
Contact:

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

Post by orschiro »

Glad I could help. :-)
User avatar
karlchen
Level 23
Level 23
Posts: 18225
Joined: Sat Dec 31, 2011 7:21 am
Location: Germany

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

Post by karlchen »

<mod> sugata's post can be found here: viewtopic.php?f=53&t=319067 </mod>
Image
The people of Alderaan have been bravely fighting back the clone warriors sent out by the unscrupulous Sith Lord Palpatine for 792 days now.
Lifeline
Locked

Return to “Networking”