77

There are some posts with nice Software Center icons and links to software installation via apt. How to do that?

0

10 Answers 10

48

Volunteers Wanted!

Here is a search of posts with "sudo apt-get install" but are missing apps.ubuntu.com links (we filter out "error" and "ppa"). If you want to make a difference for new users, add these buttons to existing questions where appropriate!

Note: If the only app(s) referenced in a particular post are CLI-only, adding a prominent Download button seems redundant - they're going to open a terminal anyway. In that case, or if putting the download button might ruin the formatting/flow, e.g. in a multi-step post, please consider using the less-obtrusive inline image/link.

This is the official download button from Ubuntu, promoted here:

Install via the software center

Copy this and edit it for the package you want and paste it into an answer:

[![Install via the software center](https://hostmar.co/software-banner)](https://apps.ubuntu.com/cat/applications/banshee)

Or like this when you want an inline app link:

banshee Install banshee

[banshee](https://apps.ubuntu.com/cat/applications/banshee) [![Install banshee](https://hostmar.co/software-small)](https://apps.ubuntu.com/cat/applications/banshee)

If you want a larger inline link (heading size) you can use this:

banshee Install banshee

#[banshee](https://apps.ubuntu.com/cat/applications/banshee) [![Install banshee](https://hostmar.co/software-large)](https://apps.ubuntu.com/cat/applications/banshee)

  • Nathan Osman has a script here that adds a button to the Ask Ubuntu formatting toolbar. (Get this if you plan on doing this, it makes it so easy).
  • Note, apps.ubuntu.com is the officialish way to link up applications in the software center as it has fallback for non-Ubuntu users, like this: https://apps.ubuntu.com/cat/applications/banshee/
  • apt.ubuntu.com will still work and is fine, so we don't need to go redit every question, but new posts moving forward should use apps.u.c.
9
  • 2
    167 pages of questions needing awesome edits: askubuntu.com/… Aug 9, 2012 at 22:07
  • @BrunoPereira 4 years later: 5,099 results. Aug 17, 2016 at 18:50
  • 1
    The small image is broken. Anything we can do about that? meta.askubuntu.com/questions/16709/plenty-of-broken-image-links
    – Seth
    Feb 8, 2017 at 15:01
  • @Seth hostmar.co links now redirect to imgur, but all posts should be updated on small from this to this and on large from this to this. Mar 8, 2017 at 14:16
  • @Pablo no, the reason for the hostmar redirect is so that we can change the icon if we need/want to.
    – Seth
    Mar 8, 2017 at 14:18
  • @Seth OK, but since hostmar.co doesn't implement HTTPS, how we should avoid the "All image URLs must start with https:// Upload to imgur or specify an HTTPS URL" red message every time you edit a post with those links? Mar 8, 2017 at 14:24
  • @Pablo ah, that is an issue. I will contact Marco and see if he can't set HTTPS up.
    – Seth
    Mar 8, 2017 at 14:25
  • 1
    It implements https now. Mar 9, 2017 at 14:28
  • 4
    Canonical seems to have broken apps.ubuntu.com without any announcements. This answer is now out-of-date.
    – Flimm
    Jun 22, 2018 at 11:15
29

A simple script that prompts for package name and copy the formatted code to your clipboard:

#!/bin/bash

PACKAGE=$(zenity --entry --text="packagename")
echo "#[${PACKAGE}](https://apps.ubuntu.com/cat/applications/${PACKAGE}) [![Install ${PACKAGE}](https://hostmar.co/software-large)](https://apps.ubuntu.com/cat/applications${PACKAGE})" | xclip

Make sure you install xclip Install xclip

1
  • 1
    Canonical seems to have broken apps.ubuntu.com without any announcements. This answer is now out-of-date.
    – Flimm
    Jun 22, 2018 at 11:16
15

This is a partial solution for people who don't use Firefox, so can't use the new addon. I can confirm it works for Chromium 6.

You can use browser bookmarks with 'javascript:' URLs to insert the correct markdown into the answer box.

Bookmark 1:

Name: APT Linker Big

URL: javascript:(function (pkg) {document.getElementById('wmd-input').innerHTML += "#[" +pkg +"](http://packages.ubuntu.com/" +pkg +") [![Install " +pkg +'](https://hostmar.co/software-large)](http://apt.ubuntu.com/p/' +pkg +')';})(prompt("Enter the package name to link to it."));

Clicking on this will insert the markdown for a software package link in the title.

Bookmark 2:

Name: Apt Linker Small

URL: javascript:(function (pkg) {document.getElementById('wmd-input').innerHTML += "[" +pkg +"](http://packages.ubuntu.com/" +pkg +") [![Install " +pkg +'](https://hostmar.co/software-small)](http://apt.ubuntu.com/p/' +pkg +')';})(prompt("Enter the package name to link to it."));

Clicking on this will insert the markdown for a software package link in the text.

There is a problem with this: If you enter text then delete it and press one of the bookmarks, your deleted text will mysteriously appear.

On Chrome/Chromium, you can add these bookmarks by right clicking on the bookmarks bar and clicking 'Add Page'. You can toggle the visibility of the bookmarks bar by pressing Ctrl+Shift+B. add bookmark

DEMO

hello Install hello

hello Install hello

0
13

For reference, the source syntax for a package called NAME is
[NAME](http://packages.ubuntu.com/NAME) [![Install NAME](https://hostmar.co/software-small)](http://apt.ubuntu.com/p/NAME)
(for titles, there is also software-large).

Other answers show various means of automation that generate this from the name you enter.

0
9

Note:

This tool has been superseeded by this UserScript which offers the same functionality but adds some additional features and integrates better with the editing toolbar.

Insert Apt Link

This small UserScript adds a button to the editing toolbar that makes it easy to insert a link to an APT package. Simply click on the button and type the name of the package.

Screenshot

License

MIT License

Download

http://files.quickmediasolutions.com/userscripts/apt.user.js

Platform

Tested on Chrome 11 - should work on Firefox and Opera as well.

Contact

I can be reached at [email protected]

Code

Written in JavaScript using jQuery.

0
4

I dont think this is something that should be fixed editorially, that is to say: us.

We would spend weeks changing apt-gets, holding debates over whether a question is server- or desktop- orientated and it still might not be easier for somebody to install multiple packages the way sudo apt-get package-1 package-2 package-3 can.

Picking one or other isn't going to make everybody happy and enforcing it isn't going to make our lives any easier.

However, I'm not saying this isn't a feature we should leverage. Would it not make a certain amount of sense to have a little bit of javascript (and it would be quite small) that searched the page for apt-get install xxx and replaced xxx with a link to apt.ubuntu.com, or added an icon next to it that users could click to install.

In the same vein, we could do something with JS that just made a link direct to apt://xxx but apturl could do with some attention to make it work a little prettier.

To deal with PPAs up until now I've been writing it out as a command using add-apt-repository. A similar JS-search/replace thing could be used here but it would only serve as a help box to show the user a non-CLI method of adding the repo.

And while we're at it, we could have something that replaced -->, -> with ▸ (per the unified style guides).

These are all things we'd need to sort out with StackOverflow but they're trivially easy that I can't see them having a problem with them.

4

You could use apt:// protocol links, which would open with the apturl package. It sounds like apturl is installed by default, and doesn't depend on any browser-specific extensions:

https://help.ubuntu.com/community/AptURL

0
3

Since this thread just popped back up, it reminded me that I made a small change to the above script that is worth sharing. I realized that I'm normally calling the script (which I call ask-link BTW) from the command line or the Alt-F2 run dialog. So the zenity dialog is a bit redundant. So I first check to see if a package name is passed when calling the script and only show the dialog if it isn't.

#!/bin/bash

set -e

# Create link for installing packages on AskUbuntu. Source:
# http://meta.askubuntu.com/questions/548/how-to-post-links-that-install-software-via-apt

if [ -n "$1" ]; then 
    PACKAGE=$1
else
    PACKAGE=$(zenity --entry --text="packagename")
fi

echo "[${PACKAGE}](http://packages.ubuntu.com/${PACKAGE}) [![Install ${PACKAGE}](http://hostmar.co/software-large)](http://apt.ubuntu.com/p/${PACKAGE})" | xclip
2

Version 1.0.1 of AskUbuntu Add-on will come with such functionality.

http://askubuntu-extension.blogspot.com/2010/10/new-features-coming-soon.html

0
2

It's nice to have an easy install link for packages, but I'd rather have it link to a short page with the package description, which in turn has an easy install link. I think there's a danger in making the process too transparent.

Is there an alternative service to the standard package search site which doesn't make one pick a distribution version first, and has an apturl?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .