diff --git a/close-in-switcher@Sarthak-Raghav/README.md b/close-in-switcher@Sarthak-Raghav/README.md new file mode 100644 index 00000000..6129e82c --- /dev/null +++ b/close-in-switcher@Sarthak-Raghav/README.md @@ -0,0 +1,11 @@ +# Close in Switcher + +Press **Delete** while the Alt-Tab window switcher is open to close the +highlighted window. The switcher stays open, so you can close several +windows in one Alt-Tab hold. + +Restores behaviour familiar from Windows. + +Tested on Cinnamon 6.6. + +![demo](demo.gif) diff --git a/close-in-switcher@Sarthak-Raghav/demo.gif b/close-in-switcher@Sarthak-Raghav/demo.gif new file mode 100644 index 00000000..6cc7bfd7 Binary files /dev/null and b/close-in-switcher@Sarthak-Raghav/demo.gif differ diff --git a/close-in-switcher@Sarthak-Raghav/files/close-in-switcher@Sarthak-Raghav/extension.js b/close-in-switcher@Sarthak-Raghav/files/close-in-switcher@Sarthak-Raghav/extension.js new file mode 100644 index 00000000..f90bf042 --- /dev/null +++ b/close-in-switcher@Sarthak-Raghav/files/close-in-switcher@Sarthak-Raghav/extension.js @@ -0,0 +1,36 @@ +const AppSwitcherMod = imports.ui.appSwitcher.appSwitcher; +const Clutter = imports.gi.Clutter; + +let _orig = null; + +function init(metadata) {} + +function enable() { + if (!AppSwitcherMod.AppSwitcher || + !AppSwitcherMod.AppSwitcher.prototype || + !AppSwitcherMod.AppSwitcher.prototype._keyPressEvent) { + global.logError("close-in-switcher: incompatible Cinnamon version, not enabling"); + return; + } + + _orig = AppSwitcherMod.AppSwitcher.prototype._keyPressEvent; + + AppSwitcherMod.AppSwitcher.prototype._keyPressEvent = function(actor, event) { + if (event.get_key_symbol() === Clutter.KEY_Delete) { + let win = this._windows && this._windows[this._currentIndex]; + if (win) { + global.log("CloseInSwitcher: closing " + win.get_title()); + win.delete(event.get_time()); + } + return true; + } + return _orig.call(this, actor, event); + }; +} + +function disable() { + if (_orig) { + AppSwitcherMod.AppSwitcher.prototype._keyPressEvent = _orig; + _orig = null; + } +} diff --git a/close-in-switcher@Sarthak-Raghav/files/close-in-switcher@Sarthak-Raghav/icon.png b/close-in-switcher@Sarthak-Raghav/files/close-in-switcher@Sarthak-Raghav/icon.png new file mode 100644 index 00000000..e89ed2ea Binary files /dev/null and b/close-in-switcher@Sarthak-Raghav/files/close-in-switcher@Sarthak-Raghav/icon.png differ diff --git a/close-in-switcher@Sarthak-Raghav/files/close-in-switcher@Sarthak-Raghav/metadata.json b/close-in-switcher@Sarthak-Raghav/files/close-in-switcher@Sarthak-Raghav/metadata.json new file mode 100644 index 00000000..c8c0d151 --- /dev/null +++ b/close-in-switcher@Sarthak-Raghav/files/close-in-switcher@Sarthak-Raghav/metadata.json @@ -0,0 +1,9 @@ +{ + "uuid": "close-in-switcher@Sarthak-Raghav", + "name": "Close in Switcher", + "description": "Press Delete in the Alt-Tab switcher to close the highlighted window.", + "version": "1.0.0", + "url": "https://github.com/Sarthak-Raghav/close-in-switcher", + "author": "Sarthak-Raghav", + "cinnamon-version": ["6.6"] +} diff --git a/close-in-switcher@Sarthak-Raghav/info.json b/close-in-switcher@Sarthak-Raghav/info.json new file mode 100644 index 00000000..ba2eb27c --- /dev/null +++ b/close-in-switcher@Sarthak-Raghav/info.json @@ -0,0 +1,5 @@ +{ + "author": "Sarthak-Raghav", + "name": "Close in Switcher", + "description": "Press Delete in the Alt-Tab switcher to close the highlighted window." +} diff --git a/close-in-switcher@Sarthak-Raghav/screenshot.png b/close-in-switcher@Sarthak-Raghav/screenshot.png new file mode 100644 index 00000000..88fa8ce1 Binary files /dev/null and b/close-in-switcher@Sarthak-Raghav/screenshot.png differ