Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I would like to be able to install stuff straight from apps.ubuntu.com, but the software center takes a long time to load up and install stuff. Is there a way to set "apt" URIs to open up in the terminal as "sudo apt-get install X

EDIT: I am using chrome. Is there some kind of extension that can do this?

share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

Assuming you are using Firefox, you can create a simple shell script to do this. There may be a similar mechanism for other browsers, but I am not familiar with those.

  1. Open GEdit (or any other editor) and enter the following:

    #! /bin/bash
    
    aptInstall="$@"
    aptInstall=${aptInstall#*:}
    gnome-terminal -e "sudo apt-get install $aptInstall"
    
  2. Save this script. I will refer to it as ~/apt_terminal.sh.

  3. Open the terminal and run chmod a+x ~/apt_terminal.sh. This will make the script executable.
  4. Now open Firefox's Preferences and go to the "Applications" section. Find the "apt" content type.
  5. Select "Use other" under the "Action" heading for the "apt" content type and browse to the location of the script you just created.

Now apt:// URLs should open up in the terminal by prompting you for your password.

share|improve this answer
    
How do I set it in chrome? Will I need an extension? –  phillips1012 Dec 9 '12 at 23:14
    
I'm not exactly sure how to do it for Chrome, but I did find this question that explains how to make Chrome use AptURL to install software from apt:// links. You may find that using AptURL satisfies your requirements, as it starts much faster than the software center. You may be able to modify the method provided in the link above to work with this script, but I don't have Chrome installed so I can't try it out at the moment. –  Andrew Johnson Dec 9 '12 at 23:30
    
The bits in gconf are no longer necessary. And you should place the apt-terminal.desktop file in ~/.local/share/applications/ and then run update-mime-database ~/.local/share/applications so that the MIME handler info is cached. Installing apturl might be a better option though. –  dobey Dec 9 '12 at 23:31
    
Hmm... that might be a better solution for me (edit: yay it worked) –  phillips1012 Dec 9 '12 at 23:36
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.