Instaling Krusader orthodox file manager on Mac OS X Mountain Lion

For the Impatient

Yes, it works! In all its awesome glory!

Click on the image to see the screen shot at its full resolution.

Krusader on Mac OS

The process itself is magical, like everything on Mac  🙂

I had to make a ritual sacrifice of the most precious commodity of them all: time. While I cannot earn it back, I am now writing this up, so that you have time to figure out (and publish in great detail) some other fun project.

Please do not hesitate to point out any omissions/mistakes – if I cannot get it right, there is no point in this whole exercise.

An Introduction, for a Random Visitor

Mac Finder, despite its tight integration and many wonderful features, is not perfect. Not for everyone.

Those of us who transitioned from other operating systems miss such familiar features as directory tree view and the dual-panel layout.  The features hark back to the so-called “orthodox file managers” – a whole dynasty of software that started with the venerable Norton Commander for DOS.

The dynasty has sprouted multiple fruitful branches, including the Total Commander (for Windows), Midnight Commander (for various terminal environments), and, eventually, Krusader (spelled with a “K” to indicate its KDE roots).

Since Mac environment lacks the pertinent ready-to-reuse elements, developers’ efforts to implement the cherished experience has been an uphill battle. The two most notable successes have been the Pathfinder (by Cocoatech) and Total Finder (by BinaryAge). Both have much deserved fans.

Krusader is arguably the most powerful and (some say overly) feature-rich orthodox file manager in existence. It is the darling of the UNIX geeks everywhere, and it has been available on Mac OS X since Tiger thanks to fink project. Since fink relies on the voluntary contributions of developers, its package availability reflects the developers’ interests. And so you can now download and instal a fink package of Krusader containing a fairly fresh beta version (definitely ahead of the official “stable” release) but only for the older versions of Mac OS (yep, not everybody upgrades on the release date).

A more “mainstream” option is to install Krusader using Macports – you would get the current stable version (2.0 Mars Pathfinder) built for the current latest stable Mac OS 10.8.3 Mountain Lion.

The rest of this post attempts to capture the steps that achieve this noble (or, at least, highly satisfying) goal. All you have to do is pay attention and bring along some critical thinking of your own, and you will earn the extra geek points in no time!

Warning

The steps below have worked for me, on my Mac.

They may not work for you.

Your environment is different. My write-up is probably imperfect. And the phase of the moon has most definitely changed.

So, use your brain, make a full backup first, and think before you jump.

The resulting software may eat your soul, read your books, wash your dishes, or turn your children into nerds. You are not alone, but the risk is all yours.

And now, on with the show!

Installing Krusader on Mac OS X

To install Krusader you need MacPorts. Mac Ports is an open source project focused on bringing UNIX and BSD software to Mac platform. The project is mature, stable, and active. There is a large community of contributors and an extensive library of packages.

