I'm new to Tauri and Rust in general.
I'm working on this desktop app that will run different bash commands such as:
I'm not entirely sure how to best make it work.
Would somebody has snippet related to bash script in a tauri App ? To get a general idea ?
Something as small echo "hello" or anything else really or even opening an app with osascript.
Anything would be very much appreciated
tauri.conf.json
"tauri": {
"allowlist": {
"all": false,
"shell": {
"all": true,
"execute": true,
"sidecar": true,
"open": true,
"scope": [
{
"name": "test",
"cmd": "echo",
"args": ["hello"]
},
{
"name": "testing",
"cmd": "osascript",
"args": ["-e", "tell application \"Calendar\" to activate"]
}
]
}
main.js
const { Command } = window.__TAURI__.shell
async function greet() {
console.log("call")
new Command('test', ["hello"])
new Command('testing', ["-e", "tell application \"Calendar\" to activate"])
}
I also had issues with this trying to run npm and was getting an error of "program not found" - a solution for Windows at least was to add .cmd at the end of the command and then it started working.
{
"name": "npm",
"cmd": "npm.cmd",
"args": //
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With