Wifi not connecting after suspend fix
  • pemartinspemartins
    PMPosts: 91
    If, like me, someone else has the problem of wifi not connection after suspending the pc, here's the fix.

    This was found at http://askubuntu.com/questions/761180
    If you get the page not found error, just get a cached version of the page http://webcache.googleusercontent.com/search?q=cache:http://askubuntu.com/questions/761180
    This is the solution that works all the time in my LXLE 16.04.1. I'll paste the entire post.

      16.04 runs on systemd. Try the following:
    sudo systemctl restart network-manager.service

    If this works, you can create a script to automate it.

    Open a terminal and type the following:
    sudo nano /etc/systemd/system/wifi-resume.service 

    Now paste the script in there with a right click:

    Script:

    #/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=/bin/systemctl restart network-manager.service

    [Install]
    WantedBy=suspend.target
    WantedBy=hibernate.target
    WantedBy=hybrid-sleep.target 
    Exit with CTRL + X and press Y to save. 


    Now to activate it: 
    sudo systemctl enable wifi-resume.service

    Hope this helps. It works on my laptop.

    -//-

    Here are previous solutions I tried.

    Type this on the terminal:
    sudo touch /etc/pm/sleep.d/wakenet.sh
    sudo chmod +x /etc/pm/sleep.d/wakenet.sh
    sudo pluma /etc/pm/sleep.d/wakenet.sh

    and then enter the following in the created and open file:
    #!/bin/bash
    case "$1" in
    thaw|resume)
    nmcli nm sleep false
    ;;
    *)
    ;;
    esac
    exit $?

    Now save it and that's it, give it a try to check if the issue is solved.

    If it did not work, just restart the network manager by typing in the terminal:
    sudo service network-manager restart

    And if all the above did not work, you gotta logout and login again and that will work for sure.
  • Where is the suspend configuration file located? I'd like to make a couple of changes on it, just to make some adjustments to better suit my personal needs.
  • lxlelxle
    PMPosts: 2,656
    check the help file in the accessories menu
    Thanked by 1pemartins
  • LXLE Help? When I click on it I only get this error message:
    Invalid desktop entry file: '/usr/share/applications/help.desktop'
  • lxlelxle
    PMPosts: 2,656
    did you remove seamonkey? if so, it takes you to the lxle wiki page...

    http://wiki.lxle.net
    Thanked by 1pemartins
  • Thank you for the info, I did remove seamonkey.

    I checked LXLE's wiki page and as I type "suspend" on the search box, it finds nothing. Also tried other terms with no luck, the better I got was with "power management" but still nothing I could use came out of it.
  • lxlelxle
    PMPosts: 2,656
    Thanked by 1pemartins
  • I'm sorry but I'm still not getting there, the only thing I could find that could be related was the tlp config file which I checked from top to bottom and couldn't find it there.
    I couldn't find how to customize the suspend behavior, how to change things like stopping the lock screen from appearing, not turning of network connections and stuff like that...
  • But do not worry about that, I just found a workaround to make what I wanted so there's no need any more for me to edit that file.

    Once again thank you very much for all your help.
  • lxlelxle
    PMPosts: 2,656
    I think you might be getting 'suspend' confused with the screenlocker
    Thanked by 1pemartins
  • Maybe, I'm not sure, I wanted to remove the screen lock after the pc resumes from the suspend state but I was able to do it with the script I posted yesterday in the first post (I edited it) of this thread; it also makes the wifi restart every time the pc resumes so the wifi issue on resume of ubuntu 16.04 also gets solved. So what matters is that it's done.