From 78f311954462e0c5a427ba168965cc899a86d0c7 Mon Sep 17 00:00:00 2001 From: scorpion-26 <58082714+scorpion-26@users.noreply.github.com> Date: Sat, 4 Feb 2023 15:33:06 +0100 Subject: [PATCH] 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 --- src/Common.h | 6 +++--- src/System.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) 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)