panel indicator: add menu with settings entry (opens prefs)

This commit is contained in:
Bastian Mäuser committed 2026-11-11 01:21:45 +01:00
1 parent 57b77f5423
commit 060b098cf3
2 files changed
+17 -4

No files matched your search

+2 -1
View File
@@ -18,7 +18,8 @@ never brought down.
connected -> `netbird up` (netbird's own default/auto exit selection).
- Every trigger is logged: `journalctl -t netbird-hooks`.
- A panel indicator shows the live netbird state (green = connected,
red = down), refreshed on network events and every 15s.
red = down), refreshed on network events and every 15s. Clicking it opens
a menu with a "NetBird settings" entry that opens the preferences.
## The GUI
+15 -3
View File
@@ -7,6 +7,7 @@ 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 PanelMenu from 'resource:///org/gnome/shell/ui/panelMenu.js';
import * as PopupMenu from 'resource:///org/gnome/shell/ui/popupMenu.js';
const UNIT = 'netbird-hooks.service';
const GREEN = '#A3BE8C';
@@ -14,13 +15,24 @@ const RED = '#BF616A';
const Indicator = GObject.registerClass(
class Indicator extends PanelMenu.Button {
_init(settings) {
super._init(0.0, 'NetBird Hooks', true);
_init(extension, settings) {
super._init(0.0, 'NetBird Hooks');
this._extension = extension;
this._settings = settings;
this._icon = new St.Icon({icon_name: 'network-vpn-symbolic',
style_class: 'system-status-icon', style: `color: ${RED};`});
this.add_child(this._icon);
const settingsItem = new PopupMenu.PopupMenuItem('NetBird settings');
settingsItem.connect('activate', () => {
try {
this._extension.openPreferences();
} catch (e) {
logError(e, 'netbird-hooks openPreferences');
}
});
this.menu.addMenuItem(settingsItem);
this._client = NM.Client.new(null);
this._client.connectObject(
'notify::active-connections', () => this._refresh(),
@@ -83,7 +95,7 @@ export default class NetbirdHooksExtension extends Extension {
this._writeUnit();
this._systemctl(['daemon-reload']);
this._systemctl(['enable', '--now', UNIT]);
this._indicator = new Indicator(this._settings);
this._indicator = new Indicator(this, this._settings);
Main.panel.addToStatusArea(this.uuid, this._indicator);
}