CoreDesktop GNOME extension

This commit is contained in:
2026-11-27 12:28:07 -07:00
commit 7d9d2d6239
15 changed files with 1742 additions and 0 deletions
+83
View File
@@ -0,0 +1,83 @@
import Adw from 'gi://Adw';
import Gio from 'gi://Gio';
import GLib from 'gi://GLib';
import Gtk from 'gi://Gtk';
import {ExtensionPreferences} from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';
const TERMINALS = ['auto', 'xdg-terminal-exec', 'kgx', 'ghostty', 'kitty', 'ptyxis', 'gnome-terminal', 'alacritty'];
const TERMINAL_NAMES = {
'auto': 'Automatic',
'xdg-terminal-exec': 'Default terminal (xdg-terminal-exec)',
'kgx': 'Console',
'ghostty': 'Ghostty',
'kitty': 'kitty',
'ptyxis': 'Ptyxis',
'gnome-terminal': 'GNOME Terminal',
'alacritty': 'Alacritty',
};
export default class CoreDesktopPreferences extends ExtensionPreferences {
fillPreferencesWindow(window) {
const settings = this.getSettings();
const page = new Adw.PreferencesPage({icon_name: 'preferences-system-symbolic'});
window.add(page);
// Updates
const updates = new Adw.PreferencesGroup({
title: 'Updates',
description: 'The extension asks CoreDesktop (version --check) whether a newer version is out.',
});
page.add(updates);
const interval = new Adw.SpinRow({
title: 'Check every',
subtitle: 'Hours between checks; 0 turns checking off',
adjustment: new Gtk.Adjustment({lower: 0, upper: 48, step_increment: 1, page_increment: 4}),
});
settings.bind('check-interval', interval, 'value', Gio.SettingsBindFlags.DEFAULT);
updates.add(interval);
const badge = new Adw.SwitchRow({
title: 'Show a dot on the top bar icon',
subtitle: 'Blue when an update is available, orange when a restart is needed',
});
settings.bind('show-badge', badge, 'active', Gio.SettingsBindFlags.DEFAULT);
updates.add(badge);
// Running commands
const running = new Adw.PreferencesGroup({
title: 'Running commands',
description: 'Update, refresh, configure, audit and report run in a terminal window, so you can follow them and type your password.',
});
page.add(running);
const available = TERMINALS.filter(t => t === 'auto' || GLib.find_program_in_path(t));
const current = settings.get_string('terminal');
if (!available.includes(current))
available.push(current);
const terminal = new Adw.ComboRow({
title: 'Terminal',
subtitle: 'Automatic uses the same one as CoreDesktop\'s notifications',
model: Gtk.StringList.new(available.map(t => TERMINAL_NAMES[t] ?? t)),
selected: available.indexOf(current),
});
terminal.connect('notify::selected', () =>
settings.set_string('terminal', available[terminal.selected]));
running.add(terminal);
const notify = new Adw.SwitchRow({
title: 'Notify when a command finishes',
subtitle: 'Says whether it worked, and offers to restart or open the log',
});
settings.bind('notify-finished', notify, 'active', Gio.SettingsBindFlags.DEFAULT);
running.add(notify);
const confirm = new Adw.SwitchRow({
title: 'Explain refresh before running it',
subtitle: 'Refresh re-runs the installer and takes a while',
});
settings.bind('confirm-refresh', confirm, 'active', Gio.SettingsBindFlags.DEFAULT);
running.add(confirm);
}
}