class IgnoreLidSwitchTweak(GetterSetterSwitchTweak): def __init__(self, **options): self._inhibitor_name = "gnome-tweak-tool-lid-inhibitor" self._inhibitor_path = "%s/%s" % (gtweak.LIBEXEC_DIR, self._inhibitor_name) self._dfile = AutostartFile(None, autostart_desktop_filename = "ignore-lid-switch-tweak.desktop", exec_cmd = self._inhibitor_path) GetterSetterSwitchTweak.__init__(self, _("Don't suspend on lid close"), **options) def get_active(self): return self._sync_inhibitor() def set_active(self, v): self._dfile.update_start_at_login(v) self._sync_inhibitor() def _sync_inhibitor(self): if (self._dfile.is_start_at_login_enabled()): GLib.spawn_command_line_async(self._inhibitor_path) return True else: bus = Gio.bus_get_sync(Gio.BusType.SESSION, None) bus.call('org.gnome.tweak-tool.lid-inhibitor', '/org/gnome/tweak_tool/lid_inhibitor', 'org.gtk.Actions', 'Activate', GLib.Variant('(sava{sv})', ('quit', [], {})), None, 0, -1, None) return False
def __init__(self, **options): self._inhibitor_name = "gnome-tweak-tool-lid-inhibitor" self._inhibitor_path = "%s/%s" % (gtweak.LIBEXEC_DIR, self._inhibitor_name) self._dfile = AutostartFile( None, autostart_desktop_filename="ignore-lid-switch-tweak.desktop", exec_cmd=self._inhibitor_path) GetterSetterSwitchTweak.__init__( self, _("Suspend when laptop lid is closed"), **options)
def __init__(self): tweaks = [AutostartTitle()] self.asm = AutostartManager() files = self.asm.get_user_autostart_files() for f in files: try: df = Gio.DesktopAppInfo.new_from_filename(f) except TypeError: logging.warning("Error loading desktopfile: %s" % f) continue if not AutostartFile(df).is_start_at_login_enabled(): continue sdf = _StartupTweak(df) sdf.btn.connect("clicked", self._on_remove_clicked, sdf, df) tweaks.append(sdf) add = AddStartupTweak() add.btn.connect("clicked", self._on_add_clicked) tweaks.append(add) ListBoxTweakGroup.__init__(self, _("Startup Applications"), *tweaks, css_class='tweak-group-startup') self.set_header_func(_list_header_func, None) self.connect("row-activated", lambda b, row: add.btn.activate() if row == add else None)
def __init__(self, **options): self._inhibitor_name = "gnome-tweak-tool-lid-inhibitor" self._inhibitor_path = "%s/%s" % (gtweak.LIBEXEC_DIR, self._inhibitor_name) self._dfile = AutostartFile(None, autostart_desktop_filename = "ignore-lid-switch-tweak.desktop", exec_cmd = self._inhibitor_path) GetterSetterSwitchTweak.__init__(self, _("Don't suspend on lid close"), **options)
def _on_add_clicked(self, btn): a = _AppChooser(self.main_window, set(self._get_running_executables())) a.show_all() resp = a.run() if resp == Gtk.ResponseType.OK: df = a.get_selected_app() if df: AutostartFile(df).update_start_at_login(True) sdf = _StartupTweak(df) sdf.btn.connect("clicked", self._on_remove_clicked, sdf, df) self.add_tweak_row(sdf, 0).show_all() a.destroy()
def _on_add_clicked(self, btn): Gio.Application.get_default().mark_busy() startup_apps = set() self.foreach(lambda row: startup_apps.add(row.app_id) if type(row) is _StartupTweak else None) a = _AppChooser(self.main_window, set(self._get_running_executables()), startup_apps) a.show_all() Gio.Application.get_default().unmark_busy() resp = a.run() if resp == Gtk.ResponseType.OK: df = a.get_selected_app() if df: AutostartFile(df).update_start_at_login(True) sdf = _StartupTweak(df) sdf.btn.connect("clicked", self._on_remove_clicked, sdf, df) self.add_tweak_row(sdf, 0).show_all() a.destroy()
def _on_remove_clicked(self, btn, widget, df): self.remove(widget) AutostartFile(df).update_start_at_login(False)