diff --git a/src/Common.h b/src/Common.h index b3aba74..cd8d4e4 100644 --- a/src/Common.h +++ b/src/Common.h @@ -1,6 +1,7 @@ #pragma once #include #include +#include #define UNUSED [[maybe_unused]] #define LOG(x) std::cout << x << '\n' @@ -66,8 +67,7 @@ struct Process pid_t pid; }; -template -inline Process OpenProcess(Args... args) +inline Process OpenProcess(const std::string& command) { pid_t child = fork(); ASSERT(child != -1, "fork error"); @@ -75,7 +75,7 @@ inline Process OpenProcess(Args... args) if (child == 0) { // Child - execl(args...); + system(command.c_str()); exit(0); } else diff --git a/src/System.cpp b/src/System.cpp index e2fe8b6..c6eb07c 100644 --- a/src/System.cpp +++ b/src/System.cpp @@ -340,7 +340,7 @@ namespace System void StartBTScan() { StopBTScan(); - btctlProcess = OpenProcess("/bin/sh", "/bin/sh", "-c", "bluetoothctl scan on", NULL); + btctlProcess = OpenProcess("/bin/sh -c \"bluetoothctl scan on\""); } void StopBTScan() { @@ -403,7 +403,7 @@ namespace System void OpenBTWidget() { - OpenProcess("/bin/sh", "/bin/sh", "-c", "gBar bluetooth"); + OpenProcess("/bin/sh -c \"gBar bluetooth\""); } std::string BTTypeToIcon(const BluetoothDevice& dev)