[gnome] Fix extension locations

This commit is contained in:
2024-01-23 15:31:15 -05:00
parent 2f029aee37
commit 5ac7107501
331 changed files with 2 additions and 0 deletions

View File

@ -0,0 +1,228 @@
/****************************************************************************
** Auto Activities - Show activities overlay when there are no windows.
** Copyright (C) 2022-2023 Cleo Menezes Jr., 2021 jan Sena <mi-jan-sena@proton.me>
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <https://www.gnu.org/licenses/>.
****************************************************************************/
"use strict";
import * as Main from "resource:///org/gnome/shell/ui/main.js";
import GLib from "gi://GLib";
import GObject from "gi://GObject";
import St from "gi://St";
import Meta from "gi://Meta";
let windowCheckingDelay;
const ignoredWindowTypes = [
Meta.WindowType.DROPDOWN_MENU,
Meta.WindowType.NOTIFICATION,
Meta.WindowType.POPUP_MENU,
Meta.WindowType.SPLASHSCREEN,
];
export const AutoActivitiesManager = GObject.registerClass(
class ActivitiesManager extends St.Bin {
_init({ remoteModel, monitorIndex, settings }) {
this._remoteModel = remoteModel;
this._monitorIndex = monitorIndex;
this._windowRemovedEvents = [];
this._windowAddedEvents = [];
this._settings = settings;
for (let i = 0; i < global.workspace_manager.n_workspaces; i++) {
this._onWorkspaceAdded(global.workspace_manager, i);
}
this._workspaceAddedEvent = global.workspace_manager.connect(
"workspace-added",
this._onWorkspaceAdded.bind(this),
);
this._workspaceRemovedEvent = global.workspace_manager.connect(
"workspace-removed",
this._onWorkspaceRemoved.bind(this),
);
this._workspaceSwitchedEvent = global.workspace_manager.connect(
"workspace-switched",
this._onWorkspaceSwitched.bind(this),
);
this._workspacesReorderedEvent = global.workspace_manager.connect(
"workspaces-reordered",
this._onWorkspacesReordered.bind(this),
);
this._minimizedEvent = global.window_manager.connect(
"minimize",
this._onWindowMinimized.bind(this),
);
}
_onWorkspaceAdded(_sender, workspaceIndex) {
let windowRemovedEvent = global.workspace_manager
.get_workspace_by_index(workspaceIndex)
.connect("window-removed", this._onWindowRemoved.bind(this));
this._windowRemovedEvents.push(windowRemovedEvent);
let windowAddedEvent = global.workspace_manager
.get_workspace_by_index(workspaceIndex)
.connect("window-added", this._onWindowAdded.bind(this));
this._windowAddedEvents.push(windowAddedEvent);
}
_onWorkspaceRemoved(_sender, workspaceIndex) {
if (workspaceIndex < this._windowRemovedEvents.length) {
this._windowRemovedEvents.splice(workspaceIndex);
this._windowAddedEvents.splice(workspaceIndex);
}
}
_onWorkspaceSwitched(
_sender,
_oldWorkspaceIndex,
_newWorkspaceIndex,
_direction,
) {
if (!this._settings.get_boolean("skip-last-workspace")) {
this._checkAndShowOverview();
}
}
_onWorkspacesReordered(_sender) {
let firstWorkspaceIndex = -1;
let secondWorkspaceIndex = -1;
for (let i = 0; i < this._windowRemovedEvents.length; i++) {
if (
GObject.signal_handler_is_connected(
global.workspace_manager.get_workspace_by_index(i),
this._windowRemovedEvents[i],
)
) {
if (firstWorkspaceIndex < 0) firstWorkspaceIndex = i;
else secondWorkspaceIndex = i;
}
}
let tempFirstWorkspaceRemovedEvent =
this._windowRemovedEvents[firstWorkspaceIndex];
this._windowRemovedEvents[firstWorkspaceIndex] =
this._windowRemovedEvents[secondWorkspaceIndex];
this._windowRemovedEvents[secondWorkspaceIndex] =
tempFirstWorkspaceRemovedEvent;
let tempFirstWorkspaceAddedEvent =
this._windowAddedEvents[firstWorkspaceIndex];
this._windowAddedEvents[firstWorkspaceIndex] =
this._windowAddedEvents[secondWorkspaceIndex];
this._windowAddedEvents[secondWorkspaceIndex] =
tempFirstWorkspaceAddedEvent;
}
_onWindowMinimized(_sender, actor) {
if (
this._settings.get_boolean("detect-minimized") &&
!ignoredWindowTypes.includes(actor.meta_window.get_window_type())
) {
this._checkAndShowOverview();
}
}
_onWindowRemoved(_sender, removedWindow) {
if (!ignoredWindowTypes.includes(removedWindow.get_window_type())) {
this._checkAndShowOverview();
}
}
_onWindowAdded(_sender, addedWindow) {
if (
!ignoredWindowTypes.includes(addedWindow.get_window_type()) &&
this._settings.get_boolean("hide-on-new-window")
) {
if (Main.overview.visible) Main.overview.hide();
}
}
_checkAndShowOverview() {
let delay = 0;
let delaySetting = this._settings.get_int("window-checking-delay");
if (!isNaN(delaySetting) && delaySetting > 0) delay = delaySetting;
windowCheckingDelay = GLib.timeout_add(
GLib.PRIORITY_DEFAULT,
delay,
() => {
let windows = global.get_window_actors();
if (this._settings.get_boolean("isolate-workspaces")) {
windows = windows.filter(
(window) =>
window.meta_window.get_workspace().index() ===
global.workspace_manager.get_active_workspace().index(),
);
}
if (this._settings.get_boolean("isolate-monitors")) {
windows = windows.filter(
(window) =>
window.meta_window.get_monitor() === this._monitorIndex,
);
}
if (this._settings.get_boolean("skip-taskbar")) {
windows = windows.filter(
(window) => !window.meta_window.skip_taskbar,
);
}
if (this._settings.get_boolean("detect-minimized")) {
windows = windows.filter((window) => !window.meta_window.minimized);
}
if (windows.length < 1) {
if (this._settings.get_boolean("show-apps")) {
Main.overview
.showApps();
} else Main.overview.show();
}
},
);
}
destroy() {
global.workspace_manager.disconnect(this._workspaceAddedEvent);
global.workspace_manager.disconnect(this._workspaceRemovedEvent);
global.workspace_manager.disconnect(this._workspaceSwitchedEvent);
global.workspace_manager.disconnect(this._workspacesReorderedEvent);
global.window_manager.disconnect(this._minimizedEvent);
for (let i = 0; i < this._windowRemovedEvents.length; i++) {
if (
GObject.signal_handler_is_connected(
global.workspace_manager.get_workspace_by_index(i),
this._windowRemovedEvents[i],
)
) {
global.workspace_manager
.get_workspace_by_index(i)
.disconnect(this._windowRemovedEvents[i]);
}
}
for (let i = 0; i < this._windowAddedEvents.length; i++) {
if (
GObject.signal_handler_is_connected(
global.workspace_manager.get_workspace_by_index(i),
this._windowAddedEvents[i],
)
) {
global.workspace_manager
.get_workspace_by_index(i)
.disconnect(this._windowAddedEvents[i]);
}
}
GLib.Source.remove(windowCheckingDelay);
}
},
);

