A photo manager for VRChat.
1use std::{ fs, thread };
2
3#[cfg(windows)]
4use mslnk::ShellLink;
5
6// When the user changes the start with windows toggle
7// create and delete the shortcut from the startup folder
8#[cfg(windows)]
9#[tauri::command]
10pub fn start_with_win(start: bool) {
11 if cfg!(windows) {
12 thread::spawn(move || {
13 if start {
14 let target = dirs::config_dir()
15 .unwrap()
16 .join("PhazeDev/VRChatPhotoManager/vrchat-photo-manager.exe");
17
18 match fs::metadata(&target) {
19 Ok(_) => {
20 let lnk = dirs::home_dir().unwrap().join("AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Startup/VRChat Photo Manager.lnk");
21
22 let sl = ShellLink::new(target).unwrap();
23 sl.create_lnk(lnk).unwrap();
24 }
25 Err(_) => {}
26 }
27 } else {
28 let lnk = dirs::home_dir().unwrap().join(
29 "AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Startup/VRChat Photo Manager.lnk",
30 );
31 fs::remove_file(lnk).unwrap();
32 }
33 });
34 } else {
35 panic!("Cannot start with windows... on not windows...");
36 }
37}