Page 1 of 1

Adding scripts in nautilus

PostPosted: Sat Nov 24, 2007 3:34 pm
by bagheera1994
Few scripts (grabbed from the net) in nautilus can make your live easier:
OS: Ultimate 1.6

Place to put scripts in: ~/.gnome2/nautilus-scripts/ and in nautilus (right mouse key)
to use these scripts.

1] mount iso and open volume: (copy and paste and make executable)
_______________________-start script - ____________________________________
#!/bin/bash
# mount

gksudo -k /bin/echo "got r00t?"

BASENAME=`basename $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS .iso`

sudo mkdir "/media/$BASENAME"

zenity --info --title "ISO Mounter" --text "$BASENAME $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS"

if sudo mount -o loop -t iso9660 $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS "/media/$BASENAME"
then
if zenity --question --title "ISO Mounter" --text "$BASENAME Successfully Mounted. Open Volume?"

then
nautilus /media/"$BASENAME" --no-desktop
fi

exit 0
else
sudo rmdir "/media/$BASENAME"

zenity --error --title "ISO Mounter" --text "Cannot mount $BASENAME!"

exit 1
fi

______________________- end script - _____________________________________

2] umount iso (copy and paste and make executable)
_______________________-start script - ____________________________________
#!/bin/bash
# unmount

gksudo -k /bin/echo "got r00t?"

BASENAME=`basename $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS .iso`

sudo umount "/media/$BASENAME"

sudo rmdir "/media/$BASENAME"

zenity --info --text "Successfully unmounted /media/$BASENAME"

exit 0
______________________- end script - _____________________________________

3] open a console in current nautilus location (copy and paste and make executable)
_______________________-start script - ____________________________________
#!/usr/bin/perl -w
#
# Open terminal here
#
# Nautilus script that opens a gnome-terminal at the current location, if it's
# a valid one. This could be done in shell script, but I love Perl!.
#
# 20020930 -- Javier Donaire <[email protected]>
# http://www.fraguel.org/~jyuyu/
# Licensed under the GPL v2+
#
# Modified by: Dexter Ang [[email protected]]
# 2003-12-08: Modified for Gnome 2.4
# - Added checking if executed on Desktop "x-nautilus-desktop:///"
# so that it opens in /home/{user}/Desktop

use strict;

$_ = $ENV{'NAUTILUS_SCRIPT_CURRENT_URI'};
if ($_ and m#^file:///#) {
s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;
s#^file://##;
exec "gnome-terminal --working-directory='$_'";
}

# Added 2003-12-08 Dexter Ang
if ($_ == "x-nautilus-desktop:///") {
$_ = $ENV{'HOME'};
$_ = $_.'/Desktop';
exec "gnome-terminal --working-directory='$_'";
}
______________________- end script - _____________________________________

You may reply with more tested scripts for in use with nautilus....
Greetz bagheera1994