View File

@ -0,0 +1,36 @@
/****************************************************************************
** Auto Activities - Show activities overlay when there are no windows.
** Copyright (C) 2022-2023 Cleo Menezes Jr., 2021 jan Sena <mi-jan-sena@proton.me>
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <https://www.gnu.org/licenses/>.
****************************************************************************/
"use strict";
import { Extension } from "resource:///org/gnome/shell/extensions/extension.js";
import { AutoActivitiesManager } from "./autoActivities.js";
export default class AutoActivities extends Extension {
enable() {
this._settings = this.getSettings();
this._autoActivities = new AutoActivitiesManager({
settings: this._settings,
});
}
disable() {
this._autoActivities.destroy();
this._autoActivities = null;
this._settings = null;
}
}

View File

@ -0,0 +1,19 @@
{
"_generated": "Generated by SweetTooth, do not edit",
"description": "Show activities overview when there are no windows, or hide it when there are new windows.\n\nThis extension is a fork of the Auto Activities extension, its former owner transferred its repository to me.",
"donations": {
"github": "CleoMenezesJr",
"kofi": "cleomenezesjr",
"paypal": "CleoMenezesJr"
},
"gettext-domain": "auto-activities",
"name": "Auto Activities",
"original-author": "mi-jan-sena@proton.me",
"settings-schema": "org.gnome.shell.extensions.auto-activities",
"shell-version": [
"45"
],
"url": "https://github.com/CleoMenezesJr/auto-activities",
"uuid": "auto-activities@CleoMenezesJr.github.io",
"version": 12
}

