I have been searching through the forums for a general solution to this problem for 18.04 (such as this one or this one).
The first example was originally posted for 14.04 and tells me to add a script to the /etc/pm/sleep.d. I tried two different scripts:
#!/bin/bash
case "$1" in
thaw|resume)
sudo nmcli nm sleep false
sudo pkill -f wpa_supplicant
;;
*)
;;
esac
exit $?
and
#!/bin/sh
case "${1}" in
resume|thaw)
nmcli r wifi off && nmcli r wifi on ;;
esac
but neither of them worked. I'm not proficient enough in Linux to understand exactly what the scripts are doing but I do get that this should run when resuming from suspend (I did make it executable using sudo chmod +x). In fact just running
nmcli nm sleep false
in a terminal gave me "Error: argument 'nm' not understood"
An answer on this post says that sleep.d is no longer active as of 16.04 and that the script should be put in /lib/systemd/systemd-sleep.
The second post seems to be specific to Lenovo laptops as it says to run:
sudo tee /etc/modprobe.d/blacklist-ideapad.conf <<< "blacklist ideapad_laptop"
but I have an HP Pavilion with an Intel Corporation Wireless 3160[8086:08b3] rev (83), as per lspci | grep Network, and there is no "blacklist-ideapad.conf" file in /etc/modprobe.d
There is no hard switch on my laptop for the Wifi adapter so I was hoping someone could help me tweak these answers for my situation. How would I add a similar script to the systemd-sleep since its not a folder or script (that I can read anyway)?
EDIT Based on @nobody's solution here is what my iwlwifi.conf file looks like:
# /etc/modprobe.d/iwlwifi.conf
# iwlwifi will dyamically load either iwldvm or iwlmvm depending on the
# microcode file installed on the system. When removing iwlwifi, first
# remove the iwl?vm module and then iwlwifi.
remove iwlwifi \
(/sbin/lsmod | grep -o -e ^iwlmvm -e ^iwldvm -e ^iwlwifi | xargs /sbin/rmmod) \
&& /sbin/modprobe -r mac80211
options iwlwifi remove_when_gone=1
Perhaps I didn't add the "options iwlwifi..." line properly?
Thanks for the help! Jeremy
sudo touch /etc/modprobe.d/iwlwifi.conf
– JJGabe Sep 16 '19 at 14:35