Skip to content
Open
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
4 changes: 2 additions & 2 deletions packages/desktop/src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use std::{
time::Duration,
};
use tauri::{AppHandle, Listener, Manager, RunEvent, State, ipc::Channel};
#[cfg(any(target_os = "linux", all(debug_assertions, windows)))]
#[cfg(any(target_os = "linux", target_os = "windows"))]
use tauri_plugin_deep_link::DeepLinkExt;
use tauri_specta::Event;
use tokio::{
Expand Down Expand Up @@ -596,7 +596,7 @@ async fn initialize(app: AppHandle) {
}

fn setup_app(app: &tauri::AppHandle, init_rx: watch::Receiver<InitStep>) {
#[cfg(any(target_os = "linux", all(debug_assertions, windows)))]
#[cfg(any(target_os = "linux", target_os = "windows"))]
app.deep_link().register_all().ok();

app.manage(InitState { current: init_rx });
Expand Down
3 changes: 2 additions & 1 deletion packages/desktop/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
"nsis": {
"installerIcon": "icons/dev/icon.ico",
"headerImage": "assets/nsis-header.bmp",
"sidebarImage": "assets/nsis-sidebar.bmp"
"sidebarImage": "assets/nsis-sidebar.bmp",
"installerHooks": "./windows/hooks.nsh"
}
}
},
Expand Down
17 changes: 17 additions & 0 deletions packages/desktop/src-tauri/windows/hooks.nsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
!macro NSIS_HOOK_POSTINSTALL
; Register "Open with OpenCode" context menu for folders
WriteRegStr HKCU "Software\Classes\Directory\shell\OpenCode" "" "Open with OpenCode"
WriteRegStr HKCU "Software\Classes\Directory\shell\OpenCode" "Icon" "$INSTDIR\OpenCode.exe"
WriteRegStr HKCU "Software\Classes\Directory\shell\OpenCode\command" "" '"$INSTDIR\OpenCode.exe" "opencode://open-project?directory=%V"'

; Register for directory background (right-click in empty space inside folder)
WriteRegStr HKCU "Software\Classes\Directory\Background\shell\OpenCode" "" "Open with OpenCode"
WriteRegStr HKCU "Software\Classes\Directory\Background\shell\OpenCode" "Icon" "$INSTDIR\OpenCode.exe"
WriteRegStr HKCU "Software\Classes\Directory\Background\shell\OpenCode\command" "" '"$INSTDIR\OpenCode.exe" "opencode://open-project?directory=%V"'
!macroend

!macro NSIS_HOOK_POSTUNINSTALL
; Remove context menu entries
DeleteRegKey HKCU "Software\Classes\Directory\shell\OpenCode"
DeleteRegKey HKCU "Software\Classes\Directory\Background\shell\OpenCode"
!macroend
Loading