The Problem
Hi all,
I recently fixed an annoying problem and I thought it would be nice to share my solution here. The problem was that after a cycle of suspend/resume, Network Manager would only auto-connect to the same network as it was previously connected to. So, for example, if I suspended my laptop at home, and then I went to school and resumed it, it would try to connect to the home network, and then just give up. It would not connect to the school network unless I explicitly told it to.
The Solution
First, I'll describe the fix. If you're having this problem, you can this. Copy the following:
Create the file /etc/pm/sleep.d/10_restart-networkmanager and paste the above code into it. Make sure it is owned by root (the administrator) and is marked as executable. That's all. Now, try suspending your computer and then taking it away from your current wireless network to another one that it should auto-connect to. See if it works.Code:#!/bin/sh case "$1" in resume|thaw) pkill NetworkManager ;; suspend|hibernate) # Do nothing ;; esac
If this doesn't work for you and you want to undo the changes you have made, simply delete the file /etc/pm/sleep.d/10_restart-networkmanager.
How the solution works
Any executable script in the directory /etc/pm/sleep.d/ will be run on both suspend and resume. The script is told which action is currently happening. This particular script will only do something when the computer is resuming. When the computer resumes, it will run this script, which will kill Network Manager, causing it to forget what network it was previously connected to. However, it doesn't stay dead. Some part of the operating system is monitoring Network Manager and will respawn it after it is killed. It will then connect to the most appropriate network, free of any previous bias.
Why the problem exists in the first place
In my case, I happen to know that the reason for my problem has to do with a problem in the Broadcom wireless drivers. The drivers don't support suspend in quite the correct way, so Network Manager thinks that it has last its connection unexpectedly, so it tries to reconnect.
Hope this helps people.
Edit: For Lucid, the following should work:
Code:#!/bin/sh case "$1" in resume|thaw) service network-manager restart ;; suspend|hibernate) # Do nothing ;; esac
Bookmarks