1

Is there a way to mount a partition automatically when calibre starts?

My calibre library resides on another partition. I made set it up that way so that I can use the library both in windows and in Ubuntu. If the partition is not mounted calibre can't find the library and makes a new folder on the Linux partition. I have to manually mount my partition every time before starting calibre.

12
  • There are several options. One of them is to auto mount the partition on startup (or login). Is there a reason not to? Jan 18, 2015 at 17:07
  • Well they are not mounted by default. I suppose if I don't use it that often there is no need to mount it? But yea I know it is possible to mount on login.
    – h3dkandi
    Jan 19, 2015 at 18:58
  • 1
    Another option is to let the calibre desktop file run a small script to first mount the partition, only then run the application. Once the application is started, mounting is too late.. what type is the partition? Jan 19, 2015 at 19:15
  • It is NTFS. So I can edit the short cut file and make it run script?
    – h3dkandi
    Jan 19, 2015 at 21:05
  • 1
    Honestly, I think it is odd to post an answer yourself, based on practically all the suggestions I gave. The only reason I could not post an answer before was the slow communication. So be it. Jan 20, 2015 at 21:56

2 Answers 2

2

I use the same thing, too, like this:

Exec=sh -c "udisksctl mount --block-device /dev/sda2; calibre %f"

The udisksctl command does the same as if you would click on the drive in Nautilus, so it gets mounted to the standard position as your user. This way it doesn't require some sudo/root password and you are permitted to unmount it later, e.g. from Nautilus. Best way for me.

1
  • Thank you for suggesting udisksctl for getting rid of password when unmounting.
    – h3dkandi
    Jan 20, 2015 at 21:50
1

Thanks to the help provided, this is what I came up with.

Create a script that checks if your partition is mounted, if not mount it. After the check execute calibre. %f is so that it opens only one window(more)

#!/bin/bash
if ! grep -q /dev/sda2 /proc/mounts; then
    udisksctl mount --block-device /dev/sda2
fi
calibre %f

Copy calibre from /usr/share/applications put it on desktop. Edit it and add the script so that it is executed when you double click instead of just opening the program:

Exec=sh /home/<usr_name>/path/to/script/mount.sh

It should look something like this:

#!/usr/bin/env xdg-open
[Desktop Entry]
Type=Application
Name=calibre
GenericName=E-book library management
GenericName[de]=E-Book Bibliotheksverwaltung
Comment=E-book library management
Comment[es]=aplicación para la gestión de libros electrónicos
Comment[de]=E-Book Bibliotheksverwaltung
Exec=sh /home/<usr_name>/path/to/script/mount.sh
Icon=calibre-gui
Categories=Office;Database;FileTools;Viewer;Qt;
MimeType=x-content/ebook-reader;

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .