/bigbashview

BigBashView is a script to run Bash+HTML in a Desktop WebView.

Primary LanguagePython

BigBashView

Logo do BigBashView

Graphical Frontends for ShellScripts using HTML/JS/CSS

Is a interface for rendering bash output using QWebEngine or WebKitGtk2. It rendering also supports a wide variety of languages, such as Python, Ruby, Perl and PHP.

Advantages

  • Create powerful frontend using common known languages, such as HTML, JS and Shell!
  • Demo for all functions available!
  • Smooth learning curve!

Pré-requisites

  • Python >= 3.0
  • Git >= 2.0

Install

Arch Based

# Python dependencies
pip install web.py
pip install setproctitle
pip install PyQt6-WebEngine
pip install PyQtWebEngine

# Clone project
git clone git@github.com:biglinux/bigbashview.git
cd bigbashview/pkgbuild/

# Remove broken dependencies
sed -Ei 's/depends/\#depends/' PKGBUILD

# Compile and install
makepkg -si

# Test
bigbashview 'execute$echo Hello World!'

Tela de boas vidas do BigBashView

Usage

To run BigBashView, you must execute the bigbashview.py script. There are serveral command line arguments that can be used as following:

./bigbashview.py [-h|--help] [-s|--screen=widthxheight] [-v|--version] [-t|--toolkit=[gtk|qt|]] [-w|--window_state=[normal|maximized|fullscreen]] [-i|--icon image] [-c|--compatibility-mode] [-r|--root] [-d|--debug] URL

Where URL is a URL or a server path as documented bellow

Options

-h, --help
Show the list of available options and exit

-s, --screen=widthxheight
Change the screen size for a specific widthxheight

-v, --version
Show version number and exit

-t, --toolkit=[gtk]
Chooses the graphical toolkit to use. QT(5) or GTK(3) UI

-w, --window_state=[normalximized|fullscreen]
Change how the window will show, it can be normal, maximized or fullscreen

-i, --icon=image
Change BigBashView window icon

-c, --compatibility-mode
Enables BigBashView compatibility mode

-r, --root
Disable sandbox in QT UI for work as root. *only 

-d, --debug
Enable remote debugging *only 

Test

To create a hello world window, just call BigBashView as follows:

./bigbashview.py 'execute$echo Hello World!'

Janela exibindo um Hellow Word!

To create a more fancy hello world, you coud try to create a script and call it, as follows:

vim hello.sh
#!/usr/env/bin bash
echo "
<html>
  <head>
    <title>Hello World at BigBashView</title>
  </head>
  <body>
    <h1>Hello $USER!</h1>
    <p>`date`</p>
  </body>
</html>
"
$chmod +x hello.sh
./bigbashview.py 'execute$hello.sh'

Server Options

As you saw above, to execute the hello.sh script, we used execute$

This syntax works like this:

command <options>$ <value>

The available commands are:

Command Description
execute execute value in your shell environment, and returns to the page everything that was printed to stdout
content returns the contents of the file at ``

The available options are:

Option Description
plain Set the web header Content type to text/plain
close _only for execute command_ Closes BigBashView after value execution

This same syntax can be used in URLs on links, images and everything on your webpage, just remember to put a / before to use it.

To get some examples on how to use server options, see the folder server_options inside the demos folder of your BigBashView package

Creating Forms

After creating a form, set it on the action to send to server to execute the script. for example:

<form action="execute$./process_form.sh"></form>

in the process_form.sh you will get all post (or get) values in system variables named like:

p_fieldname

To get an example on how to create a form, see the folder form inside the demos folder of your BigBashView package

Common JavaScript and HTML Tips

Some HTML and JavaScript window manipulations will work on BigBashView windows.

Lang Event Action Work
HTML/JavaScript on Behavior on BigBashView Window All
HTML <title> Change window title All
HTML <link rel="shortcut icon" href=""> Change window icon _only Q
JavaScript window.close Closes the window All
JavaScript window.resizeTo Resizes the window _only GT
JavaScript window.moveTo Moves the window _only GT

To see those JavaScript and HMTL tips in action, see the folder javascript_html_tips inside the demos folder of your BigBashView package

Closing the Window

As you can see here, there are some issues related to JavaScript window.close when the window has navigated.

To workaround this, you can tell server to shutdown the application, calling the close option like this:

<a href="execute close$">Close the window</a>

This option will only work with the execute command. Optionally you can, in your script, print "False" to stderr so the server will not close the window, like that:

<a href="execute close$echo False">This does not close the window</a>

This way you can show a dialog confirmation before closing the window.

To get some examples on how to use this syntax, see the folder window_close inside the demos folder of your BigBashView package.

Compatibility Mode

To enable the compatibility mode, you need to use the -c or --compatibility-mode argument option when starting the application.

  • The urls cannot contain file://, only the absolute path for the file
  • You need to use the absolute path for the file. Relative paths wont work
  • The old HTML tag <scripttool> is not available even in compatibility mode

In comptibility mode, the URLs will not contain commands, just the path for the file. BigBashView will try to guess what to do with the file according its extension.

Extension BBV Action
.sh,.sh.html,.sh.htm Execute the file and return the result as HTML
.htm, .html Open the file and return its content as HTML
.txt Open the file and return its content as TXT

To get some examples on how to use compatibility mode, see the folder compatibility_mode inside the demos folder of your BigBashView package.

Legacy Refrences