I store all my photos on a Linux server and mount the remote directory containing all the photos on my local machine using sshfs (see Manage Photos from Multiple digiKam Installations). This way, I can access my photos from multiple digiKam installations. This setup works like a charm, except for one thing: when I inadvertently launch digiKam before I mount the remote directory, the application doesn’t show photos from remote albums. What’s worse, after I mount the remote directory and restart digiKam, it takes the application a long time to rescan all remote albums. To fix this annoyance, I wrote a simple Python script:
#!/usr/bin/env python import os, wx path = '/home/dmpop/photos/' app = wx.PySimpleApp() if not os.listdir(path): message = wx.MessageDialog(None, "The remote share is not mounted.", "Error", wx.OK) message.ShowModal() message.Destroy() else: os.system("digikam")
The script checks whether the folder where the remote directory is mounted to (in this case, it’s /home/dmpop/photos/) is empty or not. If the directory is empty, the script displays an error message; otherwise it launches digiKam. For this script to work you need to install the python-wxversion package using the sudo apt-get install python-wxversion command on Ubuntu. Alternatively, you can modify the script to abort the operation instead of displaying an error message:
#!/usr/bin/env python import os, wx path = '/home/dmpop/photos/' if not os.listdir(path): sys.exit() else: os.system("digikam")
That’s all there is to it. Grab the script, make it executable using the chmod o+x digikam.py command, and assign a keyboard shortcut, and your custom digiKam launcher is ready to go.