How to implement a hotkey driven textbox that can run shell commands


I’d like to implement a simple textbox that I can call up anywhere on the screen with a hotkey. When I type a command into the textbox and hit enter, I’d like it to execute that command as if it were from a shell.

I’ve attempted this using 2 methods:

  1. An FvwmScript with a TextField Widget
  2. an FvwmForm implementation

The issue I’m having with 1. is that I’m unable to execute the text that is grabbed from the TextField using GetTitle.

The issue I’m having with 2. is that I don’t want a button but it seems as though it is built into FvwmForm. Also, I haven’t gotten Escape to close the FwvmForm yet.

Any help with choosing a method and overcoming my obstacles?

Implementation 1.

WindowTitle	{Run}
WindowSize	360 40
WindowPosition  0 170

Widget 1
 Size		360 20
 Position	0 0
 Type		TextField
 Title		{xterm}
 Case message of
 SingleClic :
  Set $Text = (GetTitle 1)
  Do {Exec $Text}

Implementation 2.

DestroyModuleConfig FvwmForm-Input: *
*FvwmForm-Input: WarpPointer
*FvwmForm-Input: Input Input 20 ""
*FvwmForm-Input: Button quit "" ^M
*FvwmForm-Input: Command Exec exec $(Input)

Thanks in advance,

Have you considered using yeahconsole instead? YeahWM
It’s a drop-down terminal which can be shown/hidden using keyboard shortcuts.

I have something like this, that I call a “Run dialog”, since it’s inspired by the thing of that name in Microsoft Windows. It’s built using xterm. I think I originally got it from the FVWM wiki.

The FVWM key binding runs a shell script to invoke xterm (this could prolly be rolled into the binding, but it would get a little hairy). The xterm invocation gives it a special class name, which will be picked up on by the FVWM style, as well as the X resource. The X resource changes the ENTER key to instead send multiple characters, to background the process and exit the tiny xterm.

.fvwmrc extract:

Key semicolon A CM Exec exec $[HOME]/.fvwm/
Style fvwm-run-dialog	FPGrabFocus, FPReleaseFocus

# the special xterm name pulls in a special key remap from Xresources
# that key remap turns ENTER into magic that gives us the "Run?" behavior
xterm +sb -name fvwm-run-dialog -title "Run" -geometry 80x1+224+360 -e bash --init-file $HOME/.fvwm/

# Doing it in a special bashrc file, rather than via regular means,
# so that any subsequent shells don't inherit this stuff.
export PS1="Run? "
export HISTCONTROL="ignorespace"

.Xresources extract:

fvwm-run-dialog.VT100*translations: #override \n\
	<Key>Return: string(" &\n exit\n")

There are some other options:

  • Use FvwmForm-Talk a default Fvwm form that does what you want (you can look at it for more details).
  • Use FvwmPrompt (or FvwmCommand) in a terminal.
  • Use FvwmConsole (if FvwmPrompt isn’t built). Open it up and send Fvwm a command to run (this is what I use, I then just minimize the console).

Note all of these options send commands to Fvwm, so if you want to run a program you will need to do something like Exec exec xterm.