Using setEnabledWireless to handle radio settings #1406
This commit is contained in:
parent
21e3447e70
commit
bf4c327bac
32
shell/controlpanel/control.py
Normal file → Executable file
32
shell/controlpanel/control.py
Normal file → Executable file
@ -307,13 +307,13 @@ def get_radio():
|
|||||||
bus = dbus.SystemBus()
|
bus = dbus.SystemBus()
|
||||||
proxy = bus.get_object(NM_SERVICE_NAME, NM_SERVICE_PATH)
|
proxy = bus.get_object(NM_SERVICE_NAME, NM_SERVICE_PATH)
|
||||||
nm = dbus.Interface(proxy, NM_SERVICE_IFACE)
|
nm = dbus.Interface(proxy, NM_SERVICE_IFACE)
|
||||||
state = nm.state()
|
state = nm.getWirelessEnabled()
|
||||||
if state:
|
if state == 0:
|
||||||
if state == NM_ASLEEP:
|
return _('off')
|
||||||
return _('off')
|
elif state == 1:
|
||||||
else:
|
return _('on')
|
||||||
return _('on')
|
else:
|
||||||
return _('State is unknown.')
|
return _('State is unknown.')
|
||||||
|
|
||||||
def print_radio():
|
def print_radio():
|
||||||
print get_radio()
|
print get_radio()
|
||||||
@ -322,18 +322,16 @@ def set_radio(state):
|
|||||||
"""Turn Radio 'on' or 'off'
|
"""Turn Radio 'on' or 'off'
|
||||||
state : 'on/off'
|
state : 'on/off'
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# TODO: NM 0.6.x does not return a reply yet
|
|
||||||
# so we ignore it for the moment
|
|
||||||
|
|
||||||
if state == 'on':
|
if state == 'on':
|
||||||
dbus.SystemBus().call_async(NM_SERVICE_NAME, NM_SERVICE_PATH,
|
bus = dbus.SystemBus()
|
||||||
NM_SERVICE_IFACE, 'wake', '', (),
|
proxy = bus.get_object(NM_SERVICE_NAME, NM_SERVICE_PATH)
|
||||||
None, None)
|
nm = dbus.Interface(proxy, NM_SERVICE_IFACE)
|
||||||
|
nm.setWirelessEnabled(True)
|
||||||
elif state == 'off':
|
elif state == 'off':
|
||||||
dbus.SystemBus().call_async(NM_SERVICE_NAME, NM_SERVICE_PATH,
|
bus = dbus.SystemBus()
|
||||||
NM_SERVICE_IFACE, 'sleep', '', (),
|
proxy = bus.get_object(NM_SERVICE_NAME, NM_SERVICE_PATH)
|
||||||
None, None)
|
nm = dbus.Interface(proxy, NM_SERVICE_IFACE)
|
||||||
|
nm.setWirelessEnabled(False)
|
||||||
else:
|
else:
|
||||||
print (_("Error in specified radio argument use on/off."))
|
print (_("Error in specified radio argument use on/off."))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user