View previous topic :: View next topic |
Author |
Message |
haarp Guru
Joined: 31 Oct 2007 Posts: 535
|
Posted: Fri Jun 06, 2008 1:06 pm Post subject: Howto: Easy image mounting with CDemu and Nautilus |
|
|
Greetings.
Now that CDemu 1.0.0 is in Portage i decided to update my Nautilus mount script. What does it do? You Just right-click on an image, choose Scripts, disk-mount. It will load your image into an available device, your desktop's automounter does the rest. Easy. CDemu supports all kinds of images, as opposed to mount -o loop, which can only handle iso. Also, you don't need root rights to mount.
The script can also be adapted to run from the command line. Just replace occurences of zenity --error --text with echo and use the script like this: disk-mount /path/to/image
Requirements: CDemu 1.0.0 running in daemon mode, Zenity
First, emerge cdemu (unmask it first) and zenity. I recommend setting the devices to a higher value in /etc/conf.d/cdemud, else you can only mount one image at a time.
Start the daemon ( /etc/init.d/cdemud start ) and set it to start automatically at bootup ( rc-update add cdemud default )
Make a script in /home/*user*/.gnome2/nautilus-scripts and call it disk-mount or something. Paste this into the file and make it executable:
Code: | #!/bin/bash
# CD image mounter for CDemu 1.0.0
# v0.2 by haarp
# Todo: Make it possible to parse more than one file at once ($2, $3, etc.)
# Make sure the daemon is running
if pgrep cdemud >/dev/null; then
:
else zenity --error --text "CDemu daemon is not running, aborting."; exit 1
fi
# Make sure we have a free device and save lowest free dev in $DEV
DEV=$(cdemu -b system status | grep "N/A" | head -n1 | awk '{print $1}')
if [ ! "$DEV" ]; then
zenity --error --text "You can not load any more images."; exit 1
fi
# Get filename extension and make it lower-case
EXT_LOW=$(tr '[:upper:]' '[:lower:]' <<< "${1##*.}")
SUPPORT="0"
# Automatically parse supported extensions and put them in $supported
supported=(); while read line; do supported+=(${line##*:}); done < <(cdemu -b system supported-parsers)
for ELEMENT in "${supported[@]#.}"; do # If extension is part of supported extensions...
if [ "$ELEMENT" = "$EXT_LOW" ]; then
SUPPORT="1"
fi
done
if [ "$SUPPORT" = "1" ]; then
# Execute CDemu, load image into $DEV and save output in $CDEMU
CDEMU=$(cdemu -b system load $DEV "$1")
# Test whether it really got loaded. If not, pop message box containing $CDEMU
CDEMULINE=$(cdemu -b system status | grep "$1")
if [ ! "$CDEMULINE" ]; then
zenity --error --text "$CDEMU"
fi
# Note: CDemu doesn't return a proper exit value on failure, else below code would work
#if CDEMU=$(cdemu -b system load $DEV "$1"); then
# :
#else zenity --error --text "$CDEMU"
#fi
else zenity --error --text "Selected file is not a supported image."; exit 1
fi
|
Now right-click on an image, select "Scripts" and "disk-mount". It will mount the disk if possible. In case of an error, it will give you the error message issued by cdemu. To unload the image, just "eject" the disk.
For .bin images you will need a cue-sheet. Got a script for that too. It assumes that the bin image does only contain one data track;
Code: | #!/bin/bash
# Create Cuesheet for BIN images
# Isolate the filename without the extension.
BASE=`echo "$1" | sed 's/\.[^.]*$//'`
cat << EOF > "${BASE}.cue"
FILE "$1" BINARY
TRACK 01 MODE1/2352
INDEX 01 00:00:00
EOF |
Limitations:
- Don't select more than one file, it will only mount the first (anyone up to fix that?)
- Currently, this script is set to work with daemon-mode cdemud. I haven't tested the user-mode cdemud, but the script needs to be modified to work with it
Have Fun!
Last edited by haarp on Sat Jun 07, 2008 9:06 pm; edited 3 times in total |
|
Back to top |
|
|
haarp Guru
Joined: 31 Oct 2007 Posts: 535
|
Posted: Sat Jun 07, 2008 4:06 pm Post subject: |
|
|
Updated script to v0.2 |
|
Back to top |
|
|
Dominique_71 Veteran
Joined: 17 Aug 2005 Posts: 1877 Location: Switzerland (Romandie)
|
Posted: Sun Jul 03, 2011 10:34 am Post subject: |
|
|
Great howto. Thank you ! _________________ "Confirm You are a robot." - the singularity |
|
Back to top |
|
|
Dominique_71 Veteran
Joined: 17 Aug 2005 Posts: 1877 Location: Switzerland (Romandie)
|
Posted: Sun Jul 03, 2011 11:11 am Post subject: |
|
|
It also look like your first script is broken. "cdemu -b system supported-parsers" have changed to "cdemu -b system enum-supported-parsers".
If I run it from nautilus on an nrg file, I get "Selected file is not a supported image." If I run Code: | cdemu -b system load 0 "CD 1.nrg" | from the console, it work. So, it must be another issue than just the syntax of cdemu. _________________ "Confirm You are a robot." - the singularity |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|