AUTHOR: "Chuck Rhode" <crhode@excel.net>

DATE: 2004-04-17

LICENSE: Public Domain

SYNOPSIS: Define .hotlink File Type

DESCRIPTION:
Gnome .desktop files are awkward to use for browser bookmarks. This is the implementation of a new .hotlink file type, which is handier. It reads Windows shortcuts, too.

ATTACHMENTS:
* HotLink.tar.bz2

PREREQUISITES:
Gnome 2.2
python
pygtk

gnome-python


HINT:

Q: What do you get when you drag a hot link from Mozilla to your Gnome desktop?
A: ... a .desktop file in ~/.gnome-desktop.

Q: Always?
A: No, only if the protocol of the link is http: ....

Q: What can you do with the .desktop link file?
A: Well, you could double click on it. Then Gnome would open the URL of the link in the default browser.

Q: What if I dragged the .desktop link file back to Mozilla?
A: Gnome would tell Mozilla to open the .desktop file. What you would see would be the text of the .desktop file, not the URL of the link.

Q: I am a Windows user, and I am confused.
A: Is that a question?

Let's be clear. The scenario is from Gnome 2.2. Windows users are accustomed to creating and using desktop shortcuts that have a defined purpose and regular function across various versions of the operating system. This is not true of .desktop files under older versions of Gnome although, God willing, the situation may be resolved somehow in later versions.

For now, I have made myself comfortable with Gnome by defining my own kind of .hotlink file that does what I want when I want.

Let's be clear. I'm not going to use the term shortcut any more. Shortcuts are tiny Windows files. They come in two flavors:
My .hotlink file is like a Windows .url file, not a Windows .lnk file. It's like a single-item bookmark -- a list of one thing; it stores one URL. If you double click on it, it opens the URL in the default browser, just as a Gnome .desktop link file would.

Let's be clear. I'm not going to use the term bookmark any more. Bookmark collections are updated and used within browsers. A bookmark points to a URL, which you view in your browser. In fact, a bookmark can point to an actual file such as an .html file if you want your browser to load it from your (local) file system rather than from an http server. In this case, the URL begins with file: rather than http:.

Let's be clear. I'm not going to use the term link, either. Unix file systems have symbolic links, html pages have links to other html pages, and Gnome has .desktop link files. I'll use the term .hotlink to refer to the object of a .hotlink file.

My .hotlink file can contain a file-protocol URL in place of an http-protocol URL if appropriate. A Gnome .desktop link file cannot.

Every user accumulates his own peculiar collection of bookmarks, but, when he wishes to swap browsers, he has to leave his collection behind. I prefer to keep my bookmarks (I mean .hotlinks.) in folders (directories) arranged by topic within my local file system. I can move, copy, and delete my .hotlinks using familiar and reliable file-system commands or even drag and drop procedures. My .hotlinks are stored separatetly from my default browser. Furthermore, they are stored in a browser-independent format. Thus, I can swap browsers or use more than one browser at the same time and still have access to all my .hotlinks.

.hotlink

My .hotlink files are html-format files that browsers can read. However, they are munged so that Gnome's mime-type sniffer doesn't smell them. Instead, I define a new mime-type, x-special/hotlink, based on the .hotlink file extension.

I have written two scripts to edit and to open .hotlink files. These scripts are written in Python. They rely upon requisite software already being installed:
Here is what you can do with a .hotlink file:

HotLink.py

HotLink.py is the .hotlink file editor. Also, it can read .url and .desktop link files. It puts up a dialog box with three blanks:
If called with a file as a parameter, HotLink.py tries to read the file as a .url file, a .desktop file, and, then, as a .hotlink file. If called without a parameter, the blanks are not filled.

As distributed, a .desktop application launcher icon (HotLink.desktop) is installed for HotLink.py. You may drag a .url, .desktop link or .hotlink file to it, or you may double click on it to open it without a file.

You can paste values into the blanks. Alternatively, you can copy a link with your browser's edit command and then paste both the URL and its Title (linked text) into HotLink.py by clicking HotLink.py's paste button. This works from browsers like Mozilla.

Click the save button to create a new .hotlink file under Name.

HotLink.py has two hot spots on the dialog box:

HotTraverse.py

HotTraverse.py reads a .url, .desktop link, or .hotlink file and opens the embedded link in a browser. This is the default action for double clicking on a .url or .hotlink file: HotLink.py opens the link in the default browser. Alternatively, you may specify a particular browser with the -c option on the command line.

As distributed, a .desktop application launcher icon (HotTraverse.desktop) is installed for HotLink.py. You may drag a .url, .desktop link, or .hotlink file to it. If you double click on it, nothing much happens.

HotType.py

HotType.py defines objects common to HotLink.py and HotTraverse.py.

Deploy.py

Deploy.py is the install procedure. Run it from the directory created by unpacking the tarball. It copies components to their installed locations. Examine the Python source to be sure the destination directories are appropriate for your configuration.

tar -jxvf HotLink.bz2
cd HotLink
./Deploy.py

HotLink.mime

HotLink.mime extends the Gnome mime-registry to include x-special/hotlink files based on file extensions of .hotlink and .url.

HotLink.applications

HotLink.applications extends the Gnome application-registry so that HotLink.py and HotTraverse.py can handle x-special/hotlink files.

HotLink.keys

HotLink.keys extends the Gnome mime-registry to define default treatment for .hotlink files.

CHANGELOG:
[2004-04-17]
* First release.


SourceForge.net Logo