Previously in this forum, about 6 months ago, I talked about how to combine XUL, thttpd, ngs-js (or your favorite CGI command-line language like Perl, Python, or PHP), and perhaps SQLite -- all to create Linux standalone applications (instead of web apps).
Well, tonight, I have learned the poorly documented technique for building robust standalone Linux applications with just XUL and perhaps SQLite. There's no longer a need to have a web server (even a tiny, embeddable one like thttpd). I'll have a short example posted here for all you novice programmers wanting to program your first Linux app, or even smart programmers who want to learn a new technique that might make application development easier for you.
Here's how it works:
1. All the end user needs on their Linux PC is Firefox 1.5 or better, and perhaps SQLite or any /usr/bin commands you might want to depend on.
2. The user doubleclicks a single executable binary file (ELF format). (Spoiler: these are made using 'makeself' command.)
3. This file then expands into /tmp and calls a startup Bash script.
4. The startup Bash script calls firefox (or equivalent) by doing:
mozilla -chrome file:/myapp.xul
5. The 'myapp.xul' can either be one single app, or it can include separate images, a SQLite database, separate CSS style sheets, and perhaps some Bash commands or separate Javascript files.
6. Myapp.XUL contains an HTML-like language inside with some special XML header information. You draw the GUI in this.
7. When buttons are clicked in the XUL interface, they can be set to call Javascript handlers in the XUL file or whatever separate Javascript files are included in this XUL file.
8. Now, Javascript on its own doesn't have any persistence (data store) or SQL database connectivity. It also can't do a lot of things that you can do from your /bin, /sbin, /usr/bin, and /usr/sbin directories. To overcome that problem, you have to use a technology called XPCOM, and you do that through Javascript.
9. XPCOM is fairly difficult to use and that's one of the big complaints. However, all you really need to learn are the XPCOM components for file i/o and process execution, intially, and learn the other components later on.
10. Firefox normally turns of XPCOM by default. But there's a special command you type (a hold over from Netscape) that unlocks XPCOM in the browser and permits your Javascript to call XPCOM components.
11. The XPCOM can then shell out to run processes and get results, or interact with files. Although there's an XPCOM component for SQLite interaction, you could always just shell out to the SQLite command to run it too, as well as MySQL or PostgreSQL -- any database you can access from command line on Linux.
Anyway, this is all a lot to go over and I want to show you how to this in the least lines of text. I'll post that on my blog in a week or so and link that in later on.
















Joined: 2006-02-17