diff --git a/src-tauri/capabilities/shell.json b/src-tauri/capabilities/shell.json index 700908f..411f126 100644 --- a/src-tauri/capabilities/shell.json +++ b/src-tauri/capabilities/shell.json @@ -64,6 +64,11 @@ "name": "powershell", "cmd": "powershell", "args": true + }, + { + "name": "cp", + "cmd": "cp", + "args": true } ] }, @@ -114,6 +119,11 @@ "name": "deno", "cmd": "deno", "args": true + }, + { + "name": "cp", + "cmd": "cp", + "args": true } ] } diff --git a/src/helpers/use-linux-registerer.ts b/src/helpers/use-linux-registerer.ts index 135b4b0..3515a0b 100644 --- a/src/helpers/use-linux-registerer.ts +++ b/src/helpers/use-linux-registerer.ts @@ -4,6 +4,7 @@ import { useKvPairs } from "@/helpers/use-kvpairs"; import { useSettingsPageStatesStore } from "@/services/store"; import { invoke } from "@tauri-apps/api/core"; import { useLogger } from "@/helpers/use-logger"; +import { Command } from "@tauri-apps/plugin-shell"; interface FileMap { source: string; @@ -41,12 +42,22 @@ export function useLinuxRegisterer() { const sourcePath = await join(resourceDirPath, file.source); // const destinationDir = await join(homeDirPath, file.dir); const destinationPath = await join(homeDirPath, file.destination); + const command = Command.create('cp', [sourcePath, destinationPath]); + + const output = await command.execute(); + if (output.code === 0) { + console.log(`File ${file.source} copied successfully to ${destinationPath}`); + LOG.info("LINUX REGISTERER", `File ${file.source} copied successfully to ${destinationPath}`); + } else { + console.error(`Failed to copy file ${file.source} to ${destinationPath}:`, output.stderr); + LOG.error("LINUX REGISTERER", `Failed to copy file ${file.source} to ${destinationPath}: ${output.stderr}`); + } // const dirExists = await fs.exists(destinationDir); // if (dirExists) { - await fs.copyFile(sourcePath, destinationPath); - console.log(`File ${file.source} copied successfully to ${destinationPath}`); - LOG.info("LINUX REGISTERER", `File ${file.source} copied successfully to ${destinationPath}`); + // await fs.copyFile(sourcePath, destinationPath); + // console.log(`File ${file.source} copied successfully to ${destinationPath}`); + // LOG.info("LINUX REGISTERER", `File ${file.source} copied successfully to ${destinationPath}`); // } else { // await fs.mkdir(destinationDir, { recursive: true }) // console.log(`Created dir ${destinationDir}`);