mirror of
https://github.com/hyprwm/Hypr.git
synced 2024-11-26 06:45:58 +01:00
fixed exec
This commit is contained in:
parent
b66200013a
commit
7bf163d45b
1 changed files with 3 additions and 27 deletions
|
@ -2,6 +2,7 @@
|
||||||
#include "utilities/Util.hpp"
|
#include "utilities/Util.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
Keybind* KeybindManager::findKeybindByKey(int mod, xcb_keysym_t keysym) {
|
Keybind* KeybindManager::findKeybindByKey(int mod, xcb_keysym_t keysym) {
|
||||||
for(auto& key : KeybindManager::keybinds) {
|
for(auto& key : KeybindManager::keybinds) {
|
||||||
|
@ -83,39 +84,14 @@ void KeybindManager::killactive(std::string args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeybindManager::call(std::string args) {
|
void KeybindManager::call(std::string args) {
|
||||||
|
|
||||||
if (fork() == 0) {
|
if (fork() == 0) {
|
||||||
setsid();
|
setsid();
|
||||||
if (fork() != 0) {
|
if (fork() != 0) {
|
||||||
_exit(0);
|
_exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// fix the args
|
execl("/bin/sh", "/bin/sh", "-c", args.c_str(), nullptr);
|
||||||
std::string command = args.substr(0, args.find_first_of(" "));
|
|
||||||
|
|
||||||
int ARGNO = std::count(args.begin(), args.end(), ' ');
|
|
||||||
if(ARGNO > 0)
|
|
||||||
ARGNO -= 1;
|
|
||||||
|
|
||||||
if(ARGNO) {
|
|
||||||
char* argsarr[ARGNO];
|
|
||||||
|
|
||||||
for (int i = 0; i < ARGNO; ++i) {
|
|
||||||
args = args.substr(args.find_first_of(' ') + 1);
|
|
||||||
argsarr[i] = (char*)args.substr(0, args.find_first_of(' ')).c_str();
|
|
||||||
}
|
|
||||||
|
|
||||||
Debug::log(LOG, "Executing " + command + " with " + std::to_string(ARGNO) + " args:");
|
|
||||||
for (int i = 0; i < ARGNO; ++i) {
|
|
||||||
Debug::log(NONE, argsarr[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
execvp((char*)command.c_str(), (char**)argsarr);
|
|
||||||
} else {
|
|
||||||
Debug::log(LOG, "Executing " + command + " with 0 args.");
|
|
||||||
|
|
||||||
execvp((char*)command.c_str(), nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
_exit(0);
|
_exit(0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue