Archive for October, 2007

Get a Quake like Linux Console in Windows

Friday, October 5th, 2007

When I saw Yakuake for Linux I began the long journey to find a similar product for Windows. I normally like to use CentOS Linux for all my needs but for gaming and at work I am forced to use Windows. I may be the system administrator but a lot of our products are written in .NET which is Windows Dependant making a switch to Linux at work currently impossible.

Quake Console

Screenshot note: This may look like a Linux XFCE Desktop but it is actually a Windows XP Desktop. See my other article: Give XP (Linux/Mac) looks and shame Vista

This will require some minor tweaks using a text editor depending on your screen size and positioning you want for you console. I will walk you through most of the steps and even give you a download of my setup to make it as simple as possible.

Step 1:

Acquire my download of the software and unzip it to your “C:\” drive. This should give you a default copy of Cygwin, a tweaked copy of Console2 for windows, and my generated binary for binding the “WIN-~” key combo to the console.

Download: Quake style console default install

Step 2:

Test the default install. Run the “Quake.exe” binary in the “C:\Console2″ folder. You will now see a green “H” in your system tray. This is the key binder. It listens for the key combination “WIN-~” and then executes the Console2 program which is skinned using a custom XML file and then executes Cygwin within the console giving you the Linux prompt and feel.

At this point you will discover that to console may be too big if your resolution is less than (1024×768) or may be too small if your resolution is larger than (1024×768). You may also not be pleased with the placement or any one of the other features. These can all be altered.

Step 3:

Customize! The file you will want to edit with any text editor will be located at “C:\Console2\console.xml”. This will allow you to edit all of the features of the console (Look and feel). Basically allowing you to create your own skin and positioning for the console.

The current console.xml file contains:

<?xml version=”1.0″?>
<settings>
<console change_refresh=”10″ refresh=”100″ rows=”25″ columns=”122″ buffer_rows=”500″ buffer_columns=”0″ shell=”" init_dir=”" save_size=”0″>
<colors>
<color id=”0″ r=”0″ g=”0″ b=”0″/>
<color id=”1″ r=”0″ g=”0″ b=”128″/>
<color id=”2″ r=”0″ g=”150″ b=”0″/>
<color id=”3″ r=”0″ g=”150″ b=”150″/>
<color id=”4″ r=”170″ g=”25″ b=”25″/>
<color id=”5″ r=”128″ g=”0″ b=”128″/>
<color id=”6″ r=”128″ g=”128″ b=”0″/>
<color id=”7″ r=”192″ g=”192″ b=”192″/>
<color id=”8″ r=”128″ g=”128″ b=”128″/>
<color id=”9″ r=”0″ g=”100″ b=”255″/>
<color id=”10″ r=”0″ g=”255″ b=”0″/>
<color id=”11″ r=”0″ g=”255″ b=”255″/>
<color id=”12″ r=”255″ g=”50″ b=”50″/>
<color id=”13″ r=”255″ g=”0″ b=”255″/>
<color id=”14″ r=”255″ g=”255″ b=”0″/>
<color id=”15″ r=”255″ g=”255″ b=”255″/>
</colors>
</console>
<appearance>
<font name=”Courier New” size=”10″ bold=”0″ italic=”0″ smoothing=”0″>
<color use=”0″ r=”0″ g=”0″ b=”0″/>
</font>
<window title=”" icon=”" use_tab_icon=”0″ use_console_title=”0″ show_cmd=”1″ show_cmd_tabs=”1″ use_tab_title=”1″ trim_tab_titles=”20″/>
<controls show_menu=”0″ show_toolbar=”0″ show_statusbar=”0″ show_tabs=”1″ hide_single_tab=”1″/>
<styles caption=”1″ resizable=”0″ taskbar_button=”1″ border=”0″ inside_border=”2″ tray_icon=”0″/>
<position x=”20″ y=”0″ dock=”-1″ snap=”0″ z_order=”0″ save_position=”0″/>
<transparency type=”1″ active_alpha=”200″ inactive_alpha=”100″ r=”0″ g=”0″ b=”0″/>
</appearance>
<behavior>
<copy_paste copy_on_select=”0″ clear_on_copy=”1″ no_wrap=”1″ trim_spaces=”1″ copy_newline_char=”0″/>
<scroll page_scroll_rows=”0″/>
</behavior>
<hotkeys use_scroll_lock=”1″>
<hotkey ctrl=”1″ shift=”0″ alt=”0″ extended=”0″ code=”83″ command=”settings”/>
<hotkey ctrl=”0″ shift=”0″ alt=”0″ extended=”0″ code=”112″ command=”help”/>
<hotkey ctrl=”0″ shift=”0″ alt=”1″ extended=”0″ code=”115″ command=”exit”/>
<hotkey ctrl=”1″ shift=”0″ alt=”0″ extended=”0″ code=”112″ command=”newtab1″/>
<hotkey ctrl=”1″ shift=”0″ alt=”0″ extended=”0″ code=”113″ command=”newtab2″/>
<hotkey ctrl=”1″ shift=”0″ alt=”0″ extended=”0″ code=”114″ command=”newtab3″/>
<hotkey ctrl=”1″ shift=”0″ alt=”0″ extended=”0″ code=”115″ command=”newtab4″/>
<hotkey ctrl=”1″ shift=”0″ alt=”0″ extended=”0″ code=”116″ command=”newtab5″/>
<hotkey ctrl=”1″ shift=”0″ alt=”0″ extended=”0″ code=”117″ command=”newtab6″/>
<hotkey ctrl=”1″ shift=”0″ alt=”0″ extended=”0″ code=”118″ command=”newtab7″/>
<hotkey ctrl=”1″ shift=”0″ alt=”0″ extended=”0″ code=”119″ command=”newtab8″/>
<hotkey ctrl=”1″ shift=”0″ alt=”0″ extended=”0″ code=”120″ command=”newtab9″/>
<hotkey ctrl=”1″ shift=”0″ alt=”0″ extended=”0″ code=”121″ command=”newtab10″/>
<hotkey ctrl=”1″ shift=”0″ alt=”0″ extended=”0″ code=”49″ command=”switchtab1″/>
<hotkey ctrl=”1″ shift=”0″ alt=”0″ extended=”0″ code=”50″ command=”switchtab2″/>
<hotkey ctrl=”1″ shift=”0″ alt=”0″ extended=”0″ code=”51″ command=”switchtab3″/>
<hotkey ctrl=”1″ shift=”0″ alt=”0″ extended=”0″ code=”52″ command=”switchtab4″/>
<hotkey ctrl=”1″ shift=”0″ alt=”0″ extended=”0″ code=”53″ command=”switchtab5″/>
<hotkey ctrl=”1″ shift=”0″ alt=”0″ extended=”0″ code=”54″ command=”switchtab6″/>
<hotkey ctrl=”1″ shift=”0″ alt=”0″ extended=”0″ code=”55″ command=”switchtab7″/>
<hotkey ctrl=”1″ shift=”0″ alt=”0″ extended=”0″ code=”56″ command=”switchtab8″/>
<hotkey ctrl=”1″ shift=”0″ alt=”0″ extended=”0″ code=”57″ command=”switchtab9″/>
<hotkey ctrl=”1″ shift=”0″ alt=”0″ extended=”0″ code=”48″ command=”switchtab10″/>
<hotkey ctrl=”1″ shift=”0″ alt=”0″ extended=”0″ code=”9″ command=”nexttab”/>
<hotkey ctrl=”1″ shift=”1″ alt=”0″ extended=”0″ code=”9″ command=”prevtab”/>
<hotkey ctrl=”1″ shift=”0″ alt=”0″ extended=”0″ code=”87″ command=”closetab”/>
<hotkey ctrl=”1″ shift=”0″ alt=”0″ extended=”0″ code=”82″ command=”renametab”/>
<hotkey ctrl=”1″ shift=”0″ alt=”0″ extended=”1″ code=”45″ command=”copy”/>
<hotkey ctrl=”1″ shift=”0″ alt=”0″ extended=”1″ code=”46″ command=”clear_selection”/>
<hotkey ctrl=”0″ shift=”1″ alt=”0″ extended=”1″ code=”45″ command=”paste”/>
<hotkey ctrl=”0″ shift=”0″ alt=”0″ extended=”0″ code=”0″ command=”scrollrowup”/>
<hotkey ctrl=”0″ shift=”0″ alt=”0″ extended=”0″ code=”0″ command=”scrollrowdown”/>
<hotkey ctrl=”0″ shift=”0″ alt=”0″ extended=”0″ code=”0″ command=”scrollpageup”/>
<hotkey ctrl=”0″ shift=”0″ alt=”0″ extended=”0″ code=”0″ command=”scrollpagedown”/>
<hotkey ctrl=”0″ shift=”0″ alt=”0″ extended=”0″ code=”0″ command=”scrollcolleft”/>
<hotkey ctrl=”0″ shift=”0″ alt=”0″ extended=”0″ code=”0″ command=”scrollcolright”/>
<hotkey ctrl=”0″ shift=”0″ alt=”0″ extended=”0″ code=”0″ command=”scrollpageleft”/>
<hotkey ctrl=”0″ shift=”0″ alt=”0″ extended=”0″ code=”0″ command=”scrollpageright”/>
<hotkey ctrl=”1″ shift=”1″ alt=”0″ extended=”0″ code=”112″ command=”dumpbuffer”/>
</hotkeys>
<mouse>
<actions>
<action ctrl=”0″ shift=”0″ alt=”0″ button=”1″ name=”copy”/>
<action ctrl=”0″ shift=”1″ alt=”0″ button=”1″ name=”select”/>
<action ctrl=”0″ shift=”0″ alt=”0″ button=”3″ name=”paste”/>
<action ctrl=”1″ shift=”0″ alt=”0″ button=”1″ name=”drag”/>
<action ctrl=”0″ shift=”0″ alt=”0″ button=”2″ name=”menu”/>
</actions>
</mouse>
<tabs>
<tab title=”">
<console shell=”" init_dir=”"/>
<cursor style=”0″ r=”255″ g=”255″ b=”255″/>
<background type=”0″ r=”0″ g=”0″ b=”0″>
<image file=”" relative=”0″ extend=”0″ position=”0″>
<tint opacity=”0″ r=”0″ g=”0″ b=”0″/>
</image>
</background>
</tab>
</tabs>
</settings>