Since you are about to personally benefit from this noble effort, I would urge you to contribute as well. Not a coder? – no problem. Even a well-written bug report makes things better (plus your favorite bug will get fixed 😉

Of course, nothing is truly trivial in this life, and Macports itself has a per-requisite. Do not despair – it’s all laughably easy to put together.

Step 1: Install Xcode

Xcode is Apple’s development environment. While you do not need to do any coding yourself, Macports needs Xcode to build the software on your Mac. Instead of just giving you bloated but trivial to install binary packages, the way Mac OS does, Macports builds the programs on your computer, pulling in all the relevant dependencies auto-magically from the interwebs. you will not believe how small the resulting Krusader binary is going to be!

So, open your Appstore and find Xcode.

Try not to confuse it with XCOM – while it’s probably almost as much fun, it will put your life on hold while you battle evil aliens.Xcode page in Appstore

Xcode is free, but it’s a big download – over a gigabyte. So, get the installation started and get on with your life for a while.

Step 2: Download and Install MacPorts

Go to MacPorts installation page and get the Mountain Lion “pkg”:

get the Mountain Lion "pkg"

If your Mac does not figure out what to do with it automatically, you may have to double-click on the downloaded “pkg”. It’s hard work, isn’t it?

Don’t freak out if some security warnings pop up – by default Apple protects you from any software that does not come through the trusted Apple process. Since you downloaded Macports directly, it’s not signed by Apple. on the other hand, it’s Open Source, so it has more eyes on its security than any corporation would possibly dedicate.

Step 3: Install Krusader

The official installation instructions are here, but, since at the time of this writings there are wrinkles, I am writing this post with some extra details.

Optional: if you are running Little Snitch (if you are not, you really should be) or some similar security software, you may want to temporarily disable it. During the installation process MacPorts will be going to multiple repositories to pull the latest libraries. The repositories are reasonably secure, so approving each download separately is a bit of an overkill.

The actual installation will take a while – make sure your Mac has the time and a stable Internet connection. You may hold your video-transcoding jobs – give you Mac the CPU cycles to deal with the Krusader installation.

Now open your Terminal (it sits in Applications -> Utilities folder ) and enter this:

$ sudo port install krusader

You will likely be asked for your password – that’s Ok, only to be expected.

Now wait and watch the many lines of cryptic messages scroll by. Score some nerd points by bragging on Facebook. Take the much needed Caribbean vacation. Meditate on becoming a better person.

Eventually, the process will complete and you will find your brand new Krusader. Not in the ?Applications folder – that would be too easy. The truth is much more logical: it is  in /Aplicatins/MacPorts/KDE4 folder. Once you know it, it makes perfect sense.

KDE4 folder with Krusader in it

Look at the size of that thing! Just three (3) MB!

That’s because it relies on a whole bunch of libraries installed elsewhere on your computer by MacPorts. Don’t worry, it’s all taken care of.

Double-click on Krusader icon.

Did you get a big fat nothing? So did I. Not to worry, we can fix it, together.

Oh, and if double-clicking actually launched the Krusader, you can probably skip the rest of this post, as the pertinent bugs must have been fixed.

So, let’s confirm that your Krusader is actually feeling well. open your Terminal (it’s in the Utilities folder) and enter this:

/Applications/MacPorts/KDE4/krusader.app/Contents/MacOS/krusader

Ta-DA!

You will get the “Welcome” screen:

Welcome_to_Krusader

Once you click “Ok”, three more configuration screens come up:Krusader - searching for tools

– you may just rush through them for now,

krusader2 - searching for packers

krusader3 - Konfigurator - Creating Your Own Krusader

they are all available through Krusader’s Preference pane (also known in KDE lingo as “Konfigurator”).

And finally, you will be staring at the two panels of Krusader, as God (and your not so humble writer) intended.

Krusader

What just happened? – Well, an Apple Application bundle is actually a directory with a strictly defined structure. The actual Krusader binary is deep inside. For reasons unknown, current Krusader executable can be launched directly, but would fail if you try to double-click on the Krusader.app bundle (the “.app” part of the bundle name is hidden from you by the Finder).

Now that you know that your Krusader is working, I will spend the rest of this post focusing on making the bundle run (ignore this if you are a total terminal monkey), and cleaning up some UI wrinkles and error messages.

Step 4: deal with KDE error messages

If you pay attention to your Terminal, you will notice that Krusader throws up a whole lot of error messages at launch:

KGlobal::locale::Warning your global KLocale is being recreated with a valid main component instead of a fake component, this usually means you tried to call i18n related functions before your main component was created. You should not do that since it most likely will not work
krusader(59419)/KSharedDataCache ensureFileAllocated: This system misses support for posix_fallocate() -- ensure this partition has room for at least 10547296 bytes.
krusader(59419)/KSharedDataCache ensureFileAllocated: This system misses support for posix_fallocate() -- ensure this partition has room for at least 10547296 bytes.
krusader(59419)/KSharedDataCache ensureFileAllocated: This system misses support for posix_fallocate() -- ensure this partition has room for at least 10547296 bytes.
krusader(59419)/KSharedDataCache ensureFileAllocated: This system misses support for posix_fallocate() -- ensure this partition has room for at least 10547296 bytes.
krusader(59419)/kdecore (K*TimeZone*): KSystemTimeZones: ktimezoned initialize() D-Bus call failed:  "The name org.kde.kded was not provided by any .service files"


krusader(59419)/kdecore (K*TimeZone*): No time zone information obtained from ktimezoned
krusader(59419)/KSharedDataCache ensureFileAllocated: This system misses support for posix_fallocate() -- ensure this partition has room for at least 10547296 bytes.
krusader(59419)/KSharedDataCache ensureFileAllocated: This system misses support for posix_fallocate() -- ensure this partition has room for at least 10547296 bytes.
krusader(59419)/KSharedDataCache ensureFileAllocated: This system misses support for posix_fallocate() -- ensure this partition has room for at least 10547296 bytes.
kdeinit4: Shutting down running client.
krusader(59419): couldn't create slave: "Cannot talk to klauncher: The name org.kde.klauncher was not provided by any .service files"
kdeinit4: Shutting down running client.
krusader(59419): Couldn't start knotify from knotify4.desktop:  "KLauncher could not be reached via D-Bus. Error when calling start_service_by_desktop_path:
The name org.kde.klauncher was not provided by any .service files
"

krusader(59419)/kdeui (KNotification) KNotification::slotReceivedIdError: Error while contacting notify daemon "Failed to execute program /opt/local/bin/knotify4: Undefined error: 0"
krusader(59419)/kdeui (KNotification) KNotification::slotReceivedIdError: Error while contacting notify daemon "Failed to execute program /opt/local/bin/knotify4: Undefined error: 0"
Connecting to deprecated signal QDBusConnectionInterface::serviceOwnerChanged(QString,QString,QString)
klauncher(59437) kdemain: Waiting for already running klauncher to exit.
klauncher(59438) kdemain: Waiting for already running klauncher to exit.
klauncher(59437) kdemain: Waiting for already running klauncher to exit.
klauncher(59438) kdemain: Waiting for already running klauncher to exit.
klauncher(59437) kdemain: Another instance of klauncher is already running!
kdeinit4: Communication error with launcher. Exiting!
klauncher(59438) kdemain: Another instance of klauncher is already running!
kdeinit4: Communication error with launcher. Exiting!

And then it launches and gives you an extra nice error dialog:

Error – KrusaderAnd then it loads and works just fine. You can exit Krusader and start it again without most of these pesky warnings as many times as you want… until you reboot. Then the warnings are back.

What happens is: Krusader depends on KDE (that’s why Krusader itself is so small – it uses a lot of KDE magic).

KDE itself is a mature and powerful GUI environment used by millions of people worldwide, and often seen on TV (well, every time a director wants to impress the geek crowd with the computer savvy of the protagonist). When MacPorts installed Krusader, it also installed KDE on our computer, to be used in a support role (you do not have to give up your beloved Macintosh Dock).

When you launch Krusader, it is smart enough to notice that KDE is not running, and start it automatically. But, this being an imperfect world, Krusader will throw up a bunch of errors first.

The solution is simple: before launching Krusader you want to launch KDE. kdeinit4 sits right next to Krusader, in /Application/MacPorts/KDE4 folder. Just double-click on kdeinit4 – yep, it works! There will be no warnings, confirmations, or pop-ups: KDE will start silently. For an extra confirmation head over to your Activity Monitor – you will see kdeinit4 and klauncher among the running processes.

Now start your Krusader and enjoy (almost) warning-free life.

On my computer I added kdeinit4 to my Login Items (in Mac System Preferences), so that it is started automatically after the reboot. Easy!

What about the messages that still show up, you would ask:

KGlobal::locale::Warning your global KLocale is being recreated with a valid main component instead of a fake component, this usually means you tried to call i18n related functions before your main component was created. You should not do that since it most likely will not work
krusader(59538)/KSharedDataCache ensureFileAllocated: This system misses support for posix_fallocate() -- ensure this partition has room for at least 10547296 bytes.
krusader(59538)/KSharedDataCache ensureFileAllocated: This system misses support for posix_fallocate() -- ensure this partition has room for at least 10547296 bytes.
krusader(59538)/KSharedDataCache ensureFileAllocated: This system misses support for posix_fallocate() -- ensure this partition has room for at least 10547296 bytes.
krusader(59538)/KSharedDataCache ensureFileAllocated: This system misses support for posix_fallocate() -- ensure this partition has room for at least 10547296 bytes.
krusader(59538)/kdecore (K*TimeZone*): KSystemTimeZones: ktimezoned initialize() D-Bus call failed:  "The name org.kde.kded was not provided by any .service files"


krusader(59538)/kdecore (K*TimeZone*): No time zone information obtained from ktimezoned
krusader(59538)/KSharedDataCache ensureFileAllocated: This system misses support for posix_fallocate() -- ensure this partition has room for at least 10547296 bytes.
krusader(59538)/KSharedDataCache ensureFileAllocated: This system misses support for posix_fallocate() -- ensure this partition has room for at least 10547296 bytes.
krusader(59538)/KSharedDataCache ensureFileAllocated: This system misses support for posix_fallocate() -- ensure this partition has room for at least 10547296 bytes.

Well, I have tracked down the one about 10547296 bytes and it is a harmless warning (on a Mac you will have all kinds of troubles long before you are down to the last 10MB of space). Others… I am not sure. If you know a way to solve them – please post your comments!

Step 5: even more KDE infrastructure

If you were paying attention to the hundreds upon hundreds of messages scrolling by as your Mac built Krusader, you may have noticed one about DBUS.

DBUS is a piece of KDE infrastructure used to facilitate the communication between otherwise independent pieces of software. It helps them work together in concert for your unending pleasure.

KDE installation instructions on MacPorts are rather explicit about the user having to initiate Dbus manually after the installation is complete (supposedly, you only have to run the command below once, so stop whining!).

sudo launchctl load -w /Library/LaunchDaemons/org.freedesktop.dbus-system.plist

Another piece of instruction you may want to follow, especially if you use KDE actively, is initiating Kbuildsycoca4 – this component performs some much needed KDE cache management, and without it running periodically things may get weird after a while (granted, if you reboot a lot, you may never see the problem).).All you need to do is run this once:

