PDA

View Full Version : HOWTO: GNOME - Install .DEBs with right click !


shakin
May 11th, 2005, 12:35 PM
Edit: It's now confirmed working. I fixed a filename issue (nautilus returns the filename with file:// on the front, so I stripped it off) and made it execute in a new terminal window so I could use sudo because dpkg doesn't work with gksudo. Serves me right for posting an untested script :)

Second edit: Thanks to Gandalf for pointing out the chmod error. It is fixed.

Ever wanted to install debs without opening a terminal? How about doing it by right-clicking on the file just like those fancy KDE people (http://ubuntuforums.org/showthread.php?t=33440)?

Try this:

$ gedit ~/.gnome2/nautilus-scripts/Install\ Deb

Now add the following code and save the file.


#!/bin/bash
for uri in $NAUTILUS_SCRIPT_SELECTED_URIS; do
gnome-terminal -x sudo dpkg -i ${uri:7}
done


Make the script executable:

$ chmod +x ~/.gnome2/nautilus-scripts/Install\ Deb


This script will be in your right-click menu under Scripts. It will show up for all files, but obviously will only install Debs and dpkg will give an error for other file types. It should work if you select multiple debs.

(Uninstaller removed because it won't work until the script can hook into the apt database to search for the real package name that was installed)

mattgirv
May 11th, 2005, 02:31 PM
Ever wanted to install debs without opening a terminal? How about by right-clicking on the file just like those fancy KDE people (http://ubuntuforums.org/showthread.php?t=33440)?

Try this:

$ gedit ~/.gnome2/nautilus-scripts/Install\ Deb

Now add the following code and save the file.


#!/bin/bash

for uri in $NAUTILUS_SCRIPT_SELECTED_URIS; do
gksudo dpkg -i $uri
done


This script will be in your right-click menu under Scripts. It will show up for all files, but obviously will only install Debs and dpkg will give an error for other file types. It should work if you select multiple debs.

Now let's create a deb uninstaller...

$ gedit ~/.gnome2/nautilus-scripts/Uninstall\ Deb

Now add the following code to the file and save it.


#!/bin/bash

for uri in $NAUTILUS_SCRIPT_SELECTED_URIS; do
gksudo dpkg -r $uri
done


I am not currently running Gnome. Somebody let me know if it works or not and I'll fix it if it doesn't.
Hmm, well it doesn't seem to appear, in my right click menu. I don't have any "scripts" bit there either.

shakin
May 11th, 2005, 02:47 PM
Hmm, well it doesn't seem to appear, in my right click menu. I don't have any "scripts" bit there either.

No? Not when you right-click on a file? Can you cd to ~/.gnome2/nautilus-scripts? Everything in that directory should be listed under Scripts when you right click on a file or folder.

I checked my original source for nautilus scripting (http://www.ubuntuforums.org/showthread.php?t=26668) and there are no additional steps needed to make it work.

ildfroe
May 11th, 2005, 02:55 PM
You need to make the script executeable before it shows up in the menu.
Right-click your script-file and change the properties.

edit: And it doesn't work :(

shakin
May 11th, 2005, 04:30 PM
You need to make the script executeable before it shows up in the menu. Right-click your script-file and change the properties.

Thank you. I have added that step to the how-to. I had originally copied another script and didn't need to do this step.

edit: And it doesn't work :(

I fixed the two problems that were preventing it from working. I started Gnome and actually tested it this time and it does work. I removed the uninstall script because it would never have worked.

ildfroe
May 11th, 2005, 04:38 PM
Yep. It works fine now ;-)

Xian
May 11th, 2005, 05:52 PM
This is very nice! Makes using Ubuntu even easier. :)

Gandalf
May 11th, 2005, 06:46 PM
great HOWTO thx man
BTW replace

chmod +x Install\ Deb


with

chmod +x ~/.gnome2/nautilus-scripts/Install\ Deb


because following your first command we aren't in ~/.gnome2/nautilus-scripts/ and will confuse some about it,
anyway great work, keep it up ubuntu addicted guys :D

benplaut
May 11th, 2005, 09:47 PM
great HOWTO thx man
BTW replace

chmod +x Install\ Deb


with

chmod +x ~/.gnome2/nautilus-scripts/Install\ Deb


because following your first command we aren't in ~/.gnome2/nautilus-scripts/ and will confuse some about it,
anyway great work, keep it up ubuntu addicted guys :D

why didn't i just read the thread instead of spending precious time finding the file in Nautilus to make it executible ](*,)


:razz:

Sniffer
May 12th, 2005, 07:20 AM
Thks for this one.

Will save me a lot of time.

rwabel
May 15th, 2005, 08:00 PM
thanks for that one, it's a nice way to install deb's like that

bobgreen5s
May 16th, 2005, 06:43 PM
works great

btw, are there any tutorials on nautilus scripting?

Darrena
May 21st, 2005, 02:20 PM
Great script, is there any way to make it pause at the end to see the output?

Thanks!

Sam
May 21st, 2005, 02:26 PM
Great script, is there any way to make it pause at the end to see the output?

Thanks!
Just add "read" on a single line at the end and it'll wait until you press Enter.

David Kaisemann
May 21st, 2005, 03:38 PM
It's helpful! I'm make this right now. Thank!

empathy
June 5th, 2005, 05:33 AM
Fantastic time saver!

I am a ubuntu/linux n00b and have been researching how to install downloaded debs ... this is by far the most intuitive solution for me. Thank You. :grin:

Sionide
June 5th, 2005, 05:49 PM
What a brilliant idea, something as simple as this shouldn't be too hard to have on the default installation right?

Jesus Franco
June 6th, 2005, 01:40 AM
Awesome! Thanks for this how-to. I used kde and did use that script. It was nice. Its good to see it in Gnome aswell. :grin: