A little wireless trick

My media center PC has a wireless network adapter and of cause a BIG blue light on the front of the PC.

As wireless network connection and a media center (with slow CPU) streaming movies is not a good combination I wanted to disable the wireless card.

To do that I used the command ifconfig.

First type:

$> ifconfig -a
eth0      Link encap:Ethernet  HWaddr 00:01:02:03:04:05:06 
          inet addr:192.168.0.153  Bcast:10.25.1.255  Mask:255.255.255.0
          inet6 addr: fe80::201:2eff:fe3b:c50f/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:154476 errors:0 dropped:0 overruns:0 frame:0
          TX packets:77817 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:168840925 (168.8 MB)  TX bytes:5938729 (5.9 MB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:376 errors:0 dropped:0 overruns:0 frame:0
          TX packets:376 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:45071 (45.0 KB)  TX bytes:45071 (45.0 KB)

wlan0     Link encap:Wireless  HWaddr 00:01:02:03:04:05:07
          inet addr:192.168.0.153  Bcast:10.25.1.255  Mask:255.255.255.0
          inet6 addr: fe80::201:2eff:fe3b:c60f/64 Scope:Link
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

As you can see from the output I have 3 network adapters: eth0, lo, wlan0.
You might get other output, like eth1, lo, wlan0 etc.

I want to disable the wireless adapter: wlan0

At the command line I type:

$> sudo ifconfig wlan0 down
[sudo] password for gopher:

Then the wireless adapter is disabled and the stupid blue light is gone!

To enable the wireless adapter again type:

$> sudo ifconfig wlan0 up
[sudo] password for gopher:

Then the wireless adapter is enabled and the stupid blue light is on again!

To have the wireless adapter disabled every time the media center start add the command to the end of the file /etc/rc.local (before the exit 0).
Use a editor like nano or kate etc. to change the file.

$> sudo nano /etc/rc.local
!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

ifconfig wlan0 down

exit 0

Now I just found that out after a suspend the wireless network adapter was enabled again.

To solve it I have to disable the wlan0 adapter during the resume. Create a file called /etc/pm/sleep.d/20_custom_wlan0

$> sudo nano /etc/pm/sleep.d/20_custom_wlan0

Add the following to the file:

# Script to disable wlan0 before suspend and restart after wake.
case "${1}" in
        suspend|hibernate)
                echo suspending 20_custom-wlan0
                ;;
        resume|thaw)
               echo Resumeing 20_custom-wlan0 - shutting down wlan0
               ifconfig wlan0 down
               ;;
esac

Save the files and make sure is executable:

$> sudo chmod 755 /etc/pm/sleep.d/20_custom-wlan0

The file is named 20<something> because I want the file to called a relative late in resume process. On my system there is a file called 60<something> which enable the wireless network adapter and I want to disable it again.

To see the scripts called during the suspend process go through the log file:

/var/log/pm-suspend.log

Thats it, good luck 🙂

 

Leave a Reply