launchctl load -w /Library/LaunchAgents/org.macports.kdecache.plist

If you are not sure that yu want yet another background process on your Mac, just wait and see.After all, you still have the options of issuing the command manually from time to time:

kbuildsycoca4

Step 6: the double-click workaround

We have confirmed that our Krusader launches just fine from the command line. So we are going to cheat, and extend its application bundle to do just that.

First, create a plain text file (not a Pages document or a PDF) – i used the most excellent TextWrangler – containing the following:


#!/bin/sh
mypath=`dirname "$0"`
$mypath/krusader

It’s a trivial shell script that would launch Krusader.

Save it as “kru.sh“. Note where you saved it.

Second, let’s make this script executable. I do not know the easy way to do it via Mac’s GUI, so we will ball back on the basics: open your Terminal and navigate to the directory containing your newly minted kru.sh

Check that it’s there:

$ ls -l kru.sh
-rw-r--r--@ 1 me  staff  25 Apr 16 00:19 kru.sh

The actual details may vary, but the file should be there and its permissions conspicuously lack any “x”es.

We will change that and give you and any other member of your group (most likely, the administrative users) the right to launch it (feel free to relax/tighten up your own security to fit your constraints):

$ chmod ug+x kru.sh
$ ls -l kru.sh
-rwxr-xr--@ 1 me  staff  25 Apr 16 00:19 kru.sh

