Contents of my .ratpoisonrc:
bind Return run_or_raise lilyterm lilyterm
bind c run_or_raise chromium-browser chromium --disk-cache-dir=/tmp/cache
diff --git a/src/actions.c b/src/actions.c
index 3aef26b..af92dc8 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -399,6 +399,9 @@ init_user_commands(void)
"Text: ", arg_RAW);
add_command ("getsel", cmd_getsel, 0, 0, 0);
add_command ("compat", cmd_compat, 0, 0, 0);
+ add_command ("run_or_raise", cmd_run_or_raise, 2, 2, 2,
+ "Class: ", arg_STRING,
+ "/bin/sh -c ", arg_SHELLCMD);
/address@hidden (tag required for genrpbindings) */
/* Commands to help debug ratpoison. */
@@ -2673,6 +2676,22 @@ cmd_execf (int interactive UNUSED, struct cmdarg **args)
return cmdret_new (RET_SUCCESS, NULL);
}
+ cmdret *
+cmd_run_or_raise (int interactive UNUSED, struct cmdarg **args)
+{
+ rp_window *cur = current_window();
+ if (cur && cur->res_class && !strcmp (cur->res_class, ARG_STRING(0)))
+ return cmd_inext(interactive, args);
+ cmdret *ret =cmd_select(interactive, args);
+ if (ret->success==RET_FAILURE){
+ spawn (ARG_STRING(1), 0, current_frame());
+ ret->success=RET_SUCCESS;
+ free(ret->output);
+ ret->output=NULL;
+ }
+ return ret;
+}
+
int
spawn(char *cmd, int raw, rp_frame *frame)
{
diff --git a/src/actions.h b/src/actions.h
index 519c1a7..54d70cf 100644
--- a/src/actions.h
+++ b/src/actions.h
@@ -219,6 +219,7 @@ RP_CMD (undo);
RP_CMD (redo);
RP_CMD (putsel);
RP_CMD (getsel);
+RP_CMD (run_or_raise);
void del_frame_undo (rp_frame_undo *u);