For editing the size of the console you will want to edit the rows=”25″ columns=”122″ to whatever fits your screen. You may need to experiment until it is right.

If you would like to create your own keybinding you will have to download Autohotkey from “http://www.autohotkey.com/“. You will have to edit the “C:\Console2\quake.ahk” file and recreate the “quake.exe” binary.

Here is a copy of my current “quake.ahk” file:

; Launch console if necessary; hide/show on Win+`
#`::
DetectHiddenWindows, on
IfWinExist ahk_class ATL:00456188
{
IfWinActive ahk_class ATL:00456188
{
WinHide ahk_class ATL:00456188
; need to move the focus somewhere else.
WinActivate ahk_class Shell_TrayWnd
}
else
{
WinShow ahk_class ATL:00456188
WinActivate ahk_class ATL:00456188
}
}
else
Run, C:\Console2\Console.exe -d C:\cygwin\ -r “cmd /C Cygwin.bat”
; the above assumes a shortcut in the c:\windows folder to console.exe.
; also assumes console is using the default console.xml file, or
; that the desired config file is set in the shortcut.

DetectHiddenWindows, off
return

; hide console on “esc”.
#IfWinActive ahk_class ATL:00456188
esc::
{
WinHide ahk_class ATL:00456188
WinActivate ahk_class Shell_TrayWnd
}
return

In the above script you will notice,

“C:\Console2\Console.exe -d C:\cygwin\ -r “cmd /C Cygwin.bat”

That is the command that runs when the “WIN-~” key is pressed. It runs console and then console automatically runs Cygwin. Pretty nice and dirty hack.

Console was obtained from “http://sourceforge.net/projects/console/“. This basically gives you the XML customizable extended windows console that we edited above.

Cygwin was obtained from “http://www.cygwin.com/“. This is what gives you the Linux bash prompt inside the Console program. It can be run independently, but it wouldn’t look as cool.

Final Step:

Create a startup shortcut for “C:\Console2\quake.exe” in “C:\Documents and Settings\%username%\Start Menu\Programs\Startup\” folder so that it runs the keybinding software automatically when the system starts.

I would recommend reading up on all three of these wonderful products listed above. Enjoy!