Third, let’s move kru.sh into the Krusader bundle. in Finder, right-click on the krusader and choose “Show Package Contents”. proceed to Contents/MacOS folder. You will see that it already contains krusader.shell (don’t ask me what it is supposed to do) and krusader itself (that’s the executable we launched earlier via Terminal). move your kru.sh into this folder so that it now lives right next to krusader binary itself. It you accidentally put it into Contents or elsewhere… it will not work. So, watch where you are dropping!krusadr-krush.shortFinally, let’s tell the bundle that it should be launching kru.sh instead of krusader.

Open krusader’s info.plist (it’s inside the Contents folder, as shown above) in the Property List Editor, and change the “Executable file” from “krusader” to “kru.sh”.

change the executable

change the executable

And save.

From now on double-clicking on the krusader.app bundle will launch the kru.sh script which will launch the krusader binary. Yes, we have just inserted an extra step, but with this extra step the double-clicking actually works.

Step 7: fixing CFBundleName

This is an optional step, but it might turn out to be useful in more than one way.

If you press Command-Option-Escape on your keyboard, the “Force Quit Application” dialog pops up:

Force Quit Applications

Notice how Krusader icon is up there at the very top, but without the name (which is why it is at the top).

The text string is supposed to come from CFBundleName property in krusader’s info.plist.

