You are not logged in.
I've just finished making the switch from Terminal and Tilda to urxvt. My setup currently runs urxvt in daemon mode on-demand and I have two different key combinations to launch urxvt.
For a regular floating terminal window, I use W-t (Windows key + t, which previously launched Terminal).
For a quake-console-esque urxvt terminal that I can toggle on any desktop and which stays above all other windows, I use W-grave, which previously toggled Tilda. Here's how I did it:
I use this scriptlet from the man page to launch instances of urxvtc without needing to start the server first:
urxvtc
#!/bin/sh
urxvtc "$@"
if [ $? -eq 2 ]; then
urxvtd -q -o -f
urxvtc "$@"
fi
I have the following in openbox's rc.xml:
in "<applications>":
<application name="urxvtq">
<decor>no</decor>
<position force="yes">
<x>center</x>
<y>0</y>
</position>
<desktop>all</desktop>
<layer>above</layer>
<skip_pager>yes</skip_pager>
<skip_taskbar>yes</skip_taskbar>
<maximized>Horizontal</maximized>
</application>
in "<keyboard>":
<keybind key="W-t">
<action name="Execute">
<command>/path/to/urxvtc</command>
</action>
</keybind>
<keybind key="W-grave">
<action name="Execute">
<execute>/path/to/urxvtq</execute>
</action>
</keybind>
</keyboard>
Finally, I have this script to toggle the console:
*edit: As this sometimes needs to be updated, I have uploaded it here. If the version in this post doesn't work, try the one on my site. It is symlinked to the script that I use on my system so it should always be the latest working version. *
#!/bin/bash
wid=$(xdotool search --classname urxvtq)
if [ -z "$wid" ]; then
urxvtdc -name urxvtq -geometry 80x28
wid=$(xdotool search --classname urxvtq)
xdotool windowfocus $wid
xdotool key Control_L+l
elif [ -z "$(xdotool search --onlyvisible --classname urxvtq 2>/dev/null)" ]; then
xdotool windowmap $wid
xdotool windowfocus $wid
else
xdotool windowunmap $wid
fi
dependencies
xdotool (installed size: 137K)
caveats
You'll have to change the "/path/to/*" lines to point to the scripts on your system and the "<y>" tag in the "<position>" tag and the geometry line in the urxvtq script to resize and reposition the console window.
faq
Why are you using xdotool to get the window ID?
urxvt won't show up with "wmctrl -l", even though conky and ipager do... after ripping out most of my URxvt* settings in .Xdefaults, I gave up trying to figure out why. If you find a better solution, please post it. Until then, I'm sticking to what works.
What's with the "xdotool key Control_L+l" line?
When the console first opens it messes up my PS1 var, which contains color codes, a newline char and some unicode characters. I'm not sure what the cause is though because opening urxvt normally doesn't do that. Maybe it's due to the resizing event. Anyway, that line just sends a "ctrl+l" signal to the window to clear it when it first opens (not every time it toggles).
Um, urxvt has a perl script called kuake that does this already, lol.
Wtf, that's not even a question, but ok. The kauke script doesn't accept modifiers so you effectively sacrifice the entire physical key that you bind kuake to, which isn't optimal. With the openbox bindings, you have more options.
Why didn't you just do <better solution>?
Either because I didn't think of it, couldn't figure it out or because it's not actually a better solution (for me).
Feel free to share any improvements. If enough people find this useful, I'll wiki it. Consider this a trial run.
*edit* I've modified urxvtq to incorporate some elements from hbekel's general script below
Last edited by Xyne (2011-01-25 11:15:44)
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
Offline
offtopic, but your pacpan script is awesome. Used it today.
Offline
You should put this on the wiki
[git] | [AURpkgs] | [arch-games]
Offline
Um, urxvt has a perl script called kuake that does this already
People often overlook the fact that urxvt has an extension for this. However it's still better to be able to create a "quake console" with just about any terminal emulator on your WM. Especially if tilda, yakuake and the rest are lesser terminals than the one you use.
You need to install an RTFM interface.
Offline
This looks familiar, I do something very similar to keep bashrun running in the background. I've generalized your toggling script a little and came up with
~/bin/toggle:
Usage: toggle -n <wm_name> -c <command> [-i <initial>]
wm_name : The WM_NAME of the window to toggle
command : The command creating the window to be toggled
initial : initial command to run after the window has been created
#!/bin/bash
function map {
xdotool windowmap $wid
xdotool windowfocus $wid
}
function unmap {
xdotool windowunmap $wid
}
function toggle {
is_mapped=$(xdotool search --onlyvisible --name $wmname 2> /dev/null)
if [[ -z $is_mapped ]]; then
map
else
unmap
fi
}
function waitwid {
# wait until the window has been created
until [[ ! -z $wid ]]; do
wid=$(xdotool search -name $wmname 2> /dev/null)
done
# map and focus
map
# wait until window has focus
until [[ $(xdotool getactivewindow) == $wid ]]; do
:
done
}
function usage {
echo "Usage: toggle -n <wm_name> -c <command> [-i <initial>]"
echo
echo " wm_name : The WM_NAME of the window to toggle"
echo " command : The command creating the window to be toggled"
echo " initial : initial command to run after the window has been created"
echo
exit 1
}
while getopts ":n:i:c:" option; do
case $option in
n) wmname=$OPTARG ;;
i) init_command=$OPTARG ;;
c) command=$OPTARG ;;
*) usage ;;
esac
done
[[ -z $wmname || -z $command ]] && usage
wid=$(xdotool search -name $wmname 2> /dev/null)
if [[ -z $wid ]]; then
# run the command
$command &
# run init command
if [[ -n $init_command ]]; then
waitwid
$init_command
fi
else
toggle
fi
So, in order to run a "quake-like" xterm all you have to do it bind a key to
toggle -n qterm -c 'xterm -name qterm'
If there is no xterm of that name running, it will be started, subsequent invocations toggle window visibility. Toggling is done by mapping/unmapping the window using xdotool only (no need to mix xdotool and wmctrl). The --onlyvisible option to xdotools's search command is used to determine wether the window is currently visible or not.
Note that the command used to launch the program needs to set up the WM_NAME for the window accordingly.
To send an initial command, use the -i option, e.g.
toggle -n qterm -c 'xterm -name qterm' -i 'xdotool key ctrl+l'
This is only the toggling part, of course. Window placement and appearance can be configured as shown by Xyne.
EDIT: Added command line options to allow an optional initial command
Last edited by hbekel (2009-05-09 14:57:52)
Offline
I've incorporated some elements from hbekel's script and added a section to the urxvt wiki.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
I've just put together another version of a quake-like terminal that features animation and works for xterm, urxvt and mrxvt.
Since these terminals set $WINDOWID, it's easier to map/unmap the window from within the terminal's bash session. This way the an outside script doesn't have to rely on finding the right window via a certain WM_NAME. Instead you can send a SIGUSR1 to terminal from the outside to toggle it, using the pid from a pidfile. See the script itself for further instructions, including a method to assure that only one terminal at a time is the quake-like terminal.
Plus it's animated and scrolls down/up like yakuake and others.
Note that this script isn't run as a program, but sourced into the bash session from the terminal you want to use.
The above toggle script is still usable to toggle any kind of program, not just terminals.
Have fun!
# yaql - yet another quake-like scroll-down console
#
# works at least in xterm, urxvt and mrxvt
#
# Usage: source yaql.sh [columns] [lines]
#
# (see end of file for config & details)
#
MAPPED=1
function resize {
# resize [up|down|left|right] or
# resize columns lines
local dir=$1
local columns=$1
local lines=$2
local update=${3:-1}
# set new WIDTH, HEIGHT
case "$dir" in
up)
let HEIGHT--
;;
down)
let HEIGHT++
;;
left)
let WIDTH--
;;
right)
let WIDTH++
;;
*)
WIDTH=$columns
HEIGHT=$lines
;;
esac
# keep least 1x1
[[ $HEIGHT -eq 0 ]] && HEIGHT=1
[[ $WIDTH -eq 0 ]] && WIDTH=1
# resize
echo -ne "\e[8;${HEIGHT};${WIDTH}t";
}
function collapse {
local i=0
WIDTH=$COLUMNS
HEIGHT=$LINES
for (( i=$HEIGHT; i>=$MIN_HEIGHT; i-- )); do
resize up
sleep $DELAY
done
}
function expand {
local i=0
WIDTH=$COLUMNS
HEIGHT=$LINES
for (( i=$HEIGHT; i<=$MAX_HEIGHT; i++ )); do
resize down
sleep $DELAY
done
}
function map {
xdotool windowmap $WINDOWID
xdotool windowmove $WINDOWID $POS_X $POS_Y
MAPPED=1
}
function unmap {
xdotool windowunmap $WINDOWID
MAPPED=0
}
function toggle {
if [[ MAPPED -eq 1 ]]; then
collapse
unmap
else
map
expand
fi
}
function cleanup {
rm $PIDFILE
}
trap cleanup EXIT
trap toggle SIGUSR1
# Configure below here ######################################
POS_X=0
POS_Y=0
xdotool windowmove $WINDOWID $POS_X $POS_Y
WIDTH=${1:-$COLUMNS}
HEIGHT=${2:-$LINES}
resize $WIDTH $HEIGHT
MIN_HEIGHT=1
MAX_HEIGHT=$HEIGHT
# speed of the animation, lesser == faster
DELAY=0.001
PIDFILE=$HOME/.yaql.pid
echo "$$" > $PIDFILE
# Sending SIGUSR1 to the shell will show/hide the terminal
#
# Just bind a key in your wm to this:
#
# kill -USR1 $(cat ~/.yaql.pid)
#
# openbox example:
#
# <keybind key="C-A-d">
# <action name="Execute">
# <execute>bash -c 'kill -USR1 $(cat ~/.yaql.pid)'</execute>
# </action>
# </keybind>
#
# To make sure that only one terminal is used at a time, you can
# source it from your .bashrc like this:
#
# if [[ "$TERM" =~ ^rxvt ]]; then
# if [[ ! -f ~/.yaql.pid ]]; then
# . ~/yaql.sh 80 24
# fi
# fi
#
# This way the first terminal you open will be your quake-like
# console if there isn't already one. To avoid a stale pidfile,
# be sure to remove it when you login, or when you startup X.
EDIT: This is the corresponding launcher that either toggles an existing terminal or launches a new one. Bind this to your toggle key.
#!/bin/bash
if [[ -f ~/.yaql.pid ]]; then
if kill -SIGUSR1 $(cat ~/.yaql.pid); then
exit 0
fi
fi
exec urxvt
Last edited by hbekel (2009-07-01 22:53:47)
Offline
A screenshot maybe?
ffc
Offline
A screenshot doesn't really make sense here, since it all depends on how you configure urxvt. The scripts here all just manage a dedicated (terminal) window in the described ways.
Anyways, this is the way mine looks atm:
I'm using these fonts for urxvt:
URxvt*font: -*-*-medium-r-normal-*-*-140-*-*-c-*-iso8859-1
URxvt*boldfont: -*-*-bold-r-normal-*-*-140-*-*-c-*-iso8859-1
The screenshot shows urxvt at 113x20, on a 1024x768 screen, with a one pixel border supplied by openbox, which just happens to fit real nice.
Note that the animation feature in the last script works only by resizing line-wise, so it's probably not as smooth as in a more sophisticated terminal like yakuake, and may not work very well on slow machines.
Offline
Hi,
Something more than quakeconsole script. "hideme_quickly":
#!/bin/bash
prepare() {
[ -z "$1" -o -z "$2" ] && exit 1 || local r=0
until WID="$(xdotool search --name "$1")" || (( r++, r >= 10 )); do
[ "$ACTION" = "toggle" ] && ACTION="show"
eval `printf "$2"`
(( $? >= 1 )) && exit 2
done
}
hide() {
xdotool windowunmap "$WID"
}
show() {
xdotool windowmap "$WID"
sleep 0.2s
xdotool windowfocus "$WID"
}
toggle() {
if xdotool search --onlyvisible --name "$1" &> /dev/null; then
hide
else
show
fi
}
help() {
printf "hidemy_quickly version 0.1 by 3ED\n"
printf "
Usage:
hideme_quickly [ACTION] [WM_CLASS] [CMD]
[ACTION]:
toogle hide/show window
show show window
hide hide window
[WM_CLASS]:
Xorg WM_CLASS window name..
[CMD]:
Your command (if WM_CLASS not found then this cmd
will be executed)..
\n"
}
case $1 in
"toggle"|"show"|"hide") ACTION="$1";;
*) help 0;;
esac
prepare "$2" "$3"
$ACTION "$2"
Example for urxvtc:
hideme_quickly toggle "qcon" "urxvtc -name qcon"
and firefox:
hideme_quickly toggle "Navigator" "firefox"
Offline
The two scripts work, my W-grave key pops up a urxvt instance, however subsequent W-grave presses just create more instances instead of hiding the existing one. Also, the urxvtq instance doesn't seem to pay any attention to .Xdefaults, while the urxvtc one does (W-t). Any ideas?
Offline
You can either downgrade xdotool to version 20091231.03-1 or try the other version of the script here.
I've done the former because I only use xdotool for this. I'm hoping that they'll correct this soon (as I'm assuming it's a bug, but I haven't looked into it).
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
Yes, the last two versions of xdotool are broken (bugs are reported upstream):
in xdotool 1.20100302.2713-1 the --onlyvisible option to the 'search' command is broken, see
http://code.google.com/p/semicomplete/i … tail?id=22
in xdotool 1.20100318.2737-1 the --onlyvisible option is fixed again, but --name is now broken, see
http://code.google.com/p/semicomplete/i … tail?id=25
The scripts here mostly use both --onlyvisible and --name, so they'll break with the last two versions of xdotool.
Downgrading to xdotool 1.20100227.2679 should be enough.
EDIT: This seems to be fixed in the current svn version of xdotool (r2753)
Last edited by hbekel (2010-03-30 09:13:45)
Offline
Ah, thanks, the svn version works great! Any ideas how to fix the issue with my .Xdefauts being ignored for the urxvtq terminal?
Offline
In your urxvtq, type
xprop -id $WINDOWID WM_CLASS
This should say
WM_CLASS(STRING) = "urxvtq", "URxvt"
In your Xdefaults you can use either the name portion (first string) or the class portion (second string) to match an application. You can do any of these in your .Xdefaults:
urxvt**background: black
urxvtq**background: blue
URxvt**background: black
The first line will apply to a urxvt with the -name urxvt (default).
The second line will apply to a urxvt started via urxvt -name urxvtq (as it's done in Xyne's script)
The third line will apply to any urxvt, regardless of which -name was given to launch it.
Hope this information is useful...
Offline
Ah, of course! Thanks!
Offline
it doesn't work with last version of xdotool 2.20100524.2888-1
Last edited by silenc3r (2010-05-26 15:03:46)
Offline
Or as an alternative you can use yeahconsole (it is in AUR). Yeahconsole can embed an xterm/urxvt into its windows and will provide a nice dropdown/rollup animation
it took some time to figure out the config so I'll share mine: http://gist.github.com/414613
Offline
When the console first opens it messes up my PS1 var, which contains color codes, a newline char and some unicode characters. I'm not sure what the cause is though because opening urxvt normally doesn't do that. Maybe it's due to the resizing event. Anyway, that line just sends a "ctrl+l" signal to the window to clear it when it first opens (not every time it toggles).
though you already have a solution, this may be of interest. it's an old thread, so i'm not sure if the patch would apply to the latest version but anyway...
//github/
Offline
it doesn't work with last version of xdotool 2.20100524.2888-1
It seems xdotool search --name has changed to --classname, i.e. --name now matches the window title (equivalent to --title) and --classname now matches the first string of WM_CLASS.
In previous versions, --name used to match the first string of WM_CLASS while --title matched the window title.
So you'll likely have to exchange "xdotool search --name" with "xdotool search --classname" in the above scripts.
Offline
It still works with xdotool 2.20100524.2888-1 on my system and I haven't changed anything.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
silenc3r wrote:it doesn't work with last version of xdotool 2.20100524.2888-1
It seems xdotool search --name has changed to --classname, i.e. --name now matches the window title (equivalent to --title) and --classname now matches the first string of WM_CLASS.
In previous versions, --name used to match the first string of WM_CLASS while --title matched the window title.
So you'll likely have to exchange "xdotool search --name" with "xdotool search --classname" in the above scripts.
Thanks a lot, it helps
Offline
I would really appreciate if someone told me where i went wrong... None of the key commands even works... urxvt works normally tho
#!/bin/bash
wid=$(xdotool search --name urxvtq | grep -m 1 "" )
if [ -z "$wid" ]; then
/home/tomas/.config/openbox/urxvtc -name urxvtq -pe tabbed -geometry 80x28
wid=$(xdotool search --classname urxvtq | head -1)
xdotool windowfocus $wid
xdotool key Control_L+l
else
if [ -z "$(xdotool search --onlyvisible --classname urxvtq 2>/dev/null)" ]; then
xdotool windowmap $wid
xdotool windowfocus $wid
else
xdotool windowunmap $wid
fi
fi
<keybind key="W-x">
<action name="Execute">
<command>/home/tomas/.config/openbox/urxvtc</command>
</action>
</keybind>
<keybind key="W-¸">
<action name="Execute">
<execute>/home/tomas/.config/openbox/urxvtq</execute>
</action>
</keybind>
<applications>
<application name="urxvtq">
<decor>no</decor>
<position force="yes">
<x>center</x>
<y>0</y>
</position>
<desktop>all</desktop>
<layer>above</layer>
<skip_pager>yes</skip_pager>
<skip_taskbar>yes</skip_taskbar>
<maximized>Horizontal</maximized>
</application>
tomas
Offline
Do you have this line in autostart.sh?
urxvtd -f & #Terminal
Offline