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:
An FvwmScript with a TextField Widget
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
Property
Size 360 20
Position 0 0
Type TextField
Title {xterm}
...
Main
Case message of
SingleClic :
Begin
Set $Text = (GetTitle 1)
Do {Exec $Text}
Quit
End
End
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/run-dialog-xterm.sh
Style fvwm-run-dialog FPGrabFocus, FPReleaseFocus
run-dialog-xterm.sh:
#!/bin/bash
# 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/run-dialog-bashrc.sh
run-dialog-bashrc.sh:
# 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"