ItsRiprod / DeskThing

Desk Thing: The Discord Thing, Trello Thing, The Weather Thing, The Macro Thing, Just not The Car Thing anymore
MIT License
137 stars 6 forks source link

MediaWin fails to call mediaCLI with space in username #14

Closed josh-hanke closed 1 month ago

josh-hanke commented 1 month ago

MediaWin throws an error when trying to execute DeskThingMediaCLI.exe, looks like it's because my username contains a space.

Screenshot 2024-07-17 195741

I've been messing with some different solutions in my Local index.js but I don't really get what's going on. I've tried forcing some quotes around this.cliPath when it's called into exec with exec('\"${this.cliPath}\" .. as well as using .replaceAll to add some different escape characters for the space but nothing seems to effect it. I mean, I can get it to pass an extra-wrong path, but nothing that actually remedies it :sweat: I've never really touched JS/Electron, so I don't know if any of this helps, but I thought I'd at least try to help out instead of just complaining :sweat_smile:

ItsRiprod commented 1 month ago

Oooh yeah that makes sense. exec really hates spaces in the paths, and I suppose it makes sense that it being in your name is no different. You can try making it use quotes around a cd command and then run the executable maybe? I'll post a patch by the end of this week

Something like cd "${pathToFile}" && ./mediaWinCli.exe xyz

I can get a better solution once I'm not on my phone though - and it should be patched in v0.5.5 regardless

ItsRiprod commented 1 month ago

Okay I got it. This should hypothetically fix your issue with that. I should probably make this standard-practice whenever running an executable for that very reason. The patch will be out in v0.5.5, but if you want to fix it now, here are the changes: image

Changing the launch commands to

exec(`cd ${__dirname} && DeskThingMediaCLI.exe ${command} ${args}`,

and

exec(`cd ${__dirname} && adjust_get_current_system_volume_vista_plus.exe ${args}`,

in the mediawin.js file.

To apply the changes, run npm install and then npm build inside the /mediawin/ directory to build the output to /build

Then, zip up the contents in /build/ and then drag and drop that .zip file like you would any other app. Restart DeskThing.exe (from the tray, right click the icon and click Quit) then you should be set! Hope this helps

josh-hanke commented 1 month ago

That did the trick! Thanks for the explanation, I was really curious about that one :)