Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions standalone/scripts/dogfood.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,20 @@ if [[ "${1:-}" != "--no-install" ]]; then
echo "After that, 'dogfood:standalone' will work from then on."
exit 1
fi
if pgrep -x dormouse >/dev/null 2>&1; then
osascript -e 'tell application id "sh.dormouse.standalone" to quit' \
>/dev/null 2>&1 || true
for _ in {1..50}; do
pgrep -x dormouse >/dev/null 2>&1 || break
sleep 0.1
done
pkill -x dormouse >/dev/null 2>&1 || true
fi
rm -rf "$INSTALL_DIR"
cp -r "$RELEASE_DIR/bundle/macos/Dormouse Terminal.app" "$INSTALL_DIR"
touch "$INSTALL_DIR"
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister \
-f "$INSTALL_DIR" >/dev/null 2>&1 || true
echo "✦ Installed to $INSTALL_DIR"
;;
*)
Expand Down
3 changes: 3 additions & 0 deletions standalone/src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions standalone/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ process-wrap = { version = "9", features = ["std"] }
[target.'cfg(windows)'.dependencies]
windows = { version = "0.62", features = ["Win32_System_Threading"] }

[target.'cfg(target_os = "macos")'.dependencies]
objc2 = "0.6"
objc2-app-kit = { version = "0.3", default-features = false, features = ["NSApplication", "NSImage"] }
objc2-foundation = { version = "0.3", default-features = false, features = ["NSData"] }

[profile.release]
strip = true
lto = true
Expand Down
Binary file added standalone/src-tauri/icons/dock-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 26 additions & 2 deletions standalone/src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,27 @@ fn append_log(message: impl AsRef<str>) {
}
}

#[cfg(target_os = "macos")]
fn set_macos_dock_icon() {
use objc2::{AllocAnyThread, MainThreadMarker};
use objc2_app_kit::{NSApplication, NSImage};
use objc2_foundation::NSData;

let mtm = unsafe { MainThreadMarker::new_unchecked() };
let app = NSApplication::sharedApplication(mtm);
// The largest size exploded from icon.icns (1024×1024) — it carries the
// built-in transparent padding the bundle's edge-to-edge 128x128@2x.png lacks.
let data = NSData::with_bytes(include_bytes!("../icons/dock-icon.png"));
let Some(app_icon) = NSImage::initWithData(NSImage::alloc(), &data) else {
append_log("[app] failed to create macOS dock icon image");
return;
};

unsafe {
app.setApplicationIconImage(Some(&app_icon));
}
}

fn read_log_tail(max_bytes: usize) -> Result<String, String> {
let path = log_path();
let contents = std::fs::read_to_string(path)
Expand Down Expand Up @@ -991,13 +1012,16 @@ pub fn run() {
])
.build(tauri::generate_context!())
.expect("error while building Dormouse")
.run(|app, event| {
if let RunEvent::Exit = event {
.run(|app, event| match event {
#[cfg(target_os = "macos")]
RunEvent::Ready => set_macos_dock_icon(),
RunEvent::Exit => {
if let Some(state) = app.try_state::<SidecarState>() {
append_log("[app] exit — shutting down sidecar");
shutdown_sidecar_and_wait(&state);
}
}
_ => {}
});
}

Expand Down
Loading