View File

@ -0,0 +1,119 @@
/****************************************************************************
** Auto Activities - Show activities overlay when there are no windows.
** Copyright (C) 2021 jan Sena <mi-jan-sena@proton.me> and Cleo Menezes Jr.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <https://www.gnu.org/licenses/>.
****************************************************************************/
"use strict";
import Gtk from "gi://Gtk";
import Gio from "gi://Gio";
import { ExtensionPreferences } from "resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js";
export default class MyExtensionPreferences extends ExtensionPreferences {
fillPreferencesWindow(window) {
window._settings = this.getSettings();
window.set_default_size(360, 724);
const builder = new Gtk.Builder();
builder.add_from_file(`${this.path}/prefs.ui`);
const isolateWorkspaces = builder.get_object("IsolateWorkspacesSwitch");
isolateWorkspaces.set_active(
window._settings.get_boolean("isolate-workspaces"),
);
window._settings.bind(
"isolate-workspaces",
isolateWorkspaces,
"active",
Gio.SettingsBindFlags.DEFAULT,
);
const isolateMonitors = builder.get_object("IsolateMonitorsSwitch");
isolateMonitors.set_active(
window._settings.get_boolean("isolate-monitors"),
);
window._settings.bind(
"isolate-monitors",
isolateMonitors,
"active",
Gio.SettingsBindFlags.DEFAULT,
);
const skipTaskbar = builder.get_object("SkipTaskbarSwitch");
skipTaskbar.set_active(window._settings.get_boolean("skip-taskbar"));
window._settings.bind(
"skip-taskbar",
skipTaskbar,
"active",
Gio.SettingsBindFlags.DEFAULT,
);
const skipLastWorkspace = builder.get_object("SkipLastWorkspaceSwitch");
skipLastWorkspace.set_active(
window._settings.get_boolean("skip-last-workspace"),
);
window._settings.bind(
"skip-last-workspace",
skipLastWorkspace,
"active",
Gio.SettingsBindFlags.DEFAULT,
);
const detectMinimized = builder.get_object("MinimizedSwitch");
detectMinimized.set_active(
window._settings.get_boolean("detect-minimized"),
);
window._settings.bind(
"detect-minimized",
detectMinimized,
"active",
Gio.SettingsBindFlags.DEFAULT,
);
const hideOnNewWindow = builder.get_object("HideOnNewWindowSwitch");
hideOnNewWindow.set_active(
window._settings.get_boolean("hide-on-new-window"),
);
window._settings.bind(
"hide-on-new-window",
hideOnNewWindow,
"active",
Gio.SettingsBindFlags.DEFAULT,
);
const checkingDelay = builder.get_object("CheckingDelayEntry");
checkingDelay.set_value(
window._settings.get_int("window-checking-delay"),
);
window._settings.bind(
"window-checking-delay",
checkingDelay,
"value",
Gio.SettingsBindFlags.DEFAULT,
);
const showApps = builder.get_object("ShowAppsSwitch");
showApps.set_active(window._settings.get_boolean("show-apps"));
window._settings.bind(
"show-apps",
showApps,
"active",
Gio.SettingsBindFlags.DEFAULT,
);
const page = builder.get_object("MainWidget");
window.add(page);
}
}

