Config Tool

What is Config Tool ?

Config Tool is a UI application for shell scripts, which handles HTML and Javascript using webkit.
It can also handles any kind of interpreter as python, perl, but it's not optimized for that.

http://thor27.googlepages.com/configtool_s2.jpg

Who created this?

This application was developper by:
Thomaz "ThOR27" dos Reis thor27 -at- gmail -dot- com - webpage: http://thor27.blogspot.com
Wilson Pinto Júnior wilson -at- openlanhouse -dot- org - webpage: http://www.openlanhouse.org

With a special thanks to BIG BRUNO, who have the idea (and that I really believed it won't work :P)

How do I get this?

You can download version 0.5 from here: http://www.biglinux.net/BigConfigTool-0.5.tar.gz

You can get the latest development version through svn checkout:

svn co http://svn.biglinux.net/apps/config_tool/src config_tool

To use it you will need to have python 2.5 and pyqt4 at least version 4.4.3 wich is available in (K)Ubuntu 8.10. For (K)Ubuntu 8.04 you will need this mirror (Add this line in the bottom of /etc/apt/sources.list):

deb http://ppa.launchpad.net/kubuntu-members-kde4/ubuntu hardy main

With all mirrors correct, to get it you will just need to do:

sudo apt-get install python python-qt4

How do I use this?

The main idea of config_tool is similar to php and others webserver languages, but the main difference is that it doesn't need a webserver and it runs in user space. The idea here is not to open or create webpages, but create graphical applications with shellscript.

Basic Usage

First create a shellscript that outputs html code, for example:

#!/bin/bash
echo '<html><body><h1>Hello World!</h1></body></html>' 

save it to filename.sh and set it as executable:

chmod +x filename.sh

IMPORTANT: The filename MUST ends with ".sh" to work with config_tool (even if you use other interpreters)

now "cd" to the config_tool and runs it:

./bigconfigtool /path/to/filename.sh

and you will see the magic ;)

http://thor27.googlepages.com/configtool_s1.jpg

Application options

You can start the config_tool with some arguments to change some of its behaviour. Here is a list of arguments and what they do.

Option Function
-h or --help Shows a help screen
-s or --screen Set the window size to widthxheight.
Example:
--screen 800x600
the window will show with 800 for width and 600 for height
-v or --version Shows application version and returns
-t or --toolkit Chooses witch toolkit to use to render the window.
qt4: Uses qt4 as toolkit
gtk2: Uses gtk2 as toolkit Not working yet
-w or --window_state Chooses the window state.
normal: Show as windowed
maximized: Show as a maximized window
fullscreen: Show in fullscreen
-i or --icon Set the top left icon of the window.
Example:
--icon /path/to/icon.png
will use icon.png as the window icon.
IMPORTANT: If the loaded page has an icon in it, the icon used will be the page one

Script Variables

There are also some system variables that are created before the script execution, so you can use inside the script for some special features. They are:

WINDOW_WIDTH Contains the window width
WINDOW_HEIGHTContains the window height
SCREEN_WDITH Contains the screen width
SCREEN_HEIGHT Contains the screen height
CT_PID Contains the config_tool process ID
p_list Contains a list of all parameters
Example:
In: script.sh?param1=content1&param2=content2&param3=content3
p_list will contain: param1,param2,param3,
p_PARAMETER_NAME Will contain the content of the parameter PARAMETER_NAME
Example:
In: script.sh?param1=content1&param2=content2&param3=content3
p_param1 will contain content1
p_param2 will contain content2
p_param3 will contain content3

Script Arguments

In a script called that way:

script.sh?param1=content1&param2=content2&param3=content3

the script arguments are going to be:

--param1 content1 --param2 content2 --param3 content3

Special HTML tags

Script Tool recognizes some special html tags. they are:

<scripttool close> Closes the application
<scripttool window=style > Where style can be windowed, maximized and normal
<scripttool size=widthxheight > Change window size to widthxheight

Cool hacks

outputting any application code (Using BigConfigTool 0.5)

What about change the config_tool source code so it could shows any application output?

That it doesn't seems to be a hard task.

First we need to remove the need to end with .sh, so let's go and edit BigConfigTool/ui/qt4.py:

Go to the url_verify method and do this changes:

from:

        file_path=url.path()
	if file_path.endsWith(".sh"):
	    self.BashLoaded=True

to:

            file_path=url.path()
	#if file_path.endsWith(".sh"):
	    self.BashLoaded=True

and

from:

	else:
	    self.web.setUrl(url)

to:

	#else:
	    #self.web.setUrl(url)

now you can start test:

./bigconfigtool ls

to be possible to use parameters, you can make this change in the same method:

from:

parameters+=" \"--"+parameter[0].__str__()+"\" \""+parameter[1].__str__()+"\""

to:

parameters+=" "+parameter[0].__str__()

and add this line before "stdout_handle = os.popen(sys_var+file_path.str()+parameters, "r")":

sys_var=""

now you can just try:

./bigconfigtool ls?-la

the output is just a mess.. this is because html doesn't recognize "\n" as a line wrapper, you need to change all \n to <br />

to do that we will make a simple change in the file BigConfigTool/parser/parser.py

from:

return self.InputHTML

to:

return self.InputHTML.replace("\n","<br/>")

And try it out and you will see the output with all line wrappers ok ;)

And what about use it as a pipe?

ls -la | ./bigconfigtool

Now it's your time to go and hack around!

Known Issues

The javascript function to close window will only works in the script opened by the command line. Other scripts opened by links will not work. Instead you could use 2 different close methods showed in the "exemplo2.sh" file