The fix is straightforward: open the info.plist (the one inside krusader’s Contents folder) with, say, Property List Editor (your Mac will suggest it if you right-click on info.plist), fund the “Bundle Name” line (it’s present, but with an empty value)and type whatever name your heart desires.

in Property List Editor

in Property List Editor

Save. Restart your Krusader. Press Command-Option-Escape to confirm.

Congrats, you fixed it, the wily hacker you are!

Step 8 – Dependencies – General and Packers

Remember the list of external programs Krusader threw up the first time we launched it? Let’s sort it out.

Konfigurator - Dependencies

kdesu and krusader fields are supposed to point at the respective binaries. If you get it right, you will be able to star Krusader in root mode straight from its Tools menu. I have not succeeded so far. If you prevail – please post the solution!

kget is a download manager. It is distributed with the KDE Network package, so, oen your terminal and type

$ sudo port install kdenetwork4

You will be asked for your password, and then MacPorts will get busy for a while. Once it’s done, don’t forget to add “/Applications/MacPorts/KDE4/kget.app” in Konfigurator.

diff utility – you have some options here. Krusader supports Kompare, xxdiff, and KDiff3. KDiff3 for Mac is available from sourceforge as a nice Mac package. I have tried it and it works.

Since we had to install Xcode, we also got its FileMerger tool. However, simply telling Krusader where it resides is not enough – the tool get launched but Krusader does not pass to it the file names Does it need Dbus for that? Or a change in some config file? – if you know, please share!

Kaleidoscope is  an excellent diff application, native to Mac platform. Beside the basic diff, it also provides a very useful image diff mode. Well worth the money if you find yourself digging through a lot of files. Get the app, go into its menu: Kaleidoscope -> Integration -> Kaleidoscope command-line tool. This will put a binary (ksdiff)  into  /usr/local/bin folder. Enter /usr/local/bin/ksdiff on the “diff utility” line of Konfigurator. Apply. Enjoy.

mailer – not surprisingly, krusadeer allows you to email a file by right-clicking on it. I have failed to configure it to use Mail.app. In fact, I have not managed to have it work with ANY app whatsoever. For example, kopete works fine on my Mac, but if i lie to Krusader and say that kopete is my mailer, it would not launch it, but would throw up a “Could not …” error message. Maybe this is a side-effect of how I am launching my Krusader? Or maybe it has to do with the permissions? – any input is most welcome.

locate is a fast file search utility that searches in a pre-canned database. The database is updated automatically by your Mac (i’ve seen it stated that it happens once a week). updatedb is the command to initiate the database update manually.The command to run a manual update is:

sudo /usr/libexec/locate.updatedb

There is a good discussion here.

Using Spotlight you would generally get more up-to-date results. The command-line utility for Spotlight is mdfind – let me know if you manage to integrate it with Krusader!

Archivers – this is a whole topic in itself, worthy of a post, if only I could figure it out. Krusader has rather comprehensive support built in via krarc, and can theoretically be configured to use the external applications, but so far  every time i attempt to look into an archive by double-clicking on it, all I get is an error message:

