rewrite the way the profile script running works
This commit is contained in:
parent
cb4b854592
commit
46f87587ab
|
@ -50,7 +50,7 @@ static Key keys[] = {
|
||||||
{ -1, CONTROL, XK_Right, moveword, {.i = +1 } },
|
{ -1, CONTROL, XK_Right, moveword, {.i = +1 } },
|
||||||
{ -1, 0, XK_Left, movecursor, {.i = -1 } },
|
{ -1, 0, XK_Left, movecursor, {.i = -1 } },
|
||||||
{ -1, 0, XK_Right, 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 */
|
/* normal mode */
|
||||||
{ 0, 0, XK_i, switchmode, {0} },
|
{ 0, 0, XK_i, switchmode, {0} },
|
||||||
|
|
13
libs/arg.c
13
libs/arg.c
|
@ -506,18 +506,13 @@ setcolumns(const Arg *arg)
|
||||||
drawmenu();
|
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
|
void
|
||||||
spawn(const Arg *arg)
|
spawn(const Arg *arg)
|
||||||
{
|
{
|
||||||
if (!system(arg->v))
|
if (!system(arg->c))
|
||||||
fprintf(stderr, "spmenu: failed to execute command '%s'", ((char **)arg->v)[0]);
|
die("spmenu: failed to execute command '%s'", arg->c);
|
||||||
|
else
|
||||||
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -3,6 +3,7 @@ typedef union {
|
||||||
unsigned int ui; // unsigned int
|
unsigned int ui; // unsigned int
|
||||||
float f; // float
|
float f; // float
|
||||||
const void *v; // void
|
const void *v; // void
|
||||||
|
const char *c; // char
|
||||||
} Arg;
|
} Arg;
|
||||||
|
|
||||||
// declare keybind functions
|
// declare keybind functions
|
||||||
|
@ -37,6 +38,5 @@ static void setimgpos(const Arg *arg);
|
||||||
static void setimggaps(const Arg *arg);
|
static void setimggaps(const Arg *arg);
|
||||||
static void setlines(const Arg *arg);
|
static void setlines(const Arg *arg);
|
||||||
static void setcolumns(const Arg *arg);
|
static void setcolumns(const Arg *arg);
|
||||||
static void setprofile(const Arg *arg);
|
|
||||||
static void spawn(const Arg *arg);
|
static void spawn(const Arg *arg);
|
||||||
static void togglehighlight(const Arg *arg);
|
static void togglehighlight(const Arg *arg);
|
||||||
|
|
|
@ -24,4 +24,3 @@
|
||||||
|
|
||||||
// for running stuff
|
// for running stuff
|
||||||
#define shell "/bin/sh"
|
#define shell "/bin/sh"
|
||||||
#define cmd( cmd ) {.v = (const char*[]){ shell, "-c", cmd, NULL } },
|
|
||||||
|
|
Loading…
Reference in a new issue