rewrite the way the profile script running works

This commit is contained in:
speedie 2023-04-23 20:08:34 +02:00
parent cb4b854592
commit 46f87587ab
4 changed files with 6 additions and 12 deletions

View file

@ -50,7 +50,7 @@ static Key keys[] = {
{ -1, CONTROL, XK_Right, moveword, {.i = +1 } },
{ -1, 0, XK_Left, movecursor, {.i = -1 } },
{ -1, 0, XK_Right, movecursor, {.i = +1 } },
{ -1, CONTROL|SHIFT, XK_p, setprofile, {0} },
{ -1, CONTROL|SHIFT, XK_p, spawn, {.c = "spmenu_profile --spmenu-set-profile" } },
/* normal mode */
{ 0, 0, XK_i, switchmode, {0} },

View file

@ -506,18 +506,13 @@ setcolumns(const Arg *arg)
drawmenu();
}
void
setprofile(const Arg *arg)
{
// this just runs an external shell script to set the profile
exit(system("command -v spmenu_profile > /dev/null && spmenu_profile --spmenu-set-profile > /dev/null"));
}
void
spawn(const Arg *arg)
{
if (!system(arg->v))
fprintf(stderr, "spmenu: failed to execute command '%s'", ((char **)arg->v)[0]);
if (!system(arg->c))
die("spmenu: failed to execute command '%s'", arg->c);
else
exit(0);
}
void

View file

@ -3,6 +3,7 @@ typedef union {
unsigned int ui; // unsigned int
float f; // float
const void *v; // void
const char *c; // char
} Arg;
// declare keybind functions
@ -37,6 +38,5 @@ static void setimgpos(const Arg *arg);
static void setimggaps(const Arg *arg);
static void setlines(const Arg *arg);
static void setcolumns(const Arg *arg);
static void setprofile(const Arg *arg);
static void spawn(const Arg *arg);
static void togglehighlight(const Arg *arg);

View file

@ -24,4 +24,3 @@
// for running stuff
#define shell "/bin/sh"
#define cmd( cmd ) {.v = (const char*[]){ shell, "-c", cmd, NULL } },