Skip to content

Commit fd900a6

Browse files
imersiaclaude
andcommitted
Add settings hub delegation and registration descriptor
Add --settings-standalone flag and smart delegation: --settings tries cosmic-applet-settings hub first, falls back to standalone window. Install registration JSON for discovery by cosmic-applet-settings. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4e080c6 commit fd900a6

3 files changed

Lines changed: 36 additions & 4 deletions

File tree

justfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ install-local:
5656
mkdir -p ~/.local/share/icons/hicolor/symbolic/apps
5757
cp resources/{{appid}}-symbolic.svg ~/.local/share/icons/hicolor/symbolic/apps/
5858

59+
# Install applet registration for cosmic-applet-settings
60+
mkdir -p ~/.local/share/cosmic-applet-settings/applets
61+
cp resources/applet-settings.json ~/.local/share/cosmic-applet-settings/applets/{{name}}.json
62+
5963
echo "Installation complete!"
6064
echo "Add the applet to your COSMIC panel to use it."
6165

@@ -65,6 +69,7 @@ uninstall-local:
6569
rm -f ~/.local/share/applications/{{appid}}.desktop
6670
rm -f ~/.local/share/icons/hicolor/scalable/apps/{{appid}}.svg
6771
rm -f ~/.local/share/icons/hicolor/symbolic/apps/{{appid}}-symbolic.svg
72+
rm -f ~/.local/share/cosmic-applet-settings/applets/{{name}}.json
6873

6974
# Build and run
7075
br: build-debug run

resources/applet-settings.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "RunKat",
3+
"icon": "io.github.reality2_roycdavies.cosmic-runkat-symbolic",
4+
"applet_id": "io.github.reality2_roycdavies.cosmic-runkat",
5+
"settings_cmd": "cosmic-runkat --settings-standalone"
6+
}

src/main.rs

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ mod theme;
2424

2525
use std::env;
2626

27+
const APPLET_ID: &str = "io.github.reality2_roycdavies.cosmic-runkat";
28+
2729
/// Print command-line usage information
2830
fn print_help() {
2931
println!(
@@ -32,9 +34,10 @@ fn print_help() {
3234
Usage: cosmic-runkat [OPTIONS]
3335
3436
Options:
35-
-s, --settings Open the settings window
36-
-h, --help Show this help message
37-
-v, --version Show version information
37+
-s, --settings Open settings (via hub or standalone)
38+
--settings-standalone Open standalone settings window
39+
-h, --help Show this help message
40+
-v, --version Show version information
3841
3942
No arguments: Run as a COSMIC panel applet.
4043
"#
@@ -73,7 +76,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
7376
Ok(())
7477
}
7578
"-s" | "--settings" => {
76-
tracing::info!("Opening settings window");
79+
tracing::info!("Opening settings (trying hub first)");
80+
open_settings().map_err(|e| e.into())
81+
}
82+
"--settings-standalone" => {
83+
tracing::info!("Opening standalone settings window");
7784
settings::run_settings().map_err(|e| e.into())
7885
}
7986
arg => {
@@ -86,3 +93,17 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
8693
applet::run_applet().map_err(|e| e.into())
8794
}
8895
}
96+
97+
/// Try to open settings via cosmic-applet-settings hub; fall back to standalone.
98+
fn open_settings() -> cosmic::iced::Result {
99+
use std::process::Command;
100+
if Command::new("cosmic-applet-settings")
101+
.arg(APPLET_ID)
102+
.spawn()
103+
.is_ok()
104+
{
105+
Ok(())
106+
} else {
107+
settings::run_settings()
108+
}
109+
}

0 commit comments

Comments
 (0)