From 031d0fec99ed471b59723d88b5fde7ef5caf40b6 Mon Sep 17 00:00:00 2001 From: JA Date: Tue, 10 Oct 2023 15:28:59 +0200 Subject: [PATCH 1/6] Gnome 45 support --- README.md | 23 +++---- configure.ac | 2 +- src/Makefile.am | 2 +- src/extension.js | 161 ++++++++++++---------------------------------- src/metadata.json | 2 +- 5 files changed, 55 insertions(+), 135 deletions(-) diff --git a/README.md b/README.md index ff56a04..9d53eeb 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,14 @@ -# GNOME Shell Extension: Super+Tab Launcher +Forked and updated for Gnome Shell 45 from dsboger-zz's awesome original version : +https://github.com/dsboger/gnome-shell-extension-super-tab-launcher -Launch favorite apps from app switcher (i.e. Super+Tab or Alt+Tab) popup. +# GNOME Shell Extension: Alt+Tab Launcher -Git repository: https://github.com/dsboger/gnome-shell-extension-super-tab-launcher +Launch favorite apps from app switcher (i.e. Alt+Tab or Super+Tab) popup. -E.g.o: https://extensions.gnome.org/extension/1133/supertab-launcher/ +Git repository: https://github.com/oxayotl/gnome-shell-extension-alt-tab-launcher -Have you ever tried to switch to an App, hit Super+Tab (or Alt+Tab) and just then + +Have you ever tried to switch to an App, hit Alt+Tab (or Super+Tab) and just then realize the App you sought after is not running? Then you had to cancel the popup, bring the overview and launch the wanted App? This extension aims to streamline the process by adding your (non-running) favorite Apps in the Super+Tab (or Alt+Tab) @@ -15,18 +17,17 @@ launched! ## Notes -- Super+Tab Launcher was tested with GNOME Shell 3.22+ +- Alt+Tab Launcher was tested with GNOME Shell 45 - It may (and probably will) interfere with other extensions that also modify Super+Tab (or Alt+Tab) switcher. This scenario was not tested yet. If you find an incompatibility that you would like to see fixed, please file a bug report! ## Installation -You may simply go to the e.g.o URL above and install the latest, reviewed release -of Super+Tab Launcher. It is also possible to install from the Git repository by -cloning (or downloading a release snapshot) and running the following commands -from the root folder: - +A reviewed release of Alt+Tab Launcher should hopefully become available on +extensions.gnome.org shortly. In the meantime you can install from the Git +repository by cloning (or downloading a release snapshot) and running the +following commands from the root folder: ``` ./autogen.sh diff --git a/configure.ac b/configure.ac index d043599..28f0f96 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ([2.69]) -AC_INIT([GNOME Shell Extension Super+Tab Launcher], [6], [https://github.com/dsboger/gnome-shell-extension-super-tab-launcher/issues], [gnome-shell-extension-super-tab-launcher], [https://github.com/dsboger/gnome-shell-extension-super-tab-launcher]) +AC_INIT([GNOME Shell Extension Alt+Tab Launcher], [6], [https://github.com/oxayotl/gnome-shell-extension-alt-tab-launcher/issues], [gnome-shell-extension-alt-tab-launcher], [https://github.com/oxayotl/gnome-shell-extension-alt-tab-launcher]) AC_CONFIG_SRCDIR([src/extension.js]) AC_CONFIG_AUX_DIR([acaux]) diff --git a/src/Makefile.am b/src/Makefile.am index 5541ced..61a13f4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,2 +1,2 @@ -extensiondir = $(datadir)/gnome-shell/extensions/$(PACKAGE).dsboger@gmail.com +extensiondir = $(datadir)/gnome-shell/extensions/alt-launcher@oxayotl.github.io dist_extension_DATA = $(srcdir)/extension.js $(srcdir)/metadata.json $(srcdir)/stylesheet.css diff --git a/src/extension.js b/src/extension.js index aea868e..4a1f4ec 100644 --- a/src/extension.js +++ b/src/extension.js @@ -1,5 +1,6 @@ /* - * GNOME Shell Extension: Super+Tab Launcher + * GNOME Shell Extension: Alt+Tab Launcher + * Copyright (C) 2023 Jean-Alexandre Anglès d'Auriac * Copyright (C) 2018 Davi da Silva Böger * * This program is free software: you can redistribute it and/or modify @@ -16,10 +17,12 @@ * along with this program. If not, see . */ -const SwitcherPopup = imports.ui.switcherPopup; -const AltTab = imports.ui.altTab; -const AppFavorites = imports.ui.appFavorites; -const Shell = imports.gi.Shell; +import {Extension} from 'resource:///org/gnome/shell/extensions/extension.js'; + +import * as SwitcherPopup from 'resource:///org/gnome/shell/ui/switcherPopup.js'; +import * as AltTab from 'resource:///org/gnome/shell/ui/altTab.js'; +import * as AppFavorites from 'resource:///org/gnome/shell/ui/appFavorites.js'; +import Shell from 'gi://Shell'; function openNewAppWindow(app) { if (app.get_n_windows() == 0) { @@ -36,99 +39,31 @@ function openNewAppWindow(app) { function addLauncherForApp(app, switcher) { let appIcon = new AltTab.AppIcon(app); - if (appIcon.actor) { // compatibility with <= 3.30.1 - appIcon.actor.add_style_class_name('super-tab-launcher'); - appIcon.actor.opacity = 128; // cannot set opacity through CSS? - } else { - appIcon.add_style_class_name('super-tab-launcher'); - appIcon.opacity = 128; // cannot set opacity through CSS? - } - appIcon.cachedWindows = ["Hi, I'm a window!"]; // hack to hide the arrow - switcher._addIcon(appIcon); // TODO add in the right position + appIcon.add_style_class_name('super-tab-launcher'); + appIcon.opacity = 128; // cannot set opacity through CSS? + appIcon.cachedWindows = ["Hi, I'm a window!"]; // hack because switcher._addIcon expects a window + switcher._addIcon(appIcon); appIcon.cachedWindows = []; - // do not remove icon when non-running app stops running... - appIcon.app.disconnect(appIcon._stateChangedId); - // ... but remove when it starts running - appIcon._stateChangedId = appIcon.app.connect('notify::state', app => { - if (app.state == Shell.AppState.RUNNING) { - switcher._removeIcon(app); - } - }); + appIcon.actuallyJustLauncher = true; return appIcon; } -let AppSwitcher_init_orig; -let AppSwitcher_removeIcon_orig; -let AppSwitcherPopup_init_orig; -let AppSwitcherPopup_initialSelection_orig; -let AppSwitcherPopup_select_orig; -let AppSwitcherPopup_finish_orig; - -const AppSwitcher_init_mod = function(apps, altTabPopup) { - AppSwitcher_init_orig.apply(this, [apps, altTabPopup]); - // addedApps may differ from apps if 'current-workspace-only' is set - let addedApps = this.icons.map(function(i) { return i.app; }); +const AppSwitcherPopup_init_mod = function() { + AppSwitcherPopup_init_orig.apply(this, []); let favorites = AppFavorites.getAppFavorites().getFavorites(); + let addedApps = this._switcherList.icons.map(function(i) { return i.app; }); for (let i in favorites) { let favoriteApp = favorites[i]; if (addedApps.indexOf(favoriteApp) < 0) { - addLauncherForApp(favoriteApp, this); + addLauncherForApp(favoriteApp, this._switcherList); } } } -const AppSwitcher_removeIcon_mod = function(app) { - AppSwitcher_removeIcon_orig.apply(this, [app]); - // we may be removing a launcher, so check if app is runnning - if (app.state != Shell.AppState.RUNNING) { - let favorites = AppFavorites.getAppFavorites().getFavorites(); - let favIndex = favorites.indexOf(app); - if (favIndex >= 0) { - let appIcon = addLauncherForApp(app, this); - appIcon.set_size(this._iconSize); - } - } -} - -const AppSwitcherPopup_init_mod = function() { - AppSwitcherPopup_init_orig.apply(this, []); - if (this._switcherList == undefined) { - // we know there are no running apps, as we have no _switcherList - this._switcherList = new AltTab.AppSwitcher([], this); - this._items = this._switcherList.icons; - } -} - -const AppSwitcherPopup_initialSelection_mod = function(backward, binding) { - if (binding == 'switch-applications') { - // favorites are always added after running apps, so if first icon has no windows, - // there are no running apps - if (this._items[0].cachedWindows.length == 0) { - this._select(0); - return; - } - - if (this._items.length > 1 && this._items[1].cachedWindows.length == 0) { - let firstAppHasFocus = false; - for (let window of this._items[0].app.get_windows()) { - if (window.has_focus()) { - firstAppHasFocus = true; - break; - } - } - if (!firstAppHasFocus) { - this._select(0); - return; - } - } - } - AppSwitcherPopup_initialSelection_orig.apply(this, [backward, binding]); -} - const AppSwitcherPopup_select_mod = function(app, window, forceAppFocus) { let appIcon = this._items[app]; - if (appIcon.cachedWindows.length == 0) { + if (appIcon.actuallyJustLauncher) { // force not to show window thumbnails if app has no windows window = null; forceAppFocus = true; @@ -136,10 +71,10 @@ const AppSwitcherPopup_select_mod = function(app, window, forceAppFocus) { AppSwitcherPopup_select_orig.apply(this, [app, window, forceAppFocus]); } + const AppSwitcherPopup_finish_mod = function(timestamp) { let appIcon = this._items[this._selectedIndex]; - if (appIcon.cachedWindows.length == 0) { - // if app has no windows, launch it + if (appIcon.actuallyJustLauncher) { // we do not activate() to respect 'current-workspace-only' setting openNewAppWindow(appIcon.app); SwitcherPopup.SwitcherPopup.prototype._finish.apply(this, [timestamp]); @@ -148,46 +83,30 @@ const AppSwitcherPopup_finish_mod = function(timestamp) { } } -function init(metadata) { -} - -function enable() { - AppSwitcher_init_orig = AltTab.AppSwitcher.prototype._init; - AltTab.AppSwitcher.prototype._init = AppSwitcher_init_mod; - - AppSwitcher_removeIcon_orig = AltTab.AppSwitcher.prototype._removeIcon; - AltTab.AppSwitcher.prototype._removeIcon = AppSwitcher_removeIcon_mod; - - AppSwitcherPopup_init_orig = AltTab.AppSwitcherPopup.prototype._init; - AltTab.AppSwitcherPopup.prototype._init = AppSwitcherPopup_init_mod; - - AppSwitcherPopup_initialSelection_orig = AltTab.AppSwitcherPopup.prototype._initialSelection; - AltTab.AppSwitcherPopup.prototype._initialSelection = AppSwitcherPopup_initialSelection_mod; - - AppSwitcherPopup_select_orig = AltTab.AppSwitcherPopup.prototype._select; - AltTab.AppSwitcherPopup.prototype._select = AppSwitcherPopup_select_mod; - - AppSwitcherPopup_finish_orig = AltTab.AppSwitcherPopup.prototype._finish; - AltTab.AppSwitcherPopup.prototype._finish = AppSwitcherPopup_finish_mod; -} +let AppSwitcherPopup_init_orig; +let AppSwitcherPopup_select_orig; +let AppSwitcherPopup_finish_orig; -function disable() { - AltTab.AppSwitcher.prototype._init = AppSwitcher_init_orig; - AppSwitcher_init_orig = null; +export default class PlainExampleExtension extends Extension { + enable() { + AppSwitcherPopup_init_orig = AltTab.AppSwitcherPopup.prototype._init; + AltTab.AppSwitcherPopup.prototype._init = AppSwitcherPopup_init_mod; - AltTab.AppSwitcher.prototype._removeIcon = AppSwitcher_removeIcon_orig; - AppSwitcher_removeIcon_orig = null; + AppSwitcherPopup_select_orig = AltTab.AppSwitcherPopup.prototype._select; + AltTab.AppSwitcherPopup.prototype._select = AppSwitcherPopup_select_mod; - AltTab.AppSwitcherPopup.prototype._init = AppSwitcherPopup_init_orig; - AppSwitcherPopup_init_orig = null; + AppSwitcherPopup_finish_orig = AltTab.AppSwitcherPopup.prototype._finish; + AltTab.AppSwitcherPopup.prototype._finish = AppSwitcherPopup_finish_mod; + } - AltTab.AppSwitcherPopup.prototype._initialSelection = AppSwitcherPopup_initialSelection_orig; - AppSwitcherPopup_initialSelection_orig = null; + disable() { + AltTab.AppSwitcherPopup.prototype._init = AppSwitcherPopup_init_orig; + AppSwitcherPopup_init_orig = null; - AltTab.AppSwitcherPopup.prototype._select = AppSwitcherPopup_select_orig; - AppSwitcherPopup_select_orig = null; + AltTab.AppSwitcherPopup.prototype._select = AppSwitcherPopup_select_orig; + AppSwitcherPopup_select_orig = null; - AltTab.AppSwitcherPopup.prototype._finish = AppSwitcherPopup_finish_orig; - AppSwitcherPopup_finish_orig = null; + AltTab.AppSwitcherPopup.prototype._finish = AppSwitcherPopup_finish_orig; + AppSwitcherPopup_finish_orig = null; + } } - diff --git a/src/metadata.json b/src/metadata.json index dfba6a1..73f5938 100644 --- a/src/metadata.json +++ b/src/metadata.json @@ -1,5 +1,5 @@ { - "shell-version": ["3.22", "3.24", "3.26", "3.28", "3.30"], + "shell-version": ["45"], "uuid": "gnome-shell-extension-super-tab-launcher.dsboger@gmail.com", "name": "Super+Tab Launcher", "description": "Launch favorite apps from Super+Tab (and Alt+Tab) popup", From 3294232bb996132e00fb6dfea12e34cf639fed15 Mon Sep 17 00:00:00 2001 From: JA Date: Tue, 10 Oct 2023 15:41:18 +0200 Subject: [PATCH 2/6] Gnome 45 support --- src/metadata.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/metadata.json b/src/metadata.json index 73f5938..858fe48 100644 --- a/src/metadata.json +++ b/src/metadata.json @@ -1,8 +1,8 @@ { - "shell-version": ["45"], - "uuid": "gnome-shell-extension-super-tab-launcher.dsboger@gmail.com", - "name": "Super+Tab Launcher", - "description": "Launch favorite apps from Super+Tab (and Alt+Tab) popup", - "url": "https://github.com/dsboger/gnome-shell-extension-super-tab-launcher", - "version": 8 + "name": "Alt+Tab Launcher", + "description": "Launch favorite apps from Alt+Tab (and Super+Tab) popup", + "uuid": "alt-launcher@oxayotl.github.io", + "shell-version": [ + "45" + ] } From 551300c147e681d044ab00bc14625a2f2f89cd12 Mon Sep 17 00:00:00 2001 From: JA Date: Sun, 24 Mar 2024 18:57:32 +0100 Subject: [PATCH 3/6] Add version --- src/metadata.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/metadata.json b/src/metadata.json index 858fe48..239016a 100644 --- a/src/metadata.json +++ b/src/metadata.json @@ -2,7 +2,9 @@ "name": "Alt+Tab Launcher", "description": "Launch favorite apps from Alt+Tab (and Super+Tab) popup", "uuid": "alt-launcher@oxayotl.github.io", + "url": "https://github.com/oxayotl/gnome-shell-extension-alt-tab-launcher", "shell-version": [ "45" - ] + ], + "version": 1 } From 878d39d1decceb865fdf8535670555df1b175deb Mon Sep 17 00:00:00 2001 From: JA Date: Sun, 24 Mar 2024 18:58:55 +0100 Subject: [PATCH 4/6] Support Gnome Shell version 46 --- src/metadata.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/metadata.json b/src/metadata.json index 239016a..cc03d4c 100644 --- a/src/metadata.json +++ b/src/metadata.json @@ -4,7 +4,7 @@ "uuid": "alt-launcher@oxayotl.github.io", "url": "https://github.com/oxayotl/gnome-shell-extension-alt-tab-launcher", "shell-version": [ - "45" + "45", "46" ], - "version": 1 + "version": 2 } From 11b88331f8f75aee87994308368fc94aaf114e89 Mon Sep 17 00:00:00 2001 From: JA Date: Sun, 22 Sep 2024 20:16:49 +0200 Subject: [PATCH 5/6] Cleanup --- Makefile.am | 25 ------------------------- autogen.sh | 3 --- configure.ac | 14 -------------- src/Makefile.am | 2 -- src/metadata.json | 2 +- 5 files changed, 1 insertion(+), 45 deletions(-) delete mode 100644 Makefile.am delete mode 100755 autogen.sh delete mode 100644 configure.ac delete mode 100644 src/Makefile.am diff --git a/Makefile.am b/Makefile.am deleted file mode 100644 index 4002a66..0000000 --- a/Makefile.am +++ /dev/null @@ -1,25 +0,0 @@ -EXTRA_DIST = LICENSE README.md - -SUBDIRS = src - -zip-file: all - rm -rf $(builddir)/{_build,_install,$(PACKAGE).zip}; \ - $(MKDIR_P) $(builddir)/_build; \ - cp -r $(srcdir)/src/*.{js,json,css} $(builddir)/_build; \ - (cd "$(builddir)/_build/"; \ - zip -qr "$(abs_top_builddir)/$(PACKAGE).zip" .; \ - ); \ - rm -rf $(builddir)/{_build,_install}; - -localprefix = $(HOME)/.local/share/gnome-shell/extensions - -localinstall: zip-file - uuid="$(PACKAGE).dsboger@gmail.com"; \ - zip_file="$(abs_top_builddir)/$(PACKAGE).zip"; \ - if [ -d "$(localprefix)/$${uuid}" ]; then \ - rm -fR "$(localprefix)/$${uuid}"; \ - fi; \ - $(MKDIR_P) $(localprefix)/$${uuid}; \ - (cd $(localprefix)/$${uuid}; \ - unzip -q $${zip_file}; \ - ); diff --git a/autogen.sh b/autogen.sh deleted file mode 100755 index afab568..0000000 --- a/autogen.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env sh - -autoreconf --install || exit 1 diff --git a/configure.ac b/configure.ac deleted file mode 100644 index 28f0f96..0000000 --- a/configure.ac +++ /dev/null @@ -1,14 +0,0 @@ -# -*- Autoconf -*- -# Process this file with autoconf to produce a configure script. - -AC_PREREQ([2.69]) -AC_INIT([GNOME Shell Extension Alt+Tab Launcher], [6], [https://github.com/oxayotl/gnome-shell-extension-alt-tab-launcher/issues], [gnome-shell-extension-alt-tab-launcher], [https://github.com/oxayotl/gnome-shell-extension-alt-tab-launcher]) -AC_CONFIG_SRCDIR([src/extension.js]) -AC_CONFIG_AUX_DIR([acaux]) - -# Checks for programs. -AC_PROG_INSTALL - -AM_INIT_AUTOMAKE([1.15 foreign]) -AC_CONFIG_FILES([Makefile src/Makefile]) -AC_OUTPUT diff --git a/src/Makefile.am b/src/Makefile.am deleted file mode 100644 index 61a13f4..0000000 --- a/src/Makefile.am +++ /dev/null @@ -1,2 +0,0 @@ -extensiondir = $(datadir)/gnome-shell/extensions/alt-launcher@oxayotl.github.io -dist_extension_DATA = $(srcdir)/extension.js $(srcdir)/metadata.json $(srcdir)/stylesheet.css diff --git a/src/metadata.json b/src/metadata.json index cc03d4c..696795a 100644 --- a/src/metadata.json +++ b/src/metadata.json @@ -6,5 +6,5 @@ "shell-version": [ "45", "46" ], - "version": 2 + "version": 3 } From 431b15986baccea9217d7b28206c93cad9856568 Mon Sep 17 00:00:00 2001 From: JA Date: Sun, 22 Sep 2024 20:19:30 +0200 Subject: [PATCH 6/6] Update for GS 47 --- README.md | 2 +- src/metadata.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9d53eeb..22acfb1 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -Forked and updated for Gnome Shell 45 from dsboger-zz's awesome original version : +Forked and updated for Gnome Shell 45+ from dsboger-zz's awesome original version : https://github.com/dsboger/gnome-shell-extension-super-tab-launcher # GNOME Shell Extension: Alt+Tab Launcher diff --git a/src/metadata.json b/src/metadata.json index 696795a..deff7f5 100644 --- a/src/metadata.json +++ b/src/metadata.json @@ -4,7 +4,7 @@ "uuid": "alt-launcher@oxayotl.github.io", "url": "https://github.com/oxayotl/gnome-shell-extension-alt-tab-launcher", "shell-version": [ - "45", "46" + "45", "46", "47" ], - "version": 3 + "version": 4 }