Quote:
Originally Posted by Basher52
When the OS is started the web browser is supposed to start automatically and immediately show the intranet web page.
|
How about a webkit browser implemented in Python?
Make sure you have
python-gtk2,
python-webkit,
python-gobject, and some
ttf-* font packages installed, and you can use this script as a browser:
Code:
#!/usr/bin/env python
import signal
import gtk # package python-gtk2
import webkit # package python-webkit
import gobject # package python-gobject
rooturl = "http://www.linuxquestions.org/questions/"
# Signal handler: reload the root URL.
def handler(signum, frame):
global browser, rooturl
browser.open(rooturl)
# Set SIGHUP handler: send a HUP signal to reload root URL.
signal.signal(signal.SIGHUP, handler)
# Instead of closing the window, reload the root URL.
def onclose(widget, event):
global browser, rooturl
browser.open(rooturl)
return True
# Create a fullscreen window
gobject.threads_init()
window = gtk.Window()
window.fullscreen()
# Handle window close events using onclose() defined above
window.connect("delete-event", onclose)
# Create a widget adding scrollbars
view = gtk.ScrolledWindow(None, None)
view.set_border_width(0)
view.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
window.add(view)
# Create a new webkit browser
browser = webkit.WebView()
browser.open(rooturl)
# Set browser settings to your liking
settings = webkit.WebSettings()
settings.set_property("default-font-family", "Serif")
settings.set_property("serif-font-family", "Serif")
settings.set_property("sans-serif-font-family", "Sans")
settings.set_property("monospace-font-family", "Monospace")
settings.set_property("default-font-size", 14)
browser.set_settings(settings)
# Show the browser
view.add(browser)
window.show_all()
# and let the browser handle it all.
gtk.main()
If you save it as
browser.py, you can run it using
python browser.py URLor just
./browser.py URL.
The script expands to fullscreen, and is a real webkit-based browser. Just try it
You cannot close the browser window from itself. Try, and it will just reload the starting URL.
You can make the browser reload the original page externally, by sending the process the HUP signal:
Code:
kill -HUP $(ps -C python -o pid=,cmd= | awk '($3 ~ /(^|\/)browser\.py$/) { print $1 }')
and you can close the browser window by sending it a TERM signal:
Code:
kill -TERM $(ps -C python -o pid=,cmd= | awk '($3 ~ /(^|\/)browser\.py$/) { print $1 }')
The latter also means that if you shut down the machine, the browser window will gracefully quit.
(In the both above cases, the part following the signal name will evaluate to the process IDs of the python interpreter running
browser.py file.)
Application shortcuts still work. You can even change to another virtual terminal using Alt+F1, Alt+F2, ..., Alt+Left, and Alt+Right keys. I suggest you start another terminal before running the script, so you can close the browser.
It is possible to capture the keyboard altogether (disabling even application shortcuts), but in your case I suggest a simpler alternative: Create a dedicated user account with a plain X11 environment, with only the
browser.py script in the X session. No toolbars, no desktop, no panels.
That way you don't have any application shortcuts to worry about (since none of the desktop environment is running, your script is the only one), but you can still switch to a virtual terminal (command-line prompt) using ALT+F1, login, and do changes if the network is down. Obviously, you should have an SSH server running, so you could login remotely and do whatever maintenance (if any!) is needed.