View File

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface domain="auto-activities">
<object class="AdwPreferencesPage" id="MainWidget">
<property name="title" translatable="yes">Preferences</property>
<child>
<object class="AdwPreferencesGroup">
<property name="title" translatable="yes">General</property>
<child>
<object class="AdwActionRow">
<property name="title" translatable="yes">Detect Hidden Windows</property>
<property name="activatable-widget">MinimizedSwitch</property>
<child>
<object class="GtkSwitch" id="MinimizedSwitch">
<property name="valign">center</property>
<property name="active">True</property>
</object>
</child>
</object>
</child>
<child>
<object class="AdwActionRow">
<property name="title" translatable="yes">Always Hide on New Window</property>
<property name="activatable-widget">HideOnNewWindowSwitch</property>
<child>
<object class="GtkSwitch" id="HideOnNewWindowSwitch">
<property name="valign">center</property>
<property name="active">True</property>
</object>
</child>
</object>
</child>
<child>
<object class="AdwSpinRow">
<property name="title" translatable="yes">Window Checking Delay</property>
<property name="subtitle" translatable="yes">milliseconds</property>
<property name="adjustment">
<object class="GtkAdjustment" id="CheckingDelayEntry">
<property name="lower">0</property>
<property name="upper">10000</property>
<property name="value">0</property>
<property name="page-increment">10</property>
<property name="step-increment">10</property>
</object>
</property>
</object>
</child>
</object>
</child>
<child>
<object class="AdwPreferencesGroup">
<child>
<object class="AdwActionRow">
<property name="title" translatable="yes">Show App Grid Instead of Overview</property>
<property name="activatable-widget">ShowAppsSwitch</property>
<child>
<object class="GtkSwitch" id="ShowAppsSwitch">
<property name="valign">center</property>
<property name="active">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="AdwPreferencesGroup">
<property name="title" translatable="yes">Isolate</property>
<child>
<object class="AdwActionRow">
<property name="title" translatable="yes">Workspaces</property>
<property name="activatable-widget">IsolateWorkspacesSwitch</property>
<child>
<object class="GtkSwitch" id="IsolateWorkspacesSwitch">
<property name="valign">center</property>
<property name="active">True</property>
</object>
</child>
</object>
</child>
<child>
<object class="AdwActionRow">
<property name="title" translatable="yes">Monitors</property>
<property name="activatable-widget">IsolateMonitorsSwitch</property>
<child>
<object class="GtkSwitch" id="IsolateMonitorsSwitch">
<property name="valign">center</property>
<property name="active">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="AdwPreferencesGroup">
<property name="title" translatable="yes">Ignore</property>
<child>
<object class="AdwActionRow">
<property name="title" translatable="yes">Taskbar Window</property>
<property name="activatable-widget">SkipTaskbarSwitch</property>
<child>
<object class="GtkSwitch" id="SkipTaskbarSwitch">
<property name="valign">center</property>
<property name="active">True</property>
</object>
</child>
</object>
</child>
<child>
<object class="AdwActionRow">
<property name="title" translatable="yes">Last Workspace</property>
<property name="activatable-widget">SkipLastWorkspaceSwitch</property>
<child>
<object class="GtkSwitch" id="SkipLastWorkspaceSwitch">
<property name="valign">center</property>
<property name="active">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</interface>

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<schemalist>
<schema id="org.gnome.shell.extensions.auto-activities" path="/org/gnome/shell/extensions/auto-activities/">
<key name="isolate-workspaces" type="b">
<default>true</default>
</key>
<key name="isolate-monitors" type="b">
<default>false</default>
</key>
<key name="skip-taskbar" type="b">
<default>true</default>
</key>
<key name="skip-last-workspace" type="b">
<default>true</default>
</key>
<key name="detect-minimized" type="b">
<default>false</default>
</key>
<key name="hide-on-new-window" type="b">
<default>true</default>
</key>
<key name="window-checking-delay" type="i">
<default>100</default>
</key>
<key name="show-apps" type="b">
<default>false</default>
</key>
</schema>
</schemalist>