def save_preferences(self): configuration = Configuration() configuration.set('first-time', False) configuration.set('version', comun.VERSION) if self.radiobutton1.get_active() is True: configuration.set('theme', 'light') elif self.radiobutton2.get_active() is True: configuration.set('theme', 'dark') else: configuration.set('theme', 'normal') if self.on_start['none'].get_active() is True: configuration.set('on_start', 0) elif self.on_start['enable'].get_active() is True: configuration.set('on_start', 1) else: configuration.set('on_start', -1) if self.on_end['none'].get_active() is True: configuration.set('on_end', 0) elif self.on_end['enable'].get_active() is True: configuration.set('on_end', 1) else: configuration.set('on_end', -1) configuration.set('autostart', self.checkbutton1.get_active()) set_autostart(self.checkbutton1.get_active()) configuration.set('on_mouse_plugged', self.checkbutton2.get_active()) configuration.set('start_hidden', self.checkbutton5.get_active()) configuration.set('show_notifications', self.checkbutton6.get_active()) configuration.set('disable_on_typing', self.checkbutton8.get_active()) configuration.set('interval', self.interval.get_value()) configuration.set('natural_scrolling', self.checkbutton46.get_active()) tp = Touchpad() if tp.is_there_touchpad(): tipo = tp.get_driver() if tipo == SYNAPTICS: configuration.set( 'two_finger_scrolling', self.two_finger_scrolling.get_active()) configuration.set( 'edge_scrolling', self.edge_scrolling.get_active()) configuration.set( 'cicular_scrolling', self.cicular_scrolling.get_active()) configuration.set( 'right-top-corner', get_selected_value_in_combo(self.right_top_corner)) configuration.set( 'right-bottom-corner', get_selected_value_in_combo(self.right_bottom_corner)) configuration.set( 'left-top-corner', get_selected_value_in_combo(self.left_top_corner)) configuration.set( 'left-bottom-corner', get_selected_value_in_combo(self.right_bottom_corner)) configuration.set( 'one-finger-tap', get_selected_value_in_combo(self.one_finger_tap)) if tp.get_capabilities()['two-finger-detection']: configuration.set( 'two-finger-tap', get_selected_value_in_combo(self.two_finger_tap)) if tp.get_capabilities()['three-finger-detection']: configuration.set( 'three-finger-tap', get_selected_value_in_combo(self.three_finger_tap)) elif tipo == LIBINPUT: if tp.can_two_finger_scrolling(): configuration.set( 'two_finger_scrolling', self.two_finger_scrolling.get_active()) if tp.can_edge_scrolling(): configuration.set( 'edge_scrolling', self.edge_scrolling.get_active()) if tp.has_tapping(): configuration.set('tapping', self.tapping.get_active()) configuration.set('speed', self.speed.get_value()) elif tipo == EVDEV: configuration.set('speed', self.speed.get_value()) import watchdog configuration.set('faulty-devices', list(watchdog.faulty_devices)) configuration.save() desktop_environment = get_desktop_environment() if desktop_environment in ['gnome', 'unity', 'cinnamon', 'mate']: self.ctrl.set_active(True) self.alt.set_active(True) print(desktop_environment) if desktop_environment in ['gnome', 'unity']: dcm = DConfManager('org.gnome.settings-daemon.plugins.media-keys.\ custom-keybindings.touchpad-indicator') if self.checkbutton0.get_active() and\ len(self.entry11.get_text()) > 0: key1 = '' key2 = None if self.ctrl.get_active() is True: key1 += '<Control>' key2 = '<Primary>' if self.alt.get_active() is True: key1 += '<Alt>' if key2 is not None: key2 += '<Alt>' key1 += self.entry11.get_text().lower() if key2 is not None: key2 += self.entry11.get_text().lower() if key1 not in get_shortcuts() and key2 not in get_shortcuts(): dcm = DConfManager('org.gnome.settings-daemon.plugins.\ media-keys') shortcuts = dcm.get_value('custom-keybindings') key = '/org/gnome/settings-daemon/plugins/media-keys/\ custom-keybindings/touchpad-indicator/' if key in shortcuts: shortcuts.pop(shortcuts.index(key)) dcm.set_value('custom-keybindings', shortcuts) if key not in shortcuts: shortcuts.append(key) dcm.set_value('custom-keybindings', shortcuts) dcm = DConfManager('org.gnome.settings-daemon.plugins.media-keys.\ custom-keybindings.touchpad-indicator') dcm.set_value('name', 'Touchpad-Indicator') dcm.set_value('binding', key1) dcm.set_value('command', '/usr/bin/python3 \ /usr/share/touchpad-indicator/change_touchpad_state.py') else: dcm.set_value('binding', '') dcm = DConfManager('org.gnome.settings-daemon.plugins.\ media-keys') shortcuts = dcm.get_value('custom-keybindings') key = '/org/gnome/settings-daemon/plugins/media-keys/\ custom-keybindings/touchpad-indicator/' if key in shortcuts: shortcuts.pop(shortcuts.index(key)) dcm.set_value('custom-keybindings', shortcuts) elif desktop_environment == 'cinnamon': dcm = DConfManager('org.cinnamon.desktop.keybindings.\ custom-keybindings.touchpad-indicator') if self.checkbutton0.get_active() and\ len(self.entry11.get_text()) > 0: key1 = '' key2 = None if self.ctrl.get_active() is True: key1 += '<Control>' key2 = '<Primary>' if self.alt.get_active() is True: key1 += '<Alt>' if key2 is not None: key2 += '<Alt>' key1 += self.entry11.get_text().lower() if key2 is not None: key2 += self.entry11.get_text().lower() if key1 not in get_shortcuts() and key2 not in get_shortcuts(): dcm.set_value('name', 'Touchpad-Indicator') dcm.set_value('binding', [key1]) dcm.set_value('command', '/usr/bin/python3 \ /usr/share/touchpad-indicator/change_touchpad_state.py') dcm = DConfManager('org.cinnamon.desktop.keybindings') shortcuts = dcm.get_value('custom-list') if 'touchpad-indicator' in shortcuts: shortcuts.pop(shortcuts.index('touchpad-indicator')) dcm.set_value('custom-list', shortcuts) if 'touchpad-indicator' not in shortcuts: shortcuts.append('touchpad-indicator') dcm.set_value('custom-list', shortcuts) else: dcm.set_value('binding', []) dcm = DConfManager('org.cinnamon.desktop.keybindings') shortcuts = dcm.get_value('custom-list') if 'touchpad-indicator' in shortcuts: shortcuts.pop(shortcuts.index('touchpad-indicator')) dcm.set_value('custom-list', shortcuts) elif desktop_environment == 'mate': dcm = DConfManager('org.mate.desktop.keybindings.\ touchpad-indicator') if self.checkbutton0.get_active() and\ len(self.entry11.get_text()) > 0: key1 = '' key2 = None if self.ctrl.get_active() is True: key1 += '<Control>' key2 = '<Primary>' if self.alt.get_active() is True: key1 += '<Alt>' if key2 is not None: key2 += '<Alt>' key1 += self.entry11.get_text().lower() if key2 is not None: key2 += self.entry11.get_text().lower() if key1 not in get_shortcuts() and key2 not in get_shortcuts(): dcm.set_value('name', 'Touchpad-Indicator') dcm.set_value('binding', key1) dcm.set_value('action', '/usr/bin/python3 \ /usr/share/touchpad-indicator/change_touchpad_state.py') else: dcm.set_value('binding', '') elif desktop_environment == 'xfce': if xfconfquery_exists(): xfceconf = XFCEConfiguration('xfce4-keyboard-shortcuts') keys = xfceconf.search_for_value_in_properties_startswith( '/commands/custom/', '/usr/share/\ touchpad-indicator/change_touchpad_state.py') if keys: for akey in keys: xfceconf.reset_property(akey['key']) if self.checkbutton0.get_active(): key = key.replace('<Primary>', '<Control>') xfceconf.set_property( '/commands/custom/' + key, '/usr/share/\ touchpad-indicator/change_touchpad_state.py')
def save_preferences(self): configuration = Configuration() configuration.set('first-time', False) configuration.set('version', comun.VERSION) if self.radiobutton1.get_active() is True: configuration.set('theme', 'light') elif self.radiobutton2.get_active() is True: configuration.set('theme', 'dark') else: configuration.set('theme', 'normal') if self.on_start['none'].get_active() is True: configuration.set('on_start', 0) elif self.on_start['enable'].get_active() is True: configuration.set('on_start', 1) else: configuration.set('on_start', -1) if self.on_end['none'].get_active() is True: configuration.set('on_end', 0) elif self.on_end['enable'].get_active() is True: configuration.set('on_end', 1) else: configuration.set('on_end', -1) configuration.set('autostart', self.checkbutton1.get_active()) set_autostart(self.checkbutton1.get_active()) configuration.set('on_mouse_plugged', self.checkbutton2.get_active()) configuration.set('start_hidden', self.checkbutton5.get_active()) configuration.set('show_notifications', self.checkbutton6.get_active()) configuration.set('disable_on_typing', self.checkbutton8.get_active()) configuration.set('interval', self.interval.get_value()) configuration.set('natural_scrolling', self.checkbutton46.get_active()) tp = Touchpad() if tp.is_there_touchpad(): tipo = tp._get_type(tp._get_ids()[0]) if tipo == SYNAPTICS: configuration.set('two_finger_scrolling', self.two_finger_scrolling.get_active()) configuration.set('edge_scrolling', self.edge_scrolling.get_active()) configuration.set('cicular_scrolling', self.cicular_scrolling.get_active()) elif tipo == LIBINPUT: if tp.can_two_finger_scrolling(): configuration.set('two_finger_scrolling', self.two_finger_scrolling.get_active()) if tp.can_edge_scrolling(): configuration.set('edge_scrolling', self.edge_scrolling.get_active()) if tp.has_tapping(): configuration.set('tapping', self.tapping.get_active()) configuration.set('speed', self.speed.get_value()) elif tipo == EVDEV: configuration.set('speed', self.speed.get_value()) configuration.save() desktop_environment = get_desktop_environment() if desktop_environment in ['gnome', 'unity', 'cinnamon', 'mate']: self.ctrl.set_active(True) self.alt.set_active(True) print(desktop_environment) if desktop_environment in ['gnome', 'unity']: dcm = DConfManager('org.gnome.settings-daemon.plugins.media-keys.\ custom-keybindings.touchpad-indicator') if self.checkbutton0.get_active() and\ len(self.entry11.get_text()) > 0: key1 = '' key2 = None if self.ctrl.get_active() is True: key1 += '<Control>' key2 = '<Primary>' if self.alt.get_active() is True: key1 += '<Alt>' if key2 is not None: key2 += '<Alt>' key1 += self.entry11.get_text().lower() if key2 is not None: key2 += self.entry11.get_text().lower() if key1 not in get_shortcuts() and key2 not in get_shortcuts(): dcm = DConfManager('org.gnome.settings-daemon.plugins.\ media-keys') shortcuts = dcm.get_value('custom-keybindings') key = '/org/gnome/settings-daemon/plugins/media-keys/\ custom-keybindings/touchpad-indicator/' if key in shortcuts: shortcuts.pop(shortcuts.index(key)) dcm.set_value('custom-keybindings', shortcuts) if key not in shortcuts: shortcuts.append(key) dcm.set_value('custom-keybindings', shortcuts) dcm = DConfManager( 'org.gnome.settings-daemon.plugins.media-keys.\ custom-keybindings.touchpad-indicator') dcm.set_value('name', 'Touchpad-Indicator') dcm.set_value('binding', key1) dcm.set_value( 'command', '/usr/bin/python3 \ /usr/share/touchpad-indicator/change_touchpad_state.py') else: dcm.set_value('binding', '') dcm = DConfManager('org.gnome.settings-daemon.plugins.\ media-keys') shortcuts = dcm.get_value('custom-keybindings') key = '/org/gnome/settings-daemon/plugins/media-keys/\ custom-keybindings/touchpad-indicator/' if key in shortcuts: shortcuts.pop(shortcuts.index(key)) dcm.set_value('custom-keybindings', shortcuts) elif desktop_environment == 'cinnamon': dcm = DConfManager('org.cinnamon.desktop.keybindings.\ custom-keybindings.touchpad-indicator') if self.checkbutton0.get_active() and\ len(self.entry11.get_text()) > 0: key1 = '' key2 = None if self.ctrl.get_active() is True: key1 += '<Control>' key2 = '<Primary>' if self.alt.get_active() is True: key1 += '<Alt>' if key2 is not None: key2 += '<Alt>' key1 += self.entry11.get_text().lower() if key2 is not None: key2 += self.entry11.get_text().lower() if key1 not in get_shortcuts() and key2 not in get_shortcuts(): dcm.set_value('name', 'Touchpad-Indicator') dcm.set_value('binding', [key1]) dcm.set_value( 'command', '/usr/bin/python3 \ /usr/share/touchpad-indicator/change_touchpad_state.py') dcm = DConfManager('org.cinnamon.desktop.keybindings') shortcuts = dcm.get_value('custom-list') if 'touchpad-indicator' in shortcuts: shortcuts.pop(shortcuts.index('touchpad-indicator')) dcm.set_value('custom-list', shortcuts) if 'touchpad-indicator' not in shortcuts: shortcuts.append('touchpad-indicator') dcm.set_value('custom-list', shortcuts) else: dcm.set_value('binding', []) dcm = DConfManager('org.cinnamon.desktop.keybindings') shortcuts = dcm.get_value('custom-list') if 'touchpad-indicator' in shortcuts: shortcuts.pop(shortcuts.index('touchpad-indicator')) dcm.set_value('custom-list', shortcuts) elif desktop_environment == 'mate': dcm = DConfManager('org.mate.desktop.keybindings.\ touchpad-indicator') if self.checkbutton0.get_active() and\ len(self.entry11.get_text()) > 0: key1 = '' key2 = None if self.ctrl.get_active() is True: key1 += '<Control>' key2 = '<Primary>' if self.alt.get_active() is True: key1 += '<Alt>' if key2 is not None: key2 += '<Alt>' key1 += self.entry11.get_text().lower() if key2 is not None: key2 += self.entry11.get_text().lower() if key1 not in get_shortcuts() and key2 not in get_shortcuts(): dcm.set_value('name', 'Touchpad-Indicator') dcm.set_value('binding', key1) dcm.set_value( 'action', '/usr/bin/python3 \ /usr/share/touchpad-indicator/change_touchpad_state.py') else: dcm.set_value('binding', '') elif desktop_environment == 'xfce': if xfconfquery_exists(): xfceconf = XFCEConfiguration('xfce4-keyboard-shortcuts') keys = xfceconf.search_for_value_in_properties_startswith( '/commands/custom/', '/usr/share/\ touchpad-indicator/change_touchpad_state.py') if keys: for akey in keys: xfceconf.reset_property(akey['key']) if self.checkbutton0.get_active(): key = key.replace('<Primary>', '<Control>') xfceconf.set_property( '/commands/custom/' + key, '/usr/share/\ touchpad-indicator/change_touchpad_state.py')
def save_preferences(self): configuration = Configuration() configuration.set('first-time',False) configuration.set('version',comun.VERSION) key='' if self.ctrl.get_active() == True: key+='<Primary>' if self.alt.get_active() == True: key+='<Alt>' key += self.entry11.get_text() if self.radiobutton1.get_active() == True: theme = 'light' elif self.radiobutton2.get_active() == True: theme = 'dark' configuration.set('shortcut_enabled',self.checkbutton0.get_active()) configuration.set('autostart',self.checkbutton1.get_active()) create_or_remove_autostart(self.checkbutton1.get_active()) configuration.set('on_mouse_plugged',self.checkbutton2.get_active()) configuration.set('natural_scrolling',self.checkbutton46.get_active()) configuration.set('enable_on_exit',self.checkbutton3.get_active()) configuration.set('disable_on_exit',self.checkbutton4.get_active()) configuration.set('start_hidden',self.checkbutton5.get_active()) configuration.set('show_notifications',self.checkbutton6.get_active()) configuration.set('disable_touchpad_on_start_indicator',self.checkbutton7.get_active()) configuration.set('disable_on_typing',self.checkbutton8.get_active()) configuration.set('seconds',self.seconds.get_value()) configuration.set('shortcut',key) configuration.set('theme',theme) configuration.save() aclient = Synclient() aclient.set('VertEdgeScroll',1 if self.checkbutton41.get_active() else 0) aclient.set('HorizEdgeScroll',1 if self.checkbutton42.get_active() else 0) aclient.set('CircularScrolling',1 if self.checkbutton43.get_active() else 0) aclient.set('VertTwoFingerScroll',1 if self.checkbutton44.get_active() else 0) aclient.set('HorizTwoFingerScroll',1 if self.checkbutton45.get_active() else 0) aclient.set('TapButton1',self.combobox47.get_active()) aclient.set('TapButton2',self.combobox48.get_active()) aclient.set('TapButton3',self.combobox49.get_active()) if self.checkbutton46.get_active(): aclient.set('VertScrollDelta',-abs(int(aclient.get('VertScrollDelta')))) aclient.set('HorizScrollDelta',-abs(int(aclient.get('HorizScrollDelta')))) else: aclient.set('VertScrollDelta',abs(int(aclient.get('VertScrollDelta')))) aclient.set('HorizScrollDelta',abs(int(aclient.get('HorizScrollDelta')))) desktop_environment = get_desktop_environment() if desktop_environment == 'gnome': print('gnom3') dcm = DConfManager('org.gnome.settings-daemon.plugins.media-keys') values = dcm.get_value('custom-keybindings') if self.checkbutton0.get_active(): if '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/touchpad-indicator/' not in values: values.append('/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/touchpad-indicator/') dcm.set_value('custom-keybindings',values) dcm = DConfManager('org.gnome.settings-daemon.plugins.media-keys.custom-keybindings.touchpad-indicator') print(dcm.set_value('binding',key)) print(dcm.set_value('command','/usr/bin/python3 /opt/extras.ubuntu.com/touchpad-indicator/share/touchpad-indicator/change_touchpad_state.py')) print(dcm.set_value('name','Touchpad-Indicator key binding')) else: if '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/touchpad-indicator/' in values: values.remove('/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/touchpad-indicator/') dcm.set_value('custom-keybindings',values) elif desktop_environment == 'xfce': if xfconfquery_exists(): xfceconf = XFCEConfiguration('xfce4-keyboard-shortcuts') keys = xfceconf.search_for_value_in_properties_startswith('/commands/custom/','/opt/extras.ubuntu.com/touchpad-indicator/share/touchpad-indicator/change_touchpad_state.py') if keys: for akey in keys: xfceconf.reset_property(akey['key']) if self.checkbutton0.get_active(): key = key.replace('<Primary>','<Control>') xfceconf.set_property('/commands/custom/'+key,'/opt/extras.ubuntu.com/touchpad-indicator/share/touchpad-indicator/change_touchpad_state.py')
def save_preferences(self): configuration = Configuration() configuration.set('first-time', False) configuration.set('version', comun.VERSION) key = '' if self.ctrl.get_active() == True: key += '<Primary>' if self.alt.get_active() == True: key += '<Alt>' key += self.entry11.get_text() if self.radiobutton1.get_active() == True: theme = 'light' elif self.radiobutton2.get_active() == True: theme = 'dark' configuration.set('shortcut_enabled', self.checkbutton0.get_active()) configuration.set('autostart', self.checkbutton1.get_active()) create_or_remove_autostart(self.checkbutton1.get_active()) configuration.set('on_mouse_plugged', self.checkbutton2.get_active()) configuration.set('natural_scrolling', self.checkbutton46.get_active()) configuration.set('enable_on_exit', self.checkbutton3.get_active()) configuration.set('disable_on_exit', self.checkbutton4.get_active()) configuration.set('start_hidden', self.checkbutton5.get_active()) configuration.set('show_notifications', self.checkbutton6.get_active()) configuration.set('disable_touchpad_on_start_indicator', self.checkbutton7.get_active()) configuration.set('disable_on_typing', self.checkbutton8.get_active()) configuration.set('seconds', self.seconds.get_value() / 1000) configuration.set('shortcut', key) configuration.set('theme', theme) configuration.set('VertEdgeScroll', self.checkbutton41.get_active()) configuration.set('HorizEdgeScroll', self.checkbutton42.get_active()) configuration.set('CircularScrolling', self.checkbutton43.get_active()) configuration.set('VertTwoFingerScroll', self.checkbutton44.get_active()) configuration.set('HorizTwoFingerScroll', self.checkbutton45.get_active()) configuration.set('TapButton1', self.combobox47.get_active()) configuration.set('TapButton2', self.combobox48.get_active()) configuration.set('TapButton3', self.combobox49.get_active()) configuration.save() ''' aclient = Synclient() aclient.set('VertEdgeScroll',1 if self.checkbutton41.get_active() else 0) aclient.set('HorizEdgeScroll',1 if self.checkbutton42.get_active() else 0) aclient.set('CircularScrolling',1 if self.checkbutton43.get_active() else 0) aclient.set('VertTwoFingerScroll',1 if self.checkbutton44.get_active() else 0) aclient.set('HorizTwoFingerScroll',1 if self.checkbutton45.get_active() else 0) aclient.set('TapButton1',self.combobox47.get_active()) aclient.set('TapButton2',self.combobox48.get_active()) aclient.set('TapButton3',self.combobox49.get_active()) if self.checkbutton46.get_active(): aclient.set('VertScrollDelta',-abs(int(aclient.get('VertScrollDelta')))) aclient.set('HorizScrollDelta',-abs(int(aclient.get('HorizScrollDelta')))) else: aclient.set('VertScrollDelta',abs(int(aclient.get('VertScrollDelta')))) aclient.set('HorizScrollDelta',abs(int(aclient.get('HorizScrollDelta')))) ''' desktop_environment = get_desktop_environment() if desktop_environment == 'gnome': print('gnom3') dcm = DConfManager('org.gnome.settings-daemon.plugins.media-keys') values = dcm.get_value('custom-keybindings') if self.checkbutton0.get_active(): if '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/touchpad-indicator/' not in values: values.append( '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/touchpad-indicator/' ) dcm.set_value('custom-keybindings', values) dcm = DConfManager( 'org.gnome.settings-daemon.plugins.media-keys.custom-keybindings.touchpad-indicator' ) print(dcm.set_value('binding', key)) print( dcm.set_value( 'command', '/usr/bin/python3 /opt/extras.ubuntu.com/touchpad-indicator/share/touchpad-indicator/change_touchpad_state.py' )) print(dcm.set_value('name', 'Touchpad-Indicator key binding')) else: if '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/touchpad-indicator/' in values: values.remove( '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/touchpad-indicator/' ) dcm.set_value('custom-keybindings', values) elif desktop_environment == 'xfce': if xfconfquery_exists(): xfceconf = XFCEConfiguration('xfce4-keyboard-shortcuts') keys = xfceconf.search_for_value_in_properties_startswith( '/commands/custom/', '/opt/extras.ubuntu.com/touchpad-indicator/share/touchpad-indicator/change_touchpad_state.py' ) if keys: for akey in keys: xfceconf.reset_property(akey['key']) if self.checkbutton0.get_active(): key = key.replace('<Primary>', '<Control>') xfceconf.set_property( '/commands/custom/' + key, '/opt/extras.ubuntu.com/touchpad-indicator/share/touchpad-indicator/change_touchpad_state.py' )