Monday, May 12, 2008

The syntax of a Menu Command

Here's what you may have noticed. The vast majority of menu commands has a very simple structure, and it comes in one of two simple forms

One form to simply open an application, that works like this:

[exec] (text to display in menu) {application}

for example:
[exec] (firefox) {firefox}
[exec] (kaffeine) {kaffeine}
[exec] (virtual desktops) {kpager}

As you can see, the text to display in the menu and the command are often identical. In Linux, the name of the command is usually the name of the application.

The second form of a menu command isn't much more complicated:
[exec] (text to display in menu) {application object}

The command basically says: This opens that. For example:


Konqueror opens the "Pictures" directory
[exec] (image){konqueror ~/Pictures}*

*Note: the tilde sign represents the user's home/directory.



Firefox opens the Netflix website:
[exec] (netflix) {firefox http://www.netflix.com}

Kaffeine opens my favorite movie:
[exec] (netflix) {kaffeine ~/Videos/"Faster, Pussycat, Kill, Kill.avi"}*

*Note: quotes are needed when file names contain spaces.


Incidentally, the simple syntax that I've described here is often the syntax used by the much-dreaded Linux Command line.







A Painfully Detailed Look at the Menu -- The Painful Overview

Here's what the default version of the mainmenu for Kickbox 0.02 looks like:



And here's the code from /home/kickbox_user/.fluxbox/

Looks like a lot of typing, but it's more precisely a lot of copying and pasting. And it's simple. Look at the code for about five minutes, and there's a good chance that you'll realize that you already know how it works. If not? Well, that's good news for me. I'll be going over this again and again, and I was afraid I was going to be doing it all alone.

[begin] (kickbox 0.2)
[exec] (konqueror) {konqueror ~/.fluxbox/kickpage/kickpage.html}
[exec] (home) {konqueror ~}
[exec] (firefox) {firefox}
[submenu] (applications)
[submenu](favorites)
[exec] (kwrite) {kwrite}
[exec] (knotes) {knotes}
[exec] (kaffeine) {kaffeine}
[exec] (ktorrent) {ktorrent}
[exec] (seamonkey) {seamonkey}
[exec] (dolphin) {dolphin}
#[exec] () {}
#[exec] () {}
#[exec] () {}
#[exec] () {}
#[exec] () {}
#[exec] () {}
#[exec] () {}
#[exec] () {}
#[exec] () {}
#[exec] () {}
#[exec] () {}
#[exec] () {}
#[exec] () {}
#[exec] () {}
#[exec] () {}
#[exec] () {}
[end]
[submenu] (menus)
[exec] (general) {konqueror applications:/}
[exec] (system) {konqueror applications:/System/}
[exec] (utilities) {konqueror applications:/Utilities/}
[exec] (internet) {konqueror applications:/Internet/}
[exec] (multimedia) {konqueror applications:/Multimedia/}
[exec] (office) {konqueror applications:/Office/}
[exec] (games) {konqueror applications:/Games/}
[exec] (graphics) {konqueror applications:/Graphics/}
[exec] (edutainment) {konqueror applications:/Edutainment/}
[exec] (development) {konqueror applications:/Development/}
[exec] (settings) {konqueror applications:/Settingsmenu/}
[end]
[end]
[submenu](navigation)
[submenu](system)
[exec] (storage media) {konqueror media:/}
[exec] (network folders) {konqueror remote:/}
[exec] (trash) {konqueror trash:/}
[exec] (konqueror Help) {konqueror}
[end]
[exec] (home) {konqueror ~}
[exec] (desktop) {konqueror ~/Desktop}
[exec] (root) {konqueror /}
[exec] (documents) {konqueror ~/Documents}
[exec] (music) {konqueror ~/Music}
[exec] (pictures) {konqueror ~/Pictures}
[exec] (public) {konqueror ~/Public}
[exec] (templates) {konqueror ~/Templates}
[exec] (fluxbox files){konqueror ~/.fluxbox}
#[exec] () {konqueror }
#[exec] () {konqueror }
#[exec] () {konqueror }
#[exec] () {konqueror }
#[exec] () {konqueror }
#[exec] () {konqueror }
#[exec] () {konqueror }
#[exec] () {konqueror }
#[exec] () {konqueror }
#[exec] () {konqueror }
#[exec] () {konqueror }
#[exec] () {konqueror }
#[exec] () {konqueror }
[end]
[submenu](bookmarked media)
#[exec] (Rute User Manual) {konqueror Rute.pdf}
#[exec] (Beatles) {xmms ~/Documents/playlists/mozart.m3u}
#[exec] (Night of The Living Dead) {kaffeine ~/Videos/"Night of the Living Dead.mpg"}
#[exec] () {}
#[exec] () {}
#[exec] () {}
#[exec] () {}
#[exec] () {}
#[exec] () {}
#[exec] () {}
#[exec] () {}
#[exec] () {}
#[exec] () {}
#[exec] () {}
#[exec] () {}
#[exec] () {}
#[exec] () {}
#[exec] () {}

[end]
[submenu](webpages)
[exec] (google) {firefox http://www.google.com}
[exec] (justlinux) {firefox http://www.justlinux.com}
[exec] (ubuntu how-to) {firefox http://www.funnestra.org/ubuntu/gutsy/}
[exec] (youtube) {firefox http://www.youtube.com}
[exec] (npr) {firefox http://www.npr.org}
[exec] (CoolText) {firefox http://www.cooltext.com}
[exec] (linux commands) {firefox http://www.oreillynet.com/linux/cmd/}
[exec] (imageshack) {firefox http://imageshack.us/}
[exec] (fluxbox site) {firefox http://www.}
#[exec] () {firefox http://www. }
#[exec] () {firefox http://www. }
#[exec] () {firefox http://www. }
#[exec] () {firefox http://www. }
#[exec] () {firefox http://www. }
#[exec] () {firefox http://www. }
#[exec] () {firefox http://www. }
#[exec] () {firefox http://www. }
#[exec] () {firefox http://www. }
#[exec] () {firefox http://www. }
#[exec] () {firefox http://www. }
#[exec] () {firefox http://www. }
#[exec] () {firefox http://www. }
#[exec] () {firefox http://www. }
#[exec] () {firefox http://www. }
#[exec] () {firefox http://www. }
[end]
[submenu](configure kickbox)
[exec] (navigate to files) {konqueror ~/.fluxbox}
[submenu](edit kickbox files)
[exec] (edit menu){kwrite ~/.fluxbox/menu}
[exec] (edit keys){kwrite ~/.fluxbox/keys}
[exec] (edit init){kwrite ~/.fluxbox/init}
[exec] (edit kickpage){kwrite ~/.fluxbox/kickbox/kickbox.html}

[end]
[submenu] (backgrounds) {Set the Background}
[exec] (random background) {fbsetbg -r ~/.fluxbox/backgrounds/}
[exec] (KDE blue) {fbsetbg -a ~/.fluxbox/backgrounds/default_blue.jpg}
[exec] (orange synapses) {fbsetbg -a ~/.fluxbox/backgrounds/AbdentalHiRes.jpg}
[exec] (mars sucks) {fbsetbg -a ~/.fluxbox/backgrounds/mars5.jpg.fluxbox/backgrounds/backgrounds/fulmine.jpg}
[exec] (wonton) {fbsetbg -a ~/.fluxbox/backgrounds/wonton.jpg}
[exec] (raindrops) {fbsetbg -a ~/.fluxbox/backgrounds/raindrops.jpg}
[exec] (kickbox2) {fbsetbg -a ~/.fluxbox/backgrounds/kickbox2.jpg}
#[exec] () {fbsetbg -a}
#[exec] () {fbsetbg -a}
#[exec] () {fbsetbg -a}
#[exec] () {fbsetbg -a}
#[exec] () {fbsetbg -a}
#[exec] () {fbsetbg -a}
#[exec] () {fbsetbg -a}
#[exec] () {fbsetbg -a}
#[exec] () {fbsetbg -a}
#[exec] () {fbsetbg -a}
#[exec] () {fbsetbg -a}
[end]
[submenu] (User Styles) {Choose a style...}
[stylesdir] (~/.fluxbox/styles)
[end]
[config] (Configure)
[submenu] (System Styles) {Choose a style...}
[stylesdir] (/usr/X11R6/share/fluxbox/styles)
[stylesdir] (/usr/share/commonbox/styles/)
[end]
[end]
[submenu](mount)
[exec] (cdrom) {sudo mount /dev/cdrom}
[exec] (eject) {sudo eject}
[end]

[exec] (trash) {konqueror trash:/}
[exec] (virtual desktops) {kpager}
[restart] (restart)
[exit] (exit)
[exec] (terminal) {konsole}
[end]

A Painfully Deatailed Look at The Menu - Introduction

And now, we get to the menu, the guts of the whole thing. Once again, I'm going to provide as much detail as I possibly can, and that's probably more than you're ever going to need. Don't read these posts, study them. Look at the scripts, look at the screenshots, look at the templates, and you ought to be able to figure out how this works with a great deal of ease.

Editing your menu with a text editor may seem archaic, but it can save you a huge amount of time. The best part for me is the portability. If you hold onto the files (I like to periodically upload them to my gmail and yahoo mail accounts) you can use them again and again. For years, I was a confirmed distro hopper and serial reinstaller, and I love to use Linux on old computers. I used the same fluxbox files for a couple of years. Through five computers, approximately a dozen releases of approximately a half-dozen Linux distros, and a series of compulsive reinstalls that must have reached into the hundreds, I was always able to get everything exactly where I wanted it in the time it takes to copy my files to ~/.fluxbox. Five minutes later, I'm all set up and doing my thing.

Kickbox 0.02 released!

From the release notes:

The first revision!

Kickbox is a simple, powerful hack of the fluxbox window
manager for Linux.. The idea is to rethink the menu
to integrate KDE applications
into fluxbox, and to better utilize the fluxbox
menu's potential to do things other than open up applications.
It turns out that Fluxbox and Konqueror are a match made in
desktop heaven. Kickbox uses Konqueror to navigate the system
to generate graphical menus, to mount storage media, and
view documents.

KIckbox also adds built-in editing templates to the
configuration files, and includes a variety of shortcuts
to provide fast, easy access to those files for editing.
Making fluxbox your own was never easier.

Finally, the most important part of this project may be
the documentation that is underway at:

http://www.allaboutkickbox.blogspot.com


CONTENTS:
What you have here is a set of elaborately rewritten
configuration files for Fluxbox, nothing more,
nothing less.

Okay, that's not strictly true. Also included are a
couple dozen backgrounds which are set up to open at
random each time Kickbox restarts. I added several more
backgrounds to this edition, being less convinced that
"yellow jacket" my original theme for kickbox 0.01, is not
as ugly as original sin. I removed several of my original
wallpapers, and added some others that appear to gpl'd,
including some default KDE wallpapers. So my crazy
wallpapers won't come up so much.

In order for these to work effectively
on your system as written, the following must be installed:

Fluxbox
KDE 3
firefox
and you may need feh (an image viewer) in order for the
backgrounds to display to best effect (Alternately, you
may be able to use another image viewer, and fix the files
accordingly.)

The current version of these files has been tested on Ubuntu 8.04,
and on Vector Linux SoHo 5.8, but I've been working on these files for about
two to three years, and I've used earlier versions with Slackware,
openSUSE, and Debian (stable and unstable).

blackbox_jones

thewackydoctor@gmail.com

for more information, go to
http://www.allaboutkickbox.blogspot.com


Kickbox is released under the GPL, and comes with no
warranty, to the extent permitted by applicable law.

Saturday, May 10, 2008

Fast Editing Hint #2: Copy and Paste from Konqueror to text

Have you ever tried graphically copying a file from Konqueror (or another graphical file manager) and pasting it into a text file? Paste it into another graphical window, and the file itself will be copied into the corresponding directory. On the other hand, if you paste it into a test file, What you get is the instructions for finding the file: the file's url, or absolute path:

file:///files/audio/garage-punk/01_pink_stainless_tail_free_software_song.ogg

This is important information. It's useful for scripting, for using the command line, or for editing your kickbox files. You didn't have to type it, and there's no chance of making a mistake.

Here's an example of how to use this info, which has been obtained so quickly, so accurately, and so ...graphically.


1. If I want to add a link to the PDF file "Emacs Beginner How To" to my menu under book marked files, the first thing I do is copy it to the clipboard with Konqueror (Turns out that this is exceedingly hard to capture in a screenshot.)

I can highlight the item and hit Ctrl+C or I can right click on the item and choose "copy" from the popup menu.



2. I open the "menu" text file (Ctrl + Shift + F1), and find the template for the "Bookmark Files" menu



3. I paste in the verbatim path information from the clipboard, which, when translated into text, looks like this:
file:///files/books/Emacs-Beginner-HOWTO.pdf,
into the appropriate space, and fill in the rest of the information (The title for the menu display, the application needed to open the file)



4. I save the file, and I have a new menu item.

Fast Editing Hint #1 Instant access to edit Kickbox files:

Kickbox has been designed to make editing files fast and easy. One way it accomplishes this is with built-in templates.

Another way is to provide fast, easy access to the configuration files. The easier it is to edit your files, the easier it is to make kickbox your own. You shouldn't have to interrupt your work, or your play to to add to or adjust your menu. You should be able to get into the files with just a click or a modified keystroke, make a fast change, save the file, and get out.

So I've included, by default, three ways to access the files fast, using the Kwrite test editor.

1. Keyboard shortcuts.

Ctrl + Shift + F1 opens the menu text file (~/.fluxbox/menu)
Ctrl + Shift + F2 opens the keyboard shortcuts text file (~/.fluxbox)
Ctrl + Shift + F3 opens the Kickpage html file
Ctrl + Shift + F4 opens the startup file (~/.fluxbox.init)*


*planned for the next release, probably in June2008


2. Menu shortcuts



3. Kickpage buttons


Friday, May 9, 2008

An introduction to editing Kickbox with templates.

You program Kickbox by editing text-based files. That's how you construct and organize the menus, set the shortcuts, choose the html links for the kickpage, and even determine the color schemes of the menus. This may seem archaic if you're used to setting preferences for interfaces with gui menus, but the beauty of text files is that they can be saved, reused, shared, transferred to different computers and different distros.

In preparing the menu, the key and the kickbox files, I have added simple templates to the original fluxbox configuration files. This should not only make programming Kickbox exactly how you like it extremely easy, it should also make programming Kickbox extremely easy to learn. It was never especially difficult... but now, there's an excellent chance that you'll be able to skip most if not all of the complete and excruciating exegesis that I intend to provide here.

The templates are simply menu items with the specific information left out, and the "#" ("comment") symbol at the front of the line.

For example, here are somelines from my own personal "web pages" menu:


[exec] (youtube) {firefox http://www.youtube.com}
[exec] (netflix) {firefox http://www.netflix.com}
[exec] (npr) {firefox http://www.npr.org}
[exec] (CoolText) {firefox http://www.cooltext.com}
[exec] (Commercials I hate) {firefox http://www.mad-about-ads.com/}
[exec] (myspace) {firefox http://www.myspace.com}
[exec] (linux commands) {firefox http://www.oreillynet.com/linux/cmd/}
[exec] (This American Life) {firefox http://thisamericanlife.org/Radio_Archive.aspx}
[exec] (image shack) {firefox http://imageshack.us/}
#[exec] () {firefox http://www. }
#[exec] () {firefox http://www. }
#[exec] () {firefox http://www. }
#[exec] () {firefox http://www. }
#[exec] () {firefox http://www. }
#[exec] () {firefox http://www. }
#[exec] () {firefox http://www. }
#[exec] () {firefox http://www. }


The top part is menu items, the bottom part is potential menu items. There's an excellent chance that just by looking at these lines, you'll be able to edit one of the bottom lines to add a fast link to any web page you desire. Study the menu for a few minutes, and you may be able to figure out that:

#[exec] () {firefox http://www. }


just needs a title and a web url to become

[exec] (All About Kickbox) {firefox http://www.allaboutkickbox.blogspot.com}


So you may not need to read most of the tedious crap I'm about to write. Good luck with that.

If you need it, it's going to be here, lavishly illustrated with screenshots, and indexed so that you'll be able to find what you're looking for without too much pain. But the principles are simple, and I'm going to repeat them over and over and over. The following in

Next comes a couple of hints, however, that you're going to want to know. You may want to read these; they're brief.