diff --git a/config.def.h b/config.def.h index e623910..7836712 100644 --- a/config.def.h +++ b/config.def.h @@ -4,7 +4,6 @@ static const int showbar = 1; /* 0 means no bar */ static const int topbar = 1; /* 0 means bottom bar */ static const char *fonts[] = { "monospace:size=10" }; -static const char dmenufont[] = "monospace:size=10"; static const char col_gray1[] = "#222222"; static const char col_gray2[] = "#444444"; static const char col_gray3[] = "#bbbbbb"; @@ -54,7 +53,7 @@ static Key keys[] = { /* modifier key function argument */ { MODKEY, XK_n, nametag, {0} }, { MODKEY, XK_slash, spawn, {.v = "menu" } }, - { MODKEY|ShiftMask, XK_Return, spawn, {.v = "term" } }, + { MODKEY|ShiftMask, XK_slash, spawn, {.v = "term" } }, { MODKEY|ShiftMask, XK_f, spawn, {.v = "firefox" } }, { MODKEY, XK_b, togglebar, {0} }, { MODKEY, XK_j, focusstack, {.i = +1 } }, diff --git a/dwm.c b/dwm.c index 2cea438..69d0a56 100644 --- a/dwm.c +++ b/dwm.c @@ -1580,8 +1580,8 @@ nametag(const Arg *arg) { int i; errno = 0; // popen(3p) says on failure it "may" set errno - if(!(f = popen("dmenu < /dev/null", "r"))) { - fprintf(stderr, "polytreewm: popen 'dmenu < /dev/null' failed%s%s\n", errno ? ": " : "", errno ? strerror(errno) : ""); + if(!(f = popen("rofi -dmenu", "r"))) { + fprintf(stderr, "polytreewm: popen 'rofi -dmenu' failed%s%s\n", errno ? ": " : "", errno ? strerror(errno) : ""); return; } if (!(p = fgets(name, TAGS_CUSTOM_NAME_SIZE, f)) && (i = errno) && ferror(f)) diff --git a/polytreewm.1 b/polytreewm.1 index a7c0285..ac6d1a5 100644 --- a/polytreewm.1 +++ b/polytreewm.1 @@ -56,15 +56,15 @@ click on a tag label applies that tag to the focused window. click on a tag label adds/removes that tag to/from the focused window. .SS Keyboard commands .TP -.B Mod1\-Shift\-Return -Start -.BR st(1). -.TP .B Mod1\-/ Spawn -.BR dmenu(1) +.BR rofi(1) for launching other programs. .TP +.B Mod1\-Shift\-/ +Start +.BR st(1). +.TP .B Mod1\-, Focus previous screen, if any. .TP @@ -165,7 +165,7 @@ Resize focused window while dragging. Tiled windows will be toggled to the float PolytreeWM is customized by creating a custom config.h and (re)compiling the source code. This keeps it fast, secure and simple. .SH SEE ALSO -.BR dmenu (1), +.BR rofi (1), .BR st (1) .SH ISSUES Java applications which use the XToolkit/XAWT backend may draw grey windows diff --git a/spawn.c b/spawn.c index c1fca34..e18fcd9 100644 --- a/spawn.c +++ b/spawn.c @@ -19,38 +19,27 @@ struct Command { static struct Command commands[] = { { .name = "menu", - .monitor_arg_index = 2, + .monitor_arg_index = 6, .args = { - "dmenu_run", - // monitor - "-m", - "0", - // font - "-fn", - "monospace:size=10", - // color: gray 1 - "-nb", - "#222222", - // color: gray 3 - "-nf", - "#bbbbbb", - // color: cyan - "-sb", - "#005577", - // color: gray 4 - "-sf", - "#eeeeee", + "rofi", + "-modi", + "drun", + "-show", + "drun", + "-monitor", + "-1", + "-show-icons", NULL, }, }, { .name = "term", - .monitor_arg_index = -1, + .monitor_arg_index = 0, .args = { "st", NULL }, }, { .name = "firefox", - .monitor_arg_index = -1, + .monitor_arg_index = 0, .args = { "firefox", NULL }, }, }; @@ -73,10 +62,11 @@ void spawn_command( // We discard const modifier // because we will only change newly allocated version. char **args = (char**)command->args; + char monitor_buffer[2] = { '0' + monitor, '\0' }; - if (command->monitor_arg_index != -1) { + if (command->monitor_arg_index != 0) { args = malloc(sizeof(char*) * ARGS_SIZE); - if (args == NULL) break; + if (args == NULL) return; for (size_t arg_index = 0;; ++arg_index) { // We discard const modifier @@ -85,24 +75,10 @@ void spawn_command( if (args[arg_index] == NULL) break; } - args[command->monitor_arg_index] = - malloc(sizeof(char) * MON_ARG_SIZE); - if (args[command->monitor_arg_index] == NULL) { - free(args); - break; - } - - args[command->monitor_arg_index][0] = '0' + monitor; - args[command->monitor_arg_index][1] = '\0'; + args[command->monitor_arg_index] = monitor_buffer; } if (fork() == 0) { - // TODO: DRY (see the same code below) - if (command->monitor_arg_index != -1) { - free(args[command->monitor_arg_index]); - free(args); - } - callback(); setsid(); execvp(args[0], args); @@ -111,11 +87,8 @@ void spawn_command( exit(EXIT_SUCCESS); } - if (command->monitor_arg_index != -1) { - free(args[command->monitor_arg_index]); - free(args); - } + if (command->monitor_arg_index != 0) free(args); - break; + return; } }