Fix issues with opening the bluetooth widget

On my system, the bluetooth widget wouldn't execute the first time the
button is clicked. This probably due to the fact I forgot a NULL at the
end of the execl call. Now I just call system and "call" it a day
This commit is contained in:
scorpion-26 2023-02-04 15:33:06 +01:00
parent 4373ab7654
commit 78f3119544
2 changed files with 5 additions and 5 deletions

View file

@ -1,6 +1,7 @@
#pragma once #pragma once
#include <iostream> #include <iostream>
#include <unistd.h> #include <unistd.h>
#include <string>
#define UNUSED [[maybe_unused]] #define UNUSED [[maybe_unused]]
#define LOG(x) std::cout << x << '\n' #define LOG(x) std::cout << x << '\n'
@ -66,8 +67,7 @@ struct Process
pid_t pid; pid_t pid;
}; };
template<typename... Args> inline Process OpenProcess(const std::string& command)
inline Process OpenProcess(Args... args)
{ {
pid_t child = fork(); pid_t child = fork();
ASSERT(child != -1, "fork error"); ASSERT(child != -1, "fork error");
@ -75,7 +75,7 @@ inline Process OpenProcess(Args... args)
if (child == 0) if (child == 0)
{ {
// Child // Child
execl(args...); system(command.c_str());
exit(0); exit(0);
} }
else else

View file

@ -340,7 +340,7 @@ namespace System
void StartBTScan() void StartBTScan()
{ {
StopBTScan(); StopBTScan();
btctlProcess = OpenProcess("/bin/sh", "/bin/sh", "-c", "bluetoothctl scan on", NULL); btctlProcess = OpenProcess("/bin/sh -c \"bluetoothctl scan on\"");
} }
void StopBTScan() void StopBTScan()
{ {
@ -403,7 +403,7 @@ namespace System
void OpenBTWidget() void OpenBTWidget()
{ {
OpenProcess("/bin/sh", "/bin/sh", "-c", "gBar bluetooth"); OpenProcess("/bin/sh -c \"gBar bluetooth\"");
} }
std::string BTTypeToIcon(const BluetoothDevice& dev) std::string BTTypeToIcon(const BluetoothDevice& dev)