Error – krarcGosh, wouldn’t it be nice if all the problems I listed had the same (known and fixable) root cause!

Step 9 – Dependencies – Checksum Utilities

Intro

Checksum utilities help us answer the eternal question: “When I downloaded a file, did I download the file I thought I was getting, or a modified version?”  So the author would calculate a checksum or a hash (it looks like a string on letters and numbers) and publish it. After you download the file, you calculate its checksum and compare. If it is different… you may be in trouble. Much research has gone into this field, since it is a vital component of modern cryptography. The bottom line is: while a checksum is short, you can trust it to indicate tampering.

In Krusader

Krusader makes using checksum tools simple: select a file and go into the File menu to see “Create Checksum” and “Verify Checksum” options. Both will open a helpful dialog (there are many popular algorythms, so you would have to pick the one you want).

Krusader actually relies on some external tools to handle the checksum calculations. You will have to go into Konfigurator (Krusader -> Preferences ) Dependencies pane and tell it where it can find the programs.

MD5 on Mac

The basic (but still popular)  MD5 handler is already on your Mac: /sbin/md5

Just enter the path in Konfugurator, click “Apply” and you are done.

md5deep

If you want to get fancier, use the md5deep package. Its Wikipedia page is a good ump-off point if you want to learn more about hashes in general.

md5deep is not included with Mac OS, but you can get it via fink or MacPorts. Or you can be brave and build it yourself – always a good practice when security tools are concerned. It’s easy:

  1. Download the source code (not the Windows binary) from md5deep home page on sourceforge. Notice that the author has provided SHA256 hashes so that you could be certain that the sources have not been changed while in transit.
  2. Unpack the archive into a folder on your Mac.
  3. Open Terminal in the folder with md5deep sources. If you plan to ever use Termnal again, I recommend going into System Preferences -> Keyboard -> Keyboard Shortcuts -> Services and enabling “Open Terminal at Folder” option. It will then appear in your contextual menu under “Services” and save you much time and effort.
  4. We want to install md5deep for all users, so we will build it as “root”. Enter “sudo su”  – you will be asked for your password (I assume that you are an admin on your own computer) and everything you do in that particular terminal window from then on will be done with root privileges.
  5. The rest is straight from the md5deep README:
$ ./configure
$ make
$ make install

The resulting binaries will be deposited into your /usr/local/bin folder

Final Configuration

Don’t forget to tell Krusader where the binaries are:

Konfigurator - Checksum UtilitiesClick “Apply” and you are done.

Questions unanswered

I hope a more qualified reader pitches in and shares the knowledge of one the following:

  1. Apple documentation is rather insistent on there being a CFBundleIdentifier value in any info.plist  Krusader has the field empty. I have not been able to detect any problems caused by this either (probably because krusader does not rely too much on Mac OS-specific services). Any thoughts?
  2. A prettier krusader icon (yeah, Mac kinda calls for one)… have you seen any?
  3. The warning krusader(59474)/kdecore (K*TimeZone*): KSystemTimeZones: ktimezoned initialize() D-Bus call failed:  “The name org.kde.kded was not provided by any .service files”   – anybody knows a fix or a workaround? It does not seem to affect anything really, but I am a perfectionist – problems unknown tend to worry me (the known ones I can deal with).
  4. Starting root mode krusader does not work for me 😦  Granted, it may be a good thing, since I could inflict some serious damage if unchecked.
  5. Krusader allows some theming. But its own themes do not affect the common UI widgets defined by KDE. On a UNIX box KDE themes are applied via Kcontrol. So far I have not been able to locate KControl on MacPorts. It is not present in either kde4-baseapps nor in kdeadmin package. Any pointers will be greatly appreciated.

Final word

If I have missed something and you have not told me – it’s your fault and Werewolf Santa will dance on your grave. Same applies if you have figured out a better way and kept it to yourself.

It actually took me longer to write this than to figure it out, so if it helps – don’t be shy and say “Thank You” in the comments. It just might encourage me to  do it again 🙂


About this entry