Skip to content

Commit 1f752bf

Browse files
authored
Add tray icon support (#121)
* Add tray icon support using KStatusNotifierItem For compatibility with desktop environments that don't support the background portal. * Add preference option to enable/disable tray icon
2 parents 35399e5 + 6a7d55f commit 1f752bf

File tree

8 files changed

+301
-16
lines changed

8 files changed

+301
-16
lines changed

Cargo.lock

Lines changed: 120 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,6 @@ ashpd = { version = "0.12", default-features = false, features = [
4343
futures-timer = "3.0.3"
4444
tokio-util = "0.7.15"
4545
tracing-appender = "0.2.3"
46+
47+
[target.'cfg(target_os = "linux")'.dependencies]
48+
ksni = { version = "0.3", default-features = false, features = ["async-io"] }

build-aux/io.github.nozwock.Packet.Devel.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
],
1010
"command": "packet",
1111
"finish-args": [
12+
"--talk-name=org.kde.StatusNotifierWatcher",
1213
"--filesystem=home/.local/share/nautilus-python/extensions",
1314
"--allow=bluetooth",
1415
"--share=network",

data/io.github.nozwock.Packet.gschema.xml.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,8 @@
4141
<key name="enable-nautilus-plugin" type="b">
4242
<default>false</default>
4343
</key>
44+
<key name="enable-tray-icon" type="b">
45+
<default>false</default>
46+
</key>
4447
</schema>
4548
</schemalist>

data/resources/ui/window.blp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,14 @@ Adw.PreferencesDialog preferences_dialog {
463463
}
464464
}
465465

466+
Adw.PreferencesGroup tray_icon_group {
467+
visible: false; // Set true for target_os linux since ksni is linux only
468+
Adw.SwitchRow tray_icon_switch {
469+
title: _("Tray Icon");
470+
subtitle: _("Show tray icon in the system tray");
471+
}
472+
}
473+
466474
Adw.PreferencesGroup {
467475
Adw.ExpanderRow static_port_expander {
468476
title: _("Static Network Port");

src/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ mod ext;
66
mod monitors;
77
mod objects;
88
mod plugins;
9+
#[cfg(target_os = "linux")]
10+
mod tray;
911
mod utils;
1012
mod widgets;
1113
mod window;

0 commit comments

Comments
 (0)