LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   WiCD: How to toggle WiFi on and off? (https://www.linuxquestions.org/questions/linux-networking-3/wicd-how-to-toggle-wifi-on-and-off-4175475544/)

displace 09-02-2013 05:18 AM

WiCD: How to toggle WiFi on and off?
 
I'm setting up a headless device (has console access only) that has ethernet and wireless connectivity. I'm using wicd to manage the connections. The ethernet port is configured via Wicd to use DHCP. The WiFi can also be managed by wicd to connect to (an) access point(s).

However the wireless device will sometimes be used for other things (i.e. hostap), and during this time I'd like wicd to leave the wlan0 device alone, but still handle the ethernet dhcp. It shouldn't even scan or probe any networks. In fact it should leave the wifi completely alone - as if the device doesn't exist.

I've googled for wicd, but I couldn't come up with a proper answer. Is there a way to toggle wicd WiFi management on and off while leaving ethernet enabled? The only idea I got was to edit the wicd management config file and remove out the line where the wifi device is specified, and restart wicd.

Is there an easier way? Some gui backends offer a checkbox to enable/disable wifi.


Best regards!
~dis

frankbell 09-02-2013 07:40 PM

Wicd does have a switch-off wifi button in the GUI version of wicd-client.

Since this is headless, I suspect you will be using the ncurses wicd interface, wicd-curses. I looked about, but was unable to find a turn WiFi on/off toggle there, but I might have just overlooked it.

The Arch wiki article might help: https://wiki.archlinux.org/index.php/Wicd There might be a way to do it with scripts.

displace 09-03-2013 12:46 AM

I have managed to source-dive the wicd-daemon, python-wicd and wicd-gtk python scripts, and I've tracked down what the Enable/Disable WiFi button does. It simply invokes the following commands for wifi:

# rfkill block wifi
# rfkill unblock wifi

This does not tell the wicd not to use the wifi card, it simply sets the rfkill block. Should this rfkill block be removed manually, (just tested it) wicd will start using the device once more.

Any ideas?

Code:

@dbus.service.method('org.wicd.daemon')
def SetWirelessInterface(self, interface):
    """ Sets the wireless interface the daemon will use. """
    print "setting wireless interface %s" % (str(interface))
    self.wifi.wireless_interface = noneToBlankString(interface)
    self.config.set("Settings", "wireless_interface", interface, write=True)

I've noticed that one can set the wireless interface via dbus. Maybe if I set this to none I can disable it? I'll need to test this some more.

frankbell 09-03-2013 06:47 PM

Cool, thanks for the update.

There is an rfkill item on the wicd-curses menu bar at the bottom of the terminal window. I didn't catch it because I haven't had occasion to learn that command before.


All times are GMT -5. The time now is 07:44 PM.