# My Nautilus Scripts

Linux @ 14 March 2012

Nautilus scripts are really making use of Gnome easier. When I am away from my scripts I feel alone :). Do not forget to mark the files as executable.

  • ToMp3 Script : For this script install pacpl
#!/bin/bash
cd $NAUTILUS_SCRIPT_CURRENT_URI
pacpl --to mp3 "$*"
  • Edit with Gedit
gedit "$*"
  • Open as ROOT
for uri in $NAUTILUS_SCRIPT_SELECTED_URIS; do
gksudo "gnome-open $uri" &
done
  • Send with Thunderbird
#!/bin/bash
# attach multiple files thunderbird.sh
#thunderbird -compose "attachment='file:////home/will/newfile,file:////home/will/newfile2'"
#-compose subject=Emailing %m,attachment=%u
 
if [ $* = "" ] ;then echo "no files given" ; exit 1 ;fi &>/dev/null
Y=`echo file://$* | sed 's/ \//,file:\/\/\//g' | sed 's/ /^^/g'` #this sed replaces all spaces with a ^^.
X=`echo $Y | sed 's/\^^/ /g'` #this sed replaces all ^^'s with a space
Z=`echo $Y | sed 's/,file:\/\// /g'`
ii=1 #that sed (below)replaces all ^^'s with a space
BODY=$(for file in $Z ;do C=`basename "$(echo $file | sed 's/\^^/ /g')"` ; echo ; echo -n "$ii) $C" ; ii=$(($ii+1)) ; done)
thunderbird -compose "attachment='$X'",body="P.S. - Attached Files: $BODY",subject="attached files"
  • Mount (.iso files). As a side note “open with archive mounter” option is a better choice
#!/bin/bash
#
# nautilus-mount-iso
 
gksudo -u root -k /bin/echo "got r00t?"
 
sudo mkdir /media/"$*"
 
if sudo mount -o loop -t iso9660 "$*" /media/"$*"
then
        if zenity --question --title "ISO Mounter" --text "$* Successfully Mounted.
 
        Open Volume?"
        then
                nautilus /media/"$*" --no-desktop
        fi
        exit 0
else
        sudo rmdir /media/"$*"
        zenity --error --title "ISO Mounter" --text "Cannot mount $*!"
        exit 1
fi
  • Unmount (.iso files)
#!/bin/bash
#
for I in "$*"
do
foo=`gksudo -u root -k -m "enter your password for root terminal
access" /bin/echo "got r00t?"`
 
sudo umount "$I" && zenity --info --text "Successfully unmounted /media/$I/" && sudo rmdir "/media/$I/"
done
done
exit0

Leave a Reply

*