Toggle wifi button problem
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
wicd |
New
|
Undecided
|
Unassigned |
Bug Description
#
# Wicd version: 1.7.3
# Distribution: Ubuntu 15.04 (vivid)
# Architecture: x86_64
# Kernel: 3.19.0-22-generic
# Python version: 2.7.9
#
If I press "Switch On Wifi", Wifi is turned on and a new button appears with the text "Switch Off Wifi". If I now press "Switch Off Wifi" the state of the wireless interface and the button remains unchanged. That is the wireless network interface is still turned on and the button does not change itself back into showing "Switch On Wifi".
After looking into the source code of wicd I noticed it's reading the output from rfkill list in order to determine if the wireless network interface is soft blocked or not (activated or not activated). If I run
$ rfkill list
from the command line I get
0: hci0: Bluetooth
Soft blocked: yes
Hard blocked: no
1: phy0: Wireless LAN
Soft blocked: no
Hard blocked: no
Now if I unblock Bluetooth
# rfkill unblock bluetooth
to give me (by executing $ rfkill list on the command line),
0: hci0: Bluetooth
Soft blocked: no
Hard blocked: no
1: phy0: Wireless LAN
Soft blocked: no
Hard blocked: no
, the button suddenly works as expected.
My guess is that the wifi-toggle-
def GetRfKillStatus
""" Determines if rfkill switch is active or not.
Returns:
True if rfkill (soft-)switch is enabled.
"""
cmd = 'rfkill list'
rfkill_out = misc.Run(cmd)
soft_blocks = filter(lambda x: x.startswith(
for line in map(lambda x: x.strip(), soft_blocks):
if line.endswith(
return False
Since I'm not very familiar with Python (and the logic behind the lines in the original method) I pretty much rewrote the entire method. The changes seem to fix the problem, but I'm not too sure. Could someone who's better oriented in this project confirm it?
def GetRfKillStatus
""" Determines if rfkill switch is active or not.
Returns:
True if rfkill (soft-)switch is enabled.
"""
cmd = 'rfkill list wlan'
rfkill_out = misc.Run(cmd)
if rfkill_
return True
else:
return False
description: | updated |
description: | updated |
description: | updated |
description: | updated |
description: | updated |
description: | updated |
description: | updated |
description: | updated |
description: | updated |
description: | updated |
Please ignore the first solution I posted as it does not work when we're using 'WiMAX' or 'Wireless LAN'. Here's an updated version of the method.
def GetRfKillStatus (self):
""" Determines if rfkill switch is active or not.
Returns: cmd).strip( ).split( '\n')
True if rfkill (soft-)switch is enabled.
"""
cmd = 'rfkill list'
types = ['Wireless LAN', 'WiMAX', 'Wireless WAN']
rfkill_out = misc.Run(
rfkill_out = map(lambda x: x.strip(), rfkill_out)
# rfkill_out is empty or a list (e.g.) on the form rfkill_ out):
if rfkill_out[index+1] == 'Soft blocked: yes':
return True
# ['0: hci0: Bluetooth', 'Soft blocked: yes', 'Hard blocked: no', ...,
# 'n: phy0: Wireless LAN', 'Soft blocked: no', 'Hard blocked: no']
# Return True if any type is is Soft blocked.
try:
for index, item in enumerate(
if filter(lambda y: item.endswith(y), types):
except IndexError:
pass
return False
If any wireless network interface is soft blocked then it'll return True, otherwise False. Everything seems to work as expected now, but again I'll let someone who's more oriented in this project to be the judge of that :)