A tiling window manager

actions: cmd_execv: new exec command starts in specific vscreen (#51)

This patch adds an 'execv' command that takes an initial arg to force
which vscreen to start the new window in.

We give spawn() an extra argument for what vscreen to use, rename it
vspawn() and then wrap it with a replacement spawn() that provides the
current vscreen, leaving existing behavior unchanged, and requiring no
modification of existing callers.

This still won't force the window of an unknown process (such as those
spawned using urxvtc -- which start with pids totally unknown to the
window manager and cannot be tracked by libXRes either) to start in a
certain vscreen, because the vscreen is stored in child proc which, once
mapped, is looked up by pid.

Using this is probably incompatible with 'winaddcurvscreen' set to 1,
and experimenting with setting it *after* execv commands, did not work
for some reason, I was unable to determine.

authored by

Scott Mcdermott and committed by jcs.org 03eff4a6 3de8b742

+30 -4
+22 -4
actions.c
··· 194 194 static cmdret *cmd_exec(int interactive, struct cmdarg **args); 195 195 static cmdret *cmd_execa(int interactive, struct cmdarg **args); 196 196 static cmdret *cmd_execf(int interactive, struct cmdarg **args); 197 + static cmdret *cmd_execv(int interactive, struct cmdarg **args); 197 198 static cmdret *cmd_execw(int interactive, struct cmdarg **args); 198 199 static cmdret *cmd_fdump(int interactive, struct cmdarg **args); 199 200 static cmdret *cmd_focusdown(int interactive, struct cmdarg **args); ··· 445 446 "/bin/sh -c ", arg_SHELLCMD); 446 447 add_command("execf", cmd_execf, 2, 2, 2, 447 448 "frame to execute in:", arg_FRAME, 449 + "/bin/sh -c ", arg_SHELLCMD); 450 + add_command("execv", cmd_execv, 2, 2, 2, 451 + "vscreen to execute in:", arg_VSCREEN, 448 452 "/bin/sh -c ", arg_SHELLCMD); 449 453 add_command("execw", cmd_execw, 1, 1, 1, 450 454 "/bin/sh -c ", arg_SHELLCMD); ··· 2804 2808 return cmdret_new(RET_SUCCESS, NULL); 2805 2809 } 2806 2810 2811 + cmdret * 2812 + cmd_execv(int interactive, struct cmdarg **args) 2813 + { 2814 + rp_vscreen *vscreen; 2815 + if (!(vscreen = find_vscreen(ARG_STRING(0)))) 2816 + return cmdret_new(RET_FAILURE, NULL); 2817 + vspawn(ARG_STRING(1), current_frame(vscreen), vscreen); 2818 + return cmdret_new(RET_SUCCESS, NULL); 2819 + } 2820 + 2807 2821 int 2808 - spawn(char *cmd, rp_frame *frame) 2822 + spawn(char *cmd, rp_frame *frame) { return vspawn(cmd, frame, NULL); } 2823 + int 2824 + vspawn(char *cmd, rp_frame *frame, rp_vscreen *vscreen) 2809 2825 { 2810 2826 rp_child_info *child; 2811 2827 int pid; ··· 2835 2851 } 2836 2852 2837 2853 /* wait((int *) 0); */ 2838 - PRINT_DEBUG(("spawned %s with pid %d destined for frame %d\n", cmd, 2839 - pid, frame ? frame->number : -1)); 2854 + PRINT_DEBUG(("spawned %s, pid %d, frame %d, vscreen %d, screen %d\n", 2855 + cmd, pid, frame ? frame->number : -1, 2856 + (vscreen? vscreen: rp_current_vscreen)->number, 2857 + rp_current_screen->number)); 2840 2858 2841 2859 /* Add this child process to our list. */ 2842 2860 child = xmalloc(sizeof(rp_child_info)); ··· 2844 2862 child->pid = pid; 2845 2863 child->terminated = 0; 2846 2864 child->frame = frame; 2847 - child->vscreen = rp_current_vscreen; 2865 + child->vscreen = vscreen? vscreen: rp_current_vscreen; 2848 2866 child->screen = rp_current_screen; 2849 2867 child->window_mapped = 0; 2850 2868
+1
actions.h
··· 44 44 rp_action *find_keybinding(KeySym keysym, unsigned int state, rp_keymap *map); 45 45 rp_action *find_keybinding_by_action(char *action, rp_keymap *map); 46 46 int spawn(char *cmd, rp_frame *frame); 47 + int vspawn(char *cmd, rp_frame *frame, rp_vscreen *vscreen); 47 48 48 49 #endif /* ! _SDORFEHS_ACTIONS_H */
+7
sdorfehs.1
··· 343 343 .Ar shell\-command , 344 344 showing _NET_WM_PID supporting programs in the given frame instead of 345 345 the frame selected when this program is run. 346 + .It Ic execv Ar vscreen shell\-command 347 + Spawn a shell within a specific vscreen 348 + .Ar vscreen , 349 + executing 350 + .Ar shell\-command 351 + as in the 'exec' command (i.e., using "sh -c"). This is not likely to work 352 + well with 'winaddcurvscreen' set to 1 anywhere in the configuration file. 346 353 .It Ic execw Ar shell\-command 347 354 Spawn a shell executing 348 355 .Ar shell\-command ,