// CoreDesktop: a top bar menu for CoreDesktop's own commands (update, refresh, // configure, version, audit, report), showing what each does and how it's going. import Clutter from 'gi://Clutter'; import Gio from 'gi://Gio'; import GLib from 'gi://GLib'; import GObject from 'gi://GObject'; import St from 'gi://St'; import {Extension} from 'resource:///org/gnome/shell/extensions/extension.js'; import * as Main from 'resource:///org/gnome/shell/ui/main.js'; import * as MessageTray from 'resource:///org/gnome/shell/ui/messageTray.js'; import * as PanelMenu from 'resource:///org/gnome/shell/ui/panelMenu.js'; import * as PopupMenu from 'resource:///org/gnome/shell/ui/popupMenu.js'; import * as Cli from './lib/cli.js'; import {ConfigureDialog, ConfirmDialog, SiblingsDialog, VersionDialog} from './lib/dialogs.js'; // What each command is called, what it does in a few words, and its icon const COMMANDS = { update: { title: 'Update', description: 'Get the latest CoreDesktop, system packages, apps and extensions', icon: 'software-update-available-symbolic', argv: ['update'], }, refresh: { title: 'Refresh', description: 'Re-run the installer to add apps and services new to CoreDesktop', icon: 'view-refresh-symbolic', argv: ['refresh'], }, configure: { title: 'Configure', description: 'Set up your Core, Tailscale, backups, AI agents and more', icon: 'preferences-system-symbolic', argv: ['configure'], }, version: { title: 'Version', description: 'See your CoreDesktop, kernel, video driver and sibling versions', icon: 'help-about-symbolic', }, audit: { title: 'Network audit', description: 'See which ports are open, who can reach them, and why', icon: 'security-high-symbolic', argv: ['audit'], }, report: { title: 'Report a problem', description: 'Send the latest update log to the CoreDesktop team', icon: 'mail-send-symbolic', argv: ['report'], }, }; // Runs that change the system, so only one may run at a time. `sibling update` // runs as "siblings" for all of them, or "sibling-" for one. function changesSystem(name) { return name === 'update' || name === 'refresh' || name === 'siblings' || name.startsWith('sibling-'); } // Icons for configure's items, by name const CONFIGURE_ICONS = { 'core': 'network-server-symbolic', 'tailscale': 'network-vpn-symbolic', 'backup': 'drive-harddisk-symbolic', 'claude': 'utilities-terminal-symbolic', 'opencode': 'utilities-terminal-symbolic', 'hermes': 'utilities-terminal-symbolic', 'languages': 'applications-engineering-symbolic', 'ai-servers': 'network-workgroup-symbolic', 'printers': 'printer-symbolic', 'storage': 'folder-remote-symbolic', 'sandbox': 'security-medium-symbolic', 'security-key': 'auth-smartcard-symbolic', 'fingerprint': 'auth-fingerprint-symbolic', }; // A pill-shaped label at the end of a menu item: "New", "Running…", "To do" const Pill = GObject.registerClass( class Pill extends St.Label { _init() { super._init({style_class: 'coredesktop-pill', y_align: Clutter.ActorAlign.CENTER, visible: false}); } // kind: accent, success, warning, error, running, or null to hide. (Not // named set(): that would override GObject.Object.set, which ease() uses.) setState(text, kind) { this.remove_all_transitions(); this.opacity = 255; if (!text) { this.hide(); return; } this.text = text; for (const k of ['accent', 'success', 'warning', 'error', 'running']) this.remove_style_class_name(k); this.add_style_class_name(kind); this.show(); if (kind === 'running') { this.ease({ opacity: 110, duration: 800, autoReverse: true, repeatCount: -1, mode: Clutter.AnimationMode.EASE_IN_OUT_SINE, }); } } }); // A menu item with an icon, a title, a line saying what it does, and a pill const ActionItem = GObject.registerClass({ Signals: {'keep-open-activate': {}}, }, class ActionItem extends PopupMenu.PopupBaseMenuItem { _init({icon, title, description, keepOpen = false}) { super._init({style_class: 'coredesktop-action-item'}); this._keepOpen = keepOpen; this.icon = new St.Icon({icon_name: icon, style_class: 'popup-menu-icon coredesktop-action-icon'}); this.add_child(this.icon); const text = new St.BoxLayout({ orientation: Clutter.Orientation.VERTICAL, x_expand: true, y_align: Clutter.ActorAlign.CENTER, }); this.title = new St.Label({text: title, style_class: 'coredesktop-item-title'}); this.description = new St.Label({text: description, style_class: 'coredesktop-item-description'}); text.add_child(this.title); text.add_child(this.description); this.add_child(text); this.label_actor = this.title; this.pill = new Pill(); this.add_child(this.pill); } // Items that only refresh what the menu shows leave it open activate(event) { if (this._keepOpen) this.emit('keep-open-activate'); else super.activate(event); } }); // The status at the top of the menu: logo, version, and how things stand const HeaderItem = GObject.registerClass( class HeaderItem extends PopupMenu.PopupBaseMenuItem { _init(gicon) { super._init({reactive: false, can_focus: false, style_class: 'coredesktop-header'}); this.add_child(new St.Icon({gicon, style_class: 'coredesktop-header-icon'})); const text = new St.BoxLayout({ orientation: Clutter.Orientation.VERTICAL, x_expand: true, y_align: Clutter.ActorAlign.CENTER, }); text.add_child(new St.Label({text: 'CoreDesktop', style_class: 'coredesktop-header-title'})); this.versionLabel = new St.Label({text: '…', style_class: 'coredesktop-header-version'}); this.statusLabel = new St.Label({text: '', style_class: 'coredesktop-header-status'}); text.add_child(this.versionLabel); text.add_child(this.statusLabel); this.add_child(text); } setStatus(text, kind) { this.statusLabel.text = text; for (const k of ['accent', 'success', 'warning', 'error']) this.statusLabel.remove_style_class_name(k); if (kind) this.statusLabel.add_style_class_name(kind); } }); const Indicator = GObject.registerClass( class Indicator extends PanelMenu.Button { _init(ext) { super._init(0.5, 'CoreDesktop', false); this._ext = ext; this._settings = ext.getSettings(); this._gicon = Gio.FileIcon.new(Gio.File.new_for_path( GLib.build_filenamev([ext.path, 'icons', 'coredesktop-symbolic.svg']))); this._update = {state: 'unknown', version: null, checkedAt: null}; this._running = new Map(); // status name -> pid, 0 until run-tracked starts this._launchedAt = new Map(); // status name -> monotonic time it was launched this._titles = new Map(); // status name -> title for notifications this._rebootNeeded = false; this._configureTodo = 0; this._siblingNames = []; // installed, from disk this._siblings = null; // the last `sibling check`, or null before one this._checkCancellable = null; this._timeouts = new Set(); this._buildPanelIcon(); this._buildMenu(); this._settings.connectObject( 'changed::check-interval', () => this._scheduleChecks(), 'changed::show-badge', () => this._updateIndicator(), this); this.menu.connect('open-state-changed', (_menu, open) => { if (open) this._refreshLocal(); }); this._watchStatusDir(); this._refreshLocal(); this._scheduleChecks(); } // Top bar: the logo, with a dot in its corner when something needs attention _buildPanelIcon() { // The dot overlaps the icon's top right corner: both sit in a bin the // icon's size, the dot aligned to its corner const box = new St.Widget({ layout_manager: new Clutter.BinLayout(), x_align: Clutter.ActorAlign.CENTER, y_align: Clutter.ActorAlign.CENTER, }); this._panelIcon = new St.Icon({gicon: this._gicon, style_class: 'system-status-icon'}); this._badge = new St.Widget({ style_class: 'coredesktop-badge', x_align: Clutter.ActorAlign.END, y_align: Clutter.ActorAlign.START, visible: false, }); box.add_child(this._panelIcon); box.add_child(this._badge); this.add_child(box); } _buildMenu() { this.menu.box.add_style_class_name('coredesktop-menu'); this._header = new HeaderItem(this._gicon); this.menu.addMenuItem(this._header); // Shown only when an update needs a restart to finish this._rebootItem = new ActionItem({ icon: 'system-reboot-symbolic', title: 'Restart to finish updating', description: 'An update changed the kernel or system services', }); this._rebootItem.add_style_class_name('coredesktop-attention'); this._rebootItem.pill.setState('Restart', 'warning'); this._rebootItem.connect('activate', () => this._restart()); this.menu.addMenuItem(this._rebootItem); this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem('Keep up to date')); this._items = {}; this._items.update = this._addCommand('update'); this._items.refresh = this._addCommand('refresh'); // Shown only when there are sibling projects this._siblingsItem = new ActionItem({ icon: 'application-x-addon-symbolic', title: 'Sibling projects', description: '', }); this._siblingsItem.visible = false; this._siblingsItem.connect('activate', () => this._openSiblings()); this.menu.addMenuItem(this._siblingsItem); this._checkItem = new ActionItem({ icon: 'system-search-symbolic', title: 'Check for updates', description: 'Not checked yet', keepOpen: true, }); this._checkItem.connect('keep-open-activate', () => this._checkNow()); this.menu.addMenuItem(this._checkItem); this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem('Set up')); this._items.configure = new ActionItem(COMMANDS.configure); this._items.configure.connect('activate', () => this._openConfigure()); this.menu.addMenuItem(this._items.configure); this._configureItems = []; this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem('Information')); this._items.version = this._addCommand('version'); this._items.audit = this._addCommand('audit'); this._items.report = this._addCommand('report'); this._logItem = new ActionItem({ icon: 'text-x-generic-symbolic', title: 'Latest update log', description: 'Open the output of the last update or install', }); this._logItem.connect('activate', () => this._openLatestLog()); this.menu.addMenuItem(this._logItem); this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem()); const prefs = new PopupMenu.PopupImageMenuItem('Extension settings', 'emblem-system-symbolic'); prefs.connect('activate', () => this._ext.openPreferences()); this.menu.addMenuItem(prefs); } _addCommand(key) { const cmd = COMMANDS[key]; const item = new ActionItem(cmd); item.connect('activate', () => this._runCommand(key)); this.menu.addMenuItem(item); return item; } _openConfigure() { const items = this._configureItems.map(item => ({ ...item, icon: CONFIGURE_ICONS[item.name] ?? 'emblem-system-symbolic', running: this._running.has(`configure-${item.name}`), })); new ConfigureDialog({ items, onConfigure: item => this._runTracked(`configure-${item.name}`, item.title, ['configure', item.name]), onOpenAll: () => this._runCommand('configure'), }).open(); } _openSiblings() { // Until the first check, list what's installed with nothing known about it const known = this._siblings ?? this._siblingNames.map(name => ({name, installed: '', modified: false, state: 'unknown', available: null})); new SiblingsDialog({ siblings: known, isRunning: name => this._running.has('update') || this._running.has('siblings') || this._running.has(`sibling-${name}`), onChecked: siblings => { this._siblings = siblings; this._updateIndicator(); }, onUpdate: name => this._runTracked(`sibling-${name}`, `Update ${name}`, ['sibling', 'update', name]), onUpdateAll: () => this._runTracked('siblings', 'Update sibling projects', ['sibling', 'update']), }).open(); } // Everything that can be read locally without the network async _refreshLocal() { const version = await Cli.localVersion(); if (!this._header) return; this._header.versionLabel.text = version ?? (Cli.isInstalled() ? 'Version unknown' : 'CoreDesktop isn\'t installed'); this._rebootNeeded = GLib.file_test(Cli.REBOOT_NEEDED, GLib.FileTest.EXISTS); this._lastUpdate = Cli.mtime(Cli.PACMAN_UPDATE_LOG); const names = await Cli.installedSiblings(); if (!this._header) return; this._siblingNames = names; // Forget removed siblings; ones added since the last check show at the next if (this._siblings) this._siblings = this._siblings.filter(s => names.includes(s.name)); try { const items = await Cli.configureItems(); if (!this._header) return; this._configureItems = items; this._configureTodo = items.filter(i => !i.done).length; } catch (e) { console.warn(`CoreDesktop: couldn't list configure items: ${e.message}`); } this._updateIndicator(); } _scheduleChecks() { if (this._checkTimeout) { GLib.source_remove(this._checkTimeout); this._timeouts.delete(this._checkTimeout); this._checkTimeout = 0; } const hours = this._settings.get_uint('check-interval'); if (hours === 0) return; // A first check soon after login, then every few hours const first = this._update.checkedAt ? hours * 3600 : 45; this._checkTimeout = this._addTimeout(first, () => { this._checkTimeout = 0; this._checkNow().finally(() => this._scheduleChecks()); }); } async _checkNow() { if (this._checkCancellable) return; const cancellable = this._checkCancellable = new Gio.Cancellable(); this._checkItem.pill.setState('Checking…', 'running'); try { const [result] = await Promise.all([ Cli.checkForUpdate(cancellable), this._checkSiblings(cancellable), ]); this._update = {...result, checkedAt: GLib.get_real_time() / 1e6}; } catch { return; // cancelled: the extension is being disabled } finally { this._checkCancellable = null; } this._checkItem.pill.setState(null); this._updateIndicator(); } // Look for newer versions of the sibling projects. Keeps the last result // if sibling can't run; throws only when cancelled. async _checkSiblings(cancellable) { this._siblingNames = await Cli.installedSiblings(); if (this._siblingNames.length === 0) { this._siblings = []; return; } try { this._siblings = await Cli.checkSiblings(cancellable); } catch (e) { if (e.matches?.(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED)) throw e; console.warn(`CoreDesktop: couldn't check sibling projects: ${e.message}`); } } // Bring the menu, header and top bar icon in line with what's known _updateIndicator() { if (!this._header) return; const {state, version, checkedAt} = this._update; const running = [...this._running.keys()]; const updating = this._running.has('update') || this._running.has('refresh'); const siblings = this._siblings ?? []; const newerSiblings = siblings.filter(s => s.state === 'available').length; const somethingNewer = state === 'available' || newerSiblings > 0; // Header status line if (this._running.has('update')) this._header.setStatus('Updating…', 'accent'); else if (this._running.has('refresh')) this._header.setStatus('Refreshing…', 'accent'); else if (this._rebootNeeded) this._header.setStatus('Restart to finish the last update', 'warning'); else if (state === 'available') this._header.setStatus(`${version} is available`, 'accent'); else if (state === 'current' && newerSiblings > 0) this._header.setStatus(newerSiblings === 1 ? 'A sibling project has a newer version' : `${newerSiblings} sibling projects have newer versions`, 'accent'); else if (state === 'current') this._header.setStatus('Up to date', 'success'); else if (checkedAt) this._header.setStatus('Couldn\'t check for updates', 'warning'); else this._header.setStatus(this._lastUpdate ? `Last updated ${Cli.timeAgo(this._lastUpdate)}` : 'Never updated', null); // Check item: when it last looked this._checkItem.description.text = checkedAt ? `Last checked ${Cli.timeAgo(checkedAt)}${this._lastUpdate ? ` · last updated ${Cli.timeAgo(this._lastUpdate)}` : ''}` : 'See whether a newer CoreDesktop or sibling project is out'; this._rebootItem.visible = this._rebootNeeded && !updating; this._updateSiblingsItem(running); // Pills on the commands const configuring = running.some(k => k === 'configure' || k.startsWith('configure-')); for (const [key, item] of Object.entries(this._items)) { if (this._running.has(key) || (key === 'configure' && configuring)) item.pill.setState('Running…', 'running'); else if (key === 'update' && somethingNewer) item.pill.setState('New version', 'accent'); else if (key === 'configure' && this._configureTodo > 0) item.pill.setState(`${this._configureTodo} to do`, 'warning'); else if (key === 'configure' && this._configureItems.length > 0) item.pill.setState('All set', 'success'); else item.pill.setState(null); } // Top bar: pulse while updating, dot for an update or restart this._panelIcon.remove_all_transitions(); this._panelIcon.opacity = 255; if (updating) { this._panelIcon.ease({ opacity: 90, duration: 900, autoReverse: true, repeatCount: -1, mode: Clutter.AnimationMode.EASE_IN_OUT_SINE, }); } const badge = this._settings.get_boolean('show-badge') && !updating && (this._rebootNeeded || somethingNewer); this._badge.visible = badge; this._badge.remove_style_class_name('warning'); if (this._rebootNeeded) this._badge.add_style_class_name('warning'); let accessible = 'CoreDesktop'; if (updating) accessible += ', updating'; else if (this._rebootNeeded) accessible += ', restart needed'; else if (somethingNewer) accessible += ', update available'; this.accessible_name = accessible; } // The Sibling projects item: how many, and whether any is newer _updateSiblingsItem(running) { const count = this._siblingNames.length; this._siblingsItem.visible = count > 0; if (count === 0) return; const siblings = this._siblings ?? []; const newer = siblings.filter(s => s.state === 'available'); const unknown = siblings.filter(s => s.state === 'unknown').length; let description; if (newer.length > 0) description = `Newer: ${newer.map(s => s.name).join(', ')}`; else if (!this._siblings) description = `${count} installed`; else if (unknown > 0) description = `${count} installed, couldn't check ${unknown}`; else description = count === 1 ? '1 installed, up to date' : `${count} installed, all up to date`; this._siblingsItem.description.text = description; if (running.some(k => k === 'update' || k === 'siblings' || k.startsWith('sibling-'))) this._siblingsItem.pill.setState('Running…', 'running'); else if (newer.length > 0) this._siblingsItem.pill.setState(newer.length === 1 ? '1 new' : `${newer.length} new`, 'accent'); else this._siblingsItem.pill.setState(null); } _runCommand(key) { if (key === 'version') { new VersionDialog({onUpdate: () => this._runCommand('update')}).open(); return; } if (key === 'refresh' && this._settings.get_boolean('confirm-refresh')) { new ConfirmDialog({ title: 'Refresh CoreDesktop?', description: 'Refresh runs CoreDesktop\'s installer again, so you get apps and services added since you installed.', details: [ ['folder-download-symbolic', 'Downloads the latest CoreDesktop'], ['system-software-install-symbolic', 'Installs anything new, and re-applies CoreDesktop\'s setup'], ['dialog-password-symbolic', 'Asks for your password, and can take several minutes'], ['software-update-available-symbolic', 'Run Update afterwards to bring everything up to date'], ], confirmLabel: 'Refresh', onConfirm: () => this._runTracked('refresh', 'Refresh', COMMANDS.refresh.argv), }).open(); return; } const cmd = COMMANDS[key]; this._runTracked(key, cmd.title, cmd.argv); } // Run argv in a terminal, tracked under `name` _runTracked(name, title, argv) { if (this._running.has(name)) { this._notify(`${title} is already running`, 'Look for its terminal window.'); return; } if (changesSystem(name) && [...this._running.keys()].some(changesSystem)) { this._notify('Wait for the current run to finish', 'Update, refresh and sibling updates all change the system, so run one at a time.'); return; } const ok = Cli.runInTerminal(this._ext.path, this._settings.get_string('terminal'), name, [Cli.bin(argv[0]), ...argv.slice(1)]); if (!ok) { this._notify('No terminal found', `Install a terminal, or open one and run: ${argv.join(' ')}`, 'error'); return; } // Shown as running right away; the status file confirms it shortly this._titles.set(name, title); this._running.set(name, 0); this._launchedAt.set(name, GLib.get_monotonic_time()); this._updateIndicator(); this._pollWhileRunning(); } // run-tracked writes .status files: "running " or "exit " _watchStatusDir() { GLib.mkdir_with_parents(Cli.STATUS_DIR, 0o700); const dir = Gio.File.new_for_path(Cli.STATUS_DIR); this._monitor = dir.monitor_directory(Gio.FileMonitorFlags.NONE, null); this._monitor.connect('changed', () => this._scanSoon()); this._scanStatus(true); } _scanSoon() { if (this._scanTimeout) return; this._scanTimeout = this._addTimeout(0.3, () => { this._scanTimeout = 0; this._scanStatus(false); }); } async _scanStatus(startup) { const files = await Cli.listFiles(Gio.File.new_for_path(Cli.STATUS_DIR)); if (!this._header) return; const seen = new Set(); for (const file of files) { const base = file.get_basename(); if (!base.endsWith('.status')) continue; const name = base.slice(0, -'.status'.length); let text; try { const [bytes] = await file.load_contents_async(null); text = new TextDecoder().decode(bytes).trim(); } catch { continue; } const [what, value] = text.split(/\s+/); if (what === 'running' && GLib.file_test(`/proc/${value}`, GLib.FileTest.EXISTS)) { seen.add(name); this._running.set(name, Number(value)); continue; } // Finished, or its window was killed: either way it's over file.delete_async(GLib.PRIORITY_DEFAULT, null, null); if (!startup && what === 'exit') this._finished(name, Number(value)); } // Launched but never started (the terminal failed), or gone without a trace for (const [name, pid] of this._running) { if (!seen.has(name) && (pid !== 0 || this._launchedLongAgo(name))) { this._running.delete(name); this._launchedAt.delete(name); } } this._updateIndicator(); this._pollWhileRunning(); } // run-tracked hasn't written its status a minute after the terminal was // asked to open: the terminal must have failed _launchedLongAgo(name) { const at = this._launchedAt.get(name); return at === undefined || GLib.get_monotonic_time() - at > 60e6; } // A window killed outright leaves "running" behind: look again now and then _pollWhileRunning() { if (this._running.size === 0 || this._pollTimeout) return; this._pollTimeout = this._addTimeout(5, () => { this._pollTimeout = 0; this._scanStatus(false); }); } _finished(name, code) { this._running.delete(name); this._launchedAt.delete(name); const title = this._titles.get(name) ?? COMMANDS[name]?.title ?? name; this._titles.delete(name); const sibling = name === 'siblings' || name.startsWith('sibling-'); if (name === 'update' && code === 0) this._update = {state: 'current', version: null, checkedAt: GLib.get_real_time() / 1e6}; this._refreshLocal().then(() => { // Update and sibling update change the siblings' versions: look again if (name === 'update' || sibling) this._checkSiblingsNow(); if (!this._settings.get_boolean('notify-finished')) return; if (code === 0) { const restart = (name === 'update' || name === 'refresh') && this._rebootNeeded; this._notify(`${title} finished`, restart ? 'Restart your computer to finish.' : 'Everything went through.', 'success', restart ? [['Restart now', () => this._restart()]] : []); } else if (code === 129 || code === 130) { this._notify(`${title} was stopped`, 'Its window was closed before it finished.', 'warning'); } else if (sibling) { this._notify(`${title} ran into problems`, 'Its terminal window says what went wrong.', 'error'); } else { const actions = [['Open log', () => this._openLatestLog()]]; if (name === 'update' || name === 'refresh') actions.push(['Report problem', () => this._runCommand('report')]); this._notify(`${title} ran into problems`, 'Some steps failed. The log says which.', 'error', actions); } }); } // Check the siblings alone, unless a full check is already running async _checkSiblingsNow() { if (this._checkCancellable) return; const cancellable = this._checkCancellable = new Gio.Cancellable(); try { await this._checkSiblings(cancellable); } catch { return; // cancelled: the extension is being disabled } finally { this._checkCancellable = null; } this._updateIndicator(); } _restart() { // GNOME's own restart dialog, with its countdown and cancel button try { Gio.Subprocess.new(['gnome-session-quit', '--reboot'], Gio.SubprocessFlags.NONE); } catch { Gio.Subprocess.new(['systemctl', 'reboot'], Gio.SubprocessFlags.NONE); } } async _openLatestLog() { const log = await Cli.newestLog(); if (!log) { this._notify('No logs yet', 'Logs appear after the first update.'); return; } try { Gio.AppInfo.launch_default_for_uri(log.get_uri(), global.create_app_launch_context(0, -1)); } catch (e) { this._notify('Couldn\'t open the log', `${log.get_path()}: ${e.message}`, 'error'); } } _notify(title, body, kind = null, actions = []) { if (!this._source) { this._source = new MessageTray.Source({title: 'CoreDesktop', icon: this._gicon}); this._source.connect('destroy', () => { this._source = null; }); Main.messageTray.add(this._source); } const icons = { success: 'emblem-ok-symbolic', warning: 'dialog-warning-symbolic', error: 'dialog-error-symbolic', }; const notification = new MessageTray.Notification({ source: this._source, title, body, gicon: icons[kind] ? new Gio.ThemedIcon({name: icons[kind]}) : this._gicon, isTransient: kind === null, }); for (const [label, callback] of actions) notification.addAction(label, callback); this._source.addNotification(notification); } _addTimeout(seconds, callback) { const id = GLib.timeout_add(GLib.PRIORITY_DEFAULT, Math.round(seconds * 1000), () => { this._timeouts.delete(id); callback(); return GLib.SOURCE_REMOVE; }); this._timeouts.add(id); return id; } destroy() { this._settings.disconnectObject(this); for (const id of this._timeouts) GLib.source_remove(id); this._timeouts.clear(); this._checkCancellable?.cancel(); this._monitor?.cancel(); this._monitor = null; this._source?.destroy(); this._source = null; this._header = null; super.destroy(); } }); export default class CoreDesktopExtension extends Extension { enable() { this._indicator = new Indicator(this); Main.panel.addToStatusArea(this.uuid, this._indicator); } disable() { this._indicator?.destroy(); this._indicator = null; } }