feat(desktop): embed icon, shorten keybind label, add toggle feedback
This commit is contained in:
1 parent
86d217903a
commit
ea093c044f
6 files changed
+57
-4
No files matched your search
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"permissions": {
|
||||
"allow": [
|
||||
"Bash(find /mnt/storage/code/rust/mcl -maxdepth 2 -name README* -o -name CLAUDE.md -o -name *.md)",
|
||||
"Bash(cargo test:*)",
|
||||
"Bash(git add:*)",
|
||||
"Bash(git commit:*)",
|
||||
"Bash(cargo clippy:*)",
|
||||
"Bash(/home/consti/.claude/plugins/cache/claude-plugins-official/superpowers/5.0.6/scripts/start-server.sh --project-dir /mnt/storage/code/rust/mcl 2>&1)",
|
||||
"Bash(/home/consti/.claude/plugins/cache/claude-plugins-official/superpowers/5.0.6/skills/brainstorming/scripts/start-server.sh --project-dir /mnt/storage/code/rust/mcl 2>&1)",
|
||||
"Bash(cargo build:*)"
|
||||
]
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 664 KiB |
@@ -73,6 +73,7 @@ selected_bold = true
|
||||
row_alt_bg = "surface"
|
||||
running_fg = "success"
|
||||
text_fg = "fg"
|
||||
label_fg = "muted"
|
||||
|
||||
[log_overlay]
|
||||
bg = "bg"
|
||||
|
||||
+20
-1
@@ -2,6 +2,8 @@ use std::path::{Path, PathBuf};
|
||||
|
||||
use crate::instance::models::InstanceConfig;
|
||||
|
||||
const ICON_BYTES: &[u8] = include_bytes!("../../assets/icon.png");
|
||||
|
||||
pub fn desktop_path(name: &str) -> Option<PathBuf> {
|
||||
dirs_next::data_dir().map(|d| {
|
||||
d.join("applications")
|
||||
@@ -13,6 +15,23 @@ pub fn icon_path() -> Option<PathBuf> {
|
||||
dirs_next::data_dir().map(|d| d.join("mcl").join("icon.png"))
|
||||
}
|
||||
|
||||
fn ensure_icon() -> Option<PathBuf> {
|
||||
let path = icon_path()?;
|
||||
if path.exists() {
|
||||
return Some(path);
|
||||
}
|
||||
let parent = path.parent()?;
|
||||
if let Err(e) = std::fs::create_dir_all(parent) {
|
||||
tracing::warn!("Failed to create icon directory: {}", e);
|
||||
return None;
|
||||
}
|
||||
if let Err(e) = std::fs::write(&path, ICON_BYTES) {
|
||||
tracing::warn!("Failed to write bundled icon: {}", e);
|
||||
return None;
|
||||
}
|
||||
Some(path)
|
||||
}
|
||||
|
||||
pub fn exists(name: &str) -> bool {
|
||||
desktop_path(name).map(|p| p.exists()).unwrap_or(false)
|
||||
}
|
||||
@@ -25,7 +44,7 @@ pub fn create(config: &InstanceConfig) -> std::io::Result<PathBuf> {
|
||||
std::fs::create_dir_all(parent)?;
|
||||
}
|
||||
|
||||
let icon = icon_path().filter(|p| p.exists());
|
||||
let icon = ensure_icon();
|
||||
let content = build_content(&config.name, icon.as_deref());
|
||||
std::fs::write(&path, content)?;
|
||||
Ok(path)
|
||||
|
||||
+21
-2
@@ -421,8 +421,27 @@ impl App {
|
||||
}
|
||||
widgets::details::SettingsAction::ToggleDesktop => {
|
||||
if let Some(inst) = self.profiles_state.selected_instance() {
|
||||
if let Err(e) = crate::instance::desktop::toggle(inst) {
|
||||
tracing::error!("Failed to toggle desktop shortcut: {}", e);
|
||||
let name = inst.name.clone();
|
||||
match crate::instance::desktop::toggle(inst) {
|
||||
Ok(true) => {
|
||||
error_buffer::push_error(error_buffer::ErrorEvent {
|
||||
id: 0,
|
||||
level: tracing::Level::INFO,
|
||||
message: format!("Desktop shortcut created for '{name}'"),
|
||||
pushed_at: std::time::Instant::now(),
|
||||
});
|
||||
}
|
||||
Ok(false) => {
|
||||
error_buffer::push_error(error_buffer::ErrorEvent {
|
||||
id: 0,
|
||||
level: tracing::Level::INFO,
|
||||
message: format!("Desktop shortcut removed for '{name}'"),
|
||||
pushed_at: std::time::Instant::now(),
|
||||
});
|
||||
}
|
||||
Err(e) => {
|
||||
tracing::error!("Failed to toggle desktop shortcut: {}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return Ok(());
|
||||
|
||||
@@ -36,7 +36,7 @@ pub fn render(
|
||||
&[
|
||||
("e", " edit instance"),
|
||||
("g", " edit global"),
|
||||
("d", " desktop shortcut"),
|
||||
("d", " desktop"),
|
||||
],
|
||||
area.width.saturating_sub(2),
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user