#!/usr/bin/python # nm_unset: Display a list of known networks and delete the ones that # are selected from gconf. import gconf, subprocess # Fetch the list of known networks c = gconf.client_get_default() networks = dict([(c.get_string(x + '/essid'), x) for x in c.all_dirs('/system/networking/wireless/networks')]) # Let's be lazy and use zenity... args = ['zenity', '--list', '--checklist', '--height', '300', '--width', '300', '--separator', '\n', '--title', 'Select networks to remove', '--text', 'Select networks to remove', '--column', 'Delete', '--column', 'SSID'] for n in sorted(networks, lambda x, y: cmp(x.lower(), y.lower())): args += ['FALSE', n] out, err = subprocess.Popen(args,stdout=subprocess.PIPE).communicate() # Delete the selected ones for net in out.split('\n'): if net: c.recursive_unset(networks[net], gconf.UNSET_INCLUDING_SCHEMA_NAMES) c.suggest_sync()