def __init__(self): bus_name = dbus.service.BusName('es.atareao.TouchpadIndicator', bus=dbus.SessionBus()) dbus.service.Object.__init__(self, bus_name, '/es/atareao/TouchpadIndicator') self.about_dialog = None self.the_watchdog = None self.icon = comun.ICON self.active_icon = None self.attention_icon = None self.keyboardMonitor = None self.doItAfter = None self.enable_after = 0.2 self.touchpad = Touchpad() self.last_time_keypressed = 0 self.interval = 0 self.time_watcher = 0 self.notification = Notify.Notification.new('', '', None) self.indicator = appindicator.Indicator.new( 'Touchpad-Indicator', '', appindicator.IndicatorCategory.HARDWARE) menu = self.get_menu() self.indicator.set_menu(menu) self.indicator.connect('scroll-event', self.on_scroll) self.read_preferences(is_on_start=True)
def __init__(self): bus_name = dbus.service.BusName('es.atareao.TouchpadIndicator', bus=dbus.SessionBus()) dbus.service.Object.__init__(self, bus_name, '/es/atareao/TouchpadIndicator') self.about_dialog = None self.the_watchdog = None self.icon = comun.ICON self.active_icon = None self.attention_icon = None self.synclient = Synclient() self.syndaemon = Syndaemon() self.read_preferences() self.notification = Notify.Notification.new('', '', None) self.indicator = appindicator.Indicator.new ('Touchpad-Indicator',\ self.active_icon, appindicator.IndicatorCategory.HARDWARE) self.indicator.set_attention_icon(self.attention_icon) if not self.start_hidden: self.indicator.set_status(appindicator.IndicatorStatus.ACTIVE) self.touchpad = Touchpad() menu = self.get_menu() self.indicator.set_menu(menu) self.indicator.connect('scroll-event', self.on_scroll) if self.touchpad.are_all_touchpad_enabled(): self.change_state_item.set_label(_('Disable Touchpad')) else: self.change_state_item.set_label(_('Enable Touchpad')) if self.indicator.get_status( ) != appindicator.IndicatorStatus.PASSIVE: self.indicator.set_status( appindicator.IndicatorStatus.ATTENTION) self.on_mouse_plugged_change(self.on_mouse_plugged) if self.touchpad.are_all_touchpad_enabled( ) and self.disable_touchpad_on_start_indicator: self.set_touch_enabled(False) configuration = Configuration() configuration.set('is_working', True) configuration.save()
self._active_gesture = SingleFingerMoveGesture(self, update) elif update.n_touches == 2: self._active_gesture = TwoFingerSwipePinchGesture(self, update) elif update.n_touches > 2: self._active_gesture = HigherSwipeGesture(self, update) if self._active_gesture is not None: if was_pending and not self._active_gesture.pending: for l in self._listeners: l(self._active_gesture) if __name__ == '__main__': from touchpad import find_all_touchpads, Touchpad # type: ignore def callback(gesture: Gesture) -> None: print("New Gesture: %s" % gesture) gesture.listener(GestureListener( lambda values: print(values), lambda: print("---- Terminated ----") )) event = list(find_all_touchpads())[0][1] touchpad = Touchpad(event) gestures = Gestures( touchpad ) gestures.listener(callback) touchpad.run()
touchpad_indicator_service = bus.get_object( 'es.atareao.TouchpadIndicator', '/es/atareao/TouchpadIndicator') if len(sys.argv) > 1 and sys.argv[1] == 'resume': print(sys.argv) check_status_from_resume = \ touchpad_indicator_service.get_dbus_method( 'check_status_from_resume', 'es.atareao.TouchpadIndicator') check_status_from_resume() else: check_status = touchpad_indicator_service.get_dbus_method( 'check_status', 'es.atareao.TouchpadIndicator') check_status() print('Touchpad-Indicator is working') except dbus.exceptions.DBusException as argument: print(argument) touchpad = Touchpad() configuration = Configuration() touchpad_enabled = configuration.get('touchpad_enabled') touchpad_indicator_working = configuration.get('is_working') status = touchpad.are_all_touchpad_enabled() if touchpad_indicator_working: print('Touchpad-Indicator is working') if touchpad_enabled != status: if touchpad_enabled: touchpad.enable_all_touchpads() else: touchpad.disable_all_touchpads() newstatus = touchpad.are_all_touchpad_enabled() if status != newstatus: configuration.set('touchpad_enabled', newstatus) configuration.save()
def __init__(self, is_synaptics): # Gtk.Dialog.__init__( self, 'Touchpad Indicator | ' + _('Preferences'), None, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, (Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT, Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT)) self.set_position(Gtk.WindowPosition.CENTER_ALWAYS) # self.set_size_request(400, 230) self.connect('close', self.close_application) self.set_icon_from_file(comun.ICON) self.is_synaptics = is_synaptics vbox0 = Gtk.VBox(spacing=5) vbox0.set_border_width(5) self.get_content_area().add(vbox0) notebook = Gtk.Notebook.new() vbox0.add(notebook) if get_desktop_environment() in ['unity', 'gnome', 'cinnamon', 'mate']: vbox1 = Gtk.VBox(spacing=5) vbox1.set_border_width(5) notebook.append_page(vbox1, Gtk.Label.new(_('Shortcut'))) frame1 = Gtk.Frame() vbox1.pack_start(frame1, False, True, 1) grid1 = Gtk.Grid() grid1.set_row_spacing(10) grid1.set_column_spacing(10) grid1.set_margin_bottom(10) grid1.set_margin_left(10) grid1.set_margin_right(10) grid1.set_margin_top(10) frame1.add(grid1) label1 = Gtk.Label(_('Shortcut enabled')) label1.set_alignment(0, 0.5) grid1.attach(label1, 0, 0, 1, 1) self.checkbutton0 = Gtk.Switch() self.checkbutton0.connect('button-press-event', self.on_checkbutton0_clicked) grid1.attach(self.checkbutton0, 1, 0, 1, 1) # self.ctrl = Gtk.ToggleButton('Control') self.ctrl.set_sensitive(False) grid1.attach(self.ctrl, 2, 0, 1, 1) self.alt = Gtk.ToggleButton('Alt') self.alt.set_sensitive(False) grid1.attach(self.alt, 3, 0, 1, 1) self.entry11 = Gtk.Entry() self.entry11.set_editable(False) self.entry11.set_width_chars(4) self.entry11.connect('key-release-event', self.on_entry11_key_release_event) grid1.attach(self.entry11, 4, 0, 1, 1) vbox2 = Gtk.VBox(spacing=5) vbox2.set_border_width(5) notebook.append_page(vbox2, Gtk.Label.new(_('Actions'))) frame2 = Gtk.Frame() vbox2.pack_start(frame2, True, True, 0) grid2 = Gtk.Grid() grid2.set_row_spacing(10) grid2.set_column_spacing(10) grid2.set_margin_bottom(10) grid2.set_margin_left(10) grid2.set_margin_right(10) grid2.set_margin_top(10) frame2.add(grid2) label = Gtk.Label(_('Disable touchpad when mouse plugged')) label.set_alignment(0, 0.5) grid2.attach(label, 0, 0, 1, 1) checkbutton2box = Gtk.HBox() self.checkbutton2 = Gtk.Switch() checkbutton2box.pack_start(self.checkbutton2, False, False, 0) grid2.attach(checkbutton2box, 1, 0, 1, 1) label = Gtk.Label(_('On Touchpad Indicator starts:')) label.set_alignment(0, 0.5) grid2.attach(label, 0, 1, 1, 1) self.on_start = {} self.on_start['none'] = Gtk.RadioButton() self.on_start['none'].set_label(_('None')) grid2.attach(self.on_start['none'], 0, 2, 1, 1) self.on_start['enable'] = Gtk.RadioButton(group=self.on_start['none']) self.on_start['enable'].set_label(_('Enable touchpad')) grid2.attach(self.on_start['enable'], 1, 2, 1, 1) self.on_start['disable'] = Gtk.RadioButton(group=self.on_start['none']) self.on_start['disable'].set_label(_('Disable touchpad')) grid2.attach(self.on_start['disable'], 2, 2, 1, 1) label = Gtk.Label(_('On Touchpad Indicator ends:')) label.set_alignment(0, 0.5) grid2.attach(label, 0, 3, 1, 1) self.on_end = {} self.on_end['none'] = Gtk.RadioButton() self.on_end['none'].set_label(_('None')) grid2.attach(self.on_end['none'], 0, 4, 1, 1) self.on_end['enable'] = Gtk.RadioButton(group=self.on_end['none']) self.on_end['enable'].set_label(_('Enable touchpad')) grid2.attach(self.on_end['enable'], 1, 4, 1, 1) self.on_end['disable'] = Gtk.RadioButton(group=self.on_end['none']) self.on_end['disable'].set_label(_('Disable touchpad')) grid2.attach(self.on_end['disable'], 2, 4, 1, 1) self.checkbutton8 = Gtk.CheckButton.new_with_label( _('Disable touchpad on typing')) self.checkbutton8.connect('toggled', self.on_checkbutton8_toggled) grid2.attach(self.checkbutton8, 0, 5, 1, 1) self.label_interval = Gtk.Label( _('Milliseconds to wait \ after the last key\npress before enabling the touchpad') + ':') grid2.attach(self.label_interval, 0, 6, 1, 1) # self.interval = Gtk.SpinButton() self.interval.set_adjustment( Gtk.Adjustment(500, 300, 10000, 100, 1000, 0)) grid2.attach(self.interval, 1, 6, 1, 1) vbox3 = Gtk.VBox(spacing=5) vbox3.set_border_width(5) notebook.append_page(vbox3, Gtk.Label.new(_('General options'))) frame3 = Gtk.Frame() vbox3.pack_start(frame3, True, True, 0) grid3 = Gtk.Grid() grid3.set_row_spacing(10) grid3.set_column_spacing(10) grid3.set_margin_bottom(10) grid3.set_margin_left(10) grid3.set_margin_right(10) grid3.set_margin_top(10) frame3.add(grid3) label = Gtk.Label(_('Autostart')) label.set_alignment(0, 0.5) grid3.attach(label, 0, 0, 1, 1) checkbutton1box = Gtk.HBox() self.checkbutton1 = Gtk.Switch() checkbutton1box.pack_start(self.checkbutton1, False, False, 0) grid3.attach(checkbutton1box, 1, 0, 1, 1) self.checkbutton5 = Gtk.CheckButton.new_with_label(_('Start hidden')) grid3.attach(self.checkbutton5, 0, 1, 1, 1) # self.checkbutton6 = Gtk.CheckButton.new_with_label( _('Show notifications')) grid3.attach(self.checkbutton6, 0, 2, 1, 1) vbox4 = Gtk.VBox(spacing=5) vbox4.set_border_width(5) notebook.append_page(vbox4, Gtk.Label.new(_('Touchpad configuration'))) frame4 = Gtk.Frame() vbox4.pack_start(frame4, True, True, 0) grid4 = Gtk.Grid() grid4.set_row_spacing(10) grid4.set_column_spacing(10) grid4.set_margin_bottom(10) grid4.set_margin_left(10) grid4.set_margin_right(10) grid4.set_margin_top(10) frame4.add(grid4) label = Gtk.Label(_('Natural scrolling?')) label.set_alignment(0, 0.5) grid4.attach(label, 0, 0, 1, 1) checkbutton46box = Gtk.HBox() self.checkbutton46 = Gtk.Switch() checkbutton46box.pack_start(self.checkbutton46, False, False, 0) grid4.attach(checkbutton46box, 1, 0, 1, 1) tp = Touchpad() if tp.is_there_touchpad(): tipo = tp._get_type(tp._get_ids()[0]) if tipo == SYNAPTICS: label = Gtk.Label(_('Touchpad speed?')) label.set_alignment(0, 0.5) grid4.attach(label, 0, 1, 1, 1) self.speed = Gtk.Scale() self.speed.set_size_request(300, 0) self.speed.set_digits(0) self.speed.set_adjustment( Gtk.Adjustment(0, -100, 100, 1, 10, 0)) grid4.attach(self.speed, 1, 1, 1, 1) label = Gtk.Label(_('Two finger scolling?')) label.set_alignment(0, 0.5) grid4.attach(label, 0, 2, 1, 1) two_finger_scrollingbox = Gtk.HBox() self.two_finger_scrolling = Gtk.Switch() two_finger_scrollingbox.pack_start(self.two_finger_scrolling, False, False, 0) grid4.attach(two_finger_scrollingbox, 1, 2, 1, 1) label = Gtk.Label(_('Edge scolling?')) label.set_alignment(0, 0.5) grid4.attach(label, 0, 3, 1, 1) edge_scrollingbox = Gtk.HBox() self.edge_scrolling = Gtk.Switch() edge_scrollingbox.pack_start(self.edge_scrolling, False, False, 0) grid4.attach(edge_scrollingbox, 1, 3, 1, 1) label = Gtk.Label(_('Circular scolling?')) label.set_alignment(0, 0.5) grid4.attach(label, 0, 4, 1, 1) cicular_scrollingbox = Gtk.HBox() self.cicular_scrolling = Gtk.Switch() cicular_scrollingbox.pack_start(self.cicular_scrolling, False, False, 0) grid4.attach(cicular_scrollingbox, 1, 4, 1, 1) label = Gtk.Label(_('Driver: Synaptics')) label.set_alignment(0, 0.5) grid4.attach(label, 0, 5, 1, 1) elif tipo == LIBINPUT: if tp.has_tapping(): label = Gtk.Label(_('Tapping?')) label.set_alignment(0, 0.5) grid4.attach(label, 0, 1, 1, 1) tappingbox = Gtk.HBox() self.tapping = Gtk.Switch() tappingbox.pack_start(self.tapping, False, False, 0) grid4.attach(tappingbox, 1, 1, 1, 1) label = Gtk.Label(_('Touchpad speed?')) label.set_alignment(0, 0.5) grid4.attach(label, 0, 2, 1, 1) self.speed = Gtk.Scale() self.speed.set_size_request(300, 0) self.speed.set_digits(0) self.speed.set_adjustment( Gtk.Adjustment(0, -100, 100, 1, 10, 0)) grid4.attach(self.speed, 1, 2, 1, 1) if tp.can_two_finger_scrolling(): label = Gtk.Label(_('Two finger scolling?')) label.set_alignment(0, 0.5) grid4.attach(label, 0, 3, 1, 1) two_finger_scrollingbox = Gtk.HBox() self.two_finger_scrolling = Gtk.Switch() self.two_finger_scrolling.connect( 'state-set', self.on_two_finger_scrolling_changed) two_finger_scrollingbox.pack_start( self.two_finger_scrolling, False, False, 0) grid4.attach(two_finger_scrollingbox, 1, 3, 1, 1) if tp.can_edge_scrolling(): label = Gtk.Label(_('Edge scolling?')) label.set_alignment(0, 0.5) grid4.attach(label, 0, 4, 1, 1) edge_scrollingbox = Gtk.HBox() self.edge_scrolling = Gtk.Switch() self.edge_scrolling.connect('state-set', self.on_edge_scrolling_changed) edge_scrollingbox.pack_start(self.edge_scrolling, False, False, 0) grid4.attach(edge_scrollingbox, 1, 4, 1, 1) label = Gtk.Label(_('Driver: Libinput')) label.set_alignment(0, 0.5) grid4.attach(label, 0, 5, 1, 1) elif tipo == EVDEV: label = Gtk.Label(_('Touchpad speed?')) label.set_alignment(0, 0.5) grid4.attach(label, 0, 1, 1, 1) self.speed = Gtk.Scale() self.speed.set_size_request(300, 0) self.speed.set_digits(0) self.speed.set_adjustment( Gtk.Adjustment(0, -100, 100, 1, 10, 0)) grid4.attach(self.speed, 1, 1, 1, 1) label = Gtk.Label(_('Driver: Evdev')) label.set_alignment(0, 0.5) grid4.attach(label, 0, 2, 1, 1) vbox6 = Gtk.VBox(spacing=5) vbox6.set_border_width(5) notebook.append_page(vbox6, Gtk.Label.new(_('Theme'))) frame6 = Gtk.Frame() vbox6.pack_start(frame6, True, True, 0) grid6 = Gtk.Grid() grid6.set_row_spacing(10) grid6.set_column_spacing(10) grid6.set_margin_bottom(10) grid6.set_margin_left(10) grid6.set_margin_right(10) grid6.set_margin_top(10) frame6.add(grid6) label4 = Gtk.Label(_('Select theme') + ':') label4.set_alignment(0, 0.5) grid6.attach(label4, 0, 0, 1, 1) self.radiobutton1 = Gtk.RadioButton() image1 = Gtk.Image() image1.set_from_file( os.path.join(comun.ICONDIR, 'touchpad-indicator-light-enabled.svg')) self.radiobutton1.add(image1) grid6.attach(self.radiobutton1, 1, 0, 1, 1) self.radiobutton2 = Gtk.RadioButton(group=self.radiobutton1) image2 = Gtk.Image() image2.set_from_file( os.path.join(comun.ICONDIR, 'touchpad-indicator-dark-enabled.svg')) self.radiobutton2.add(image2) grid6.attach(self.radiobutton2, 2, 0, 1, 1) self.radiobutton3 = Gtk.RadioButton(group=self.radiobutton1) image3 = Gtk.Image() image3.set_from_file( os.path.join(comun.ICONDIR, 'touchpad-indicator-normal-enabled.svg')) self.radiobutton3.add(image3) grid6.attach(self.radiobutton3, 3, 0, 1, 1) self.load_preferences() self.show_all()
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 load_preferences(self): configuration = Configuration() first_time = configuration.get('first-time') version = configuration.get('version') if first_time or version != comun.VERSION: configuration.set_defaults() configuration.read() if os.path.exists(comun.FILE_AUTO_START) and\ not os.path.islink(comun.FILE_AUTO_START): os.remove(comun.FILE_AUTO_START) self.checkbutton1.set_active(os.path.islink(comun.FILE_AUTO_START)) print(comun.FILE_AUTO_START) print('====', os.path.exists(comun.FILE_AUTO_START)) self.checkbutton2.set_active(configuration.get('on_mouse_plugged')) desktop_environment = get_desktop_environment() print(desktop_environment) if desktop_environment == 'gnome' or\ desktop_environment == 'unity': dcm = DConfManager('org.gnome.settings-daemon.plugins.media-keys.\ custom-keybindings.touchpad-indicator') shortcut = dcm.get_value('binding') if shortcut is None or len(shortcut) == 0: self.checkbutton0.set_active(False) self.entry11.set_text('') else: self.checkbutton0.set_active(True) self.ctrl.set_active(shortcut.find('<Control>') > -1) self.alt.set_active(shortcut.find('<Alt>') > -1) self.entry11.set_text(shortcut[-1:]) elif desktop_environment == 'cinnamon': dcm = DConfManager('org.cinnamon.desktop.keybindings.\ custom-keybindings.touchpad-indicator') shortcuts = dcm.get_value('binding') if shortcuts is None or len(shortcuts) == 0: self.checkbutton0.set_active(False) self.entry11.set_text('') else: shortcut = shortcuts[0] self.checkbutton0.set_active(True) self.ctrl.set_active(shortcut.find('<Control>') > -1) self.alt.set_active(shortcut.find('<Alt>') > -1) self.entry11.set_text(shortcut[-1:]) elif desktop_environment == 'mate': dcm = DConfManager('org.mate.desktop.keybindings.\ touchpad-indicator') shortcut = dcm.get_value('binding') if shortcut is None or len(shortcut) == 0: self.checkbutton0.set_active(False) self.entry11.set_text('') else: self.checkbutton0.set_active(True) self.ctrl.set_active(shortcut.find('<Control>') > -1) self.alt.set_active(shortcut.find('<Alt>') > -1) self.entry11.set_text(shortcut[-1:]) option = configuration.get('on_start') if option == 0: self.on_start['none'].set_active(True) if option == 1: self.on_start['enable'].set_active(True) elif option == -1: self.on_start['disable'].set_active(True) option = configuration.get('on_end') if option == 0: self.on_end['none'].set_active(True) elif option == 1: self.on_end['enable'].set_active(True) elif option == -1: self.on_end['disable'].set_active(True) self.checkbutton5.set_active(configuration.get('start_hidden')) self.checkbutton6.set_active(configuration.get('show_notifications')) self.checkbutton8.set_active(configuration.get('disable_on_typing')) self.interval.set_value(configuration.get('interval')) self.label_interval.set_sensitive(self.checkbutton8.get_active()) self.interval.set_sensitive(self.checkbutton8.get_active()) option = configuration.get('theme') if option == 'light': self.radiobutton1.set_active(True) elif option == 'dark': self.radiobutton2.set_active(True) elif option == 'normal': self.radiobutton3.set_active(True) self.checkbutton46.set_active(configuration.get('natural_scrolling')) tp = Touchpad() if tp.is_there_touchpad(): tipo = tp._get_type(tp._get_ids()[0]) if tipo == SYNAPTICS: self.two_finger_scrolling.set_active( configuration.get('two_finger_scrolling')) self.edge_scrolling.set_active( configuration.get('edge_scrolling')) self.cicular_scrolling.set_active( configuration.get('cicular_scrolling')) elif tipo == LIBINPUT: if tp.can_two_finger_scrolling(): self.two_finger_scrolling.set_active( configuration.get('two_finger_scrolling')) if tp.can_edge_scrolling(): self.edge_scrolling.set_active( configuration.get('edge_scrolling')) if tp.has_tapping(): self.tapping.set_active(configuration.get('tapping')) self.speed.set_value(configuration.get('speed'))