diff --git a/src/backends/darwin.mm b/src/backends/darwin.mm index 2ef0b69..7eccb3e 100644 --- a/src/backends/darwin.mm +++ b/src/backends/darwin.mm @@ -79,7 +79,10 @@ std::shared_ptr backend::getMediaInformation() { bool backend::toggleAutostart(bool enabled) { std::filesystem::path launchAgentPath = std::getenv("HOME"); - launchAgentPath = launchAgentPath / "Library" / "LaunchAgents" / "PlayerLink.plist"; + launchAgentPath = launchAgentPath / "Library" / "LaunchAgents"; + std::filesystem::create_directories(launchAgentPath); + launchAgentPath = launchAgentPath / "PlayerLink.plist"; + if (!enabled && std::filesystem::exists(launchAgentPath)) { std::filesystem::remove(launchAgentPath); return true; diff --git a/src/backends/windows.cpp b/src/backends/windows.cpp index e249c00..0869406 100644 --- a/src/backends/windows.cpp +++ b/src/backends/windows.cpp @@ -56,7 +56,10 @@ bool CreateShortcut(std::string source, std::string target) { bool backend::toggleAutostart(bool enabled) { std::filesystem::path shortcutPath = std::getenv("APPDATA"); - shortcutPath = shortcutPath / "Microsoft" / "Windows" / "Start Menu" / "Programs" / "Startup" / "PlayerLink.lnk"; + shortcutPath = shortcutPath / "Microsoft" / "Windows" / "Start Menu" / "Programs" / "Startup"; + std::filesystem::create_directories(shortcutPath); + shortcutPath = shortcutPath / "PlayerLink.lnk";; + if (!enabled && std::filesystem::exists(shortcutPath)) { std::filesystem::remove(shortcutPath); return true;