After I added a keybinding for Bash, I think why not make it working globally?
Here is what I just added to my DWM configuration:
diff --git a/dwm-config.h b/dwm-config.h index 1994463..517976b 100644 --- a/dwm-config.h +++ b/dwm-config.h -125,6 +125,8 static const char *monitor_expand_cmd[] = { "monitorExpand.sh", NULL }; static const char *lock_cmd[] = { "xlock", "-mode", "blank", "-startCmd", "monitorOff.sh", "-timeout", "15", "-dpmsoff", "1", NULL }; +static const char *ts_cmd[] = SHCMD("xdotool keyup t ; xdotool type --clearmodifiers $(date --utc +%Y-%m-%dT%H:%M:%SZ)"); + static Key keys[] = { /* modifier key function argument */ { MODKEY, XK_p, spawn, {.v = bashrun_cmd } }, -155,6 +157,8 static Key keys[] = { { MODKEY, XK_F2, spawn, {.v = monitor_switch_cmd} }, { MODKEY, XK_F3, spawn, {.v = monitor_expand_cmd} }, + { MODKEY|ShiftMask, XK_t, spawn, {.v = ts_cmd} }, + { MODKEY|ShiftMask, XK_m, toggle_ffm, {0} }, { MODKEY|ShiftMask, XK_r, toggle_rules, {0} },
It uses xdotool to send the key events. Since I bound it to t, it is necessary to send a keyup even in prior or the timestamp string will be eaten entirely or partially, depending on when I release the key. Also, --clearmodifiers is required, or the characters in timestamp string may trigger other keybindings in DWM.
You can bind the key in your Window Manager, some may not be able to run with sh but a simple executable file, you can always create a script and put the commands in that script and make it executable.