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.

Is it possible to put documents in the launcher and if yes, how?

share|improve this question
1  
It is clear: To put documents in the unity launcher on the left and to be able to launch them through there! –  hakermania Jul 24 '12 at 11:31

1 Answer 1

up vote 5 down vote accepted

I didn't find a 'normal' way to do it, so I made a bash script do the job.

Well, here's the script:

#!/bin/bash
#This script adds to launcher a specific document that the user has selected
#After specifying the document and its icon DO NOT remove them from their original position in your disk

#THE ICON SHOULD NOT HAVE SPACES IN ITS PATH AND TO BE A PNG FILE
# VALID PATH EXAMPLE:
#  /usr/share/pixmaps/wallch.png
# INVALID PATH EXAMPLE:
# /home/alex/Pictures/MY PICS/pic.png

document=$(zenity --file-selection --title="Select the document")
if [[ "$document" == "" ]]; then
   exit #no document specified
fi

icon=$(zenity --file-selection --title="Select an icon for it")
if [[ "$icon" == "" ]]; then
   exit #no icon specified
fi
name=$(basename "$document")
desktop_name=$(echo $name | tr ' ' '_')

echo "
[Desktop Entry]
Name=$name
Comment=Open me
Exec=xdg-open \"$document\"
Icon=$icon
Terminal=0
Type=Application
Encoding=UTF-8
Categories=Utility;Application;" > ~/.local/share/applications/$desktop_name.desktop

echo "The file ~/.local/share/applications/$desktop_name.desktop has been created, pointing to $document"

To run the above script, copy and paste it into a file with Gedit, then save it as add_document_to_launcher.sh, right click on it → Properties → Permissions → Check allow executing file as program. Then (preferred way is to) open a terminal and run the script through there or double click on the file and choose 'Run'.

A dialog will pop-up asking you for the document, then another will pop-up asking you for an icon for this document. Select any icon you like BUT: It has to be PNG and its path not to contain spaces.

After this, a file will be created under ~/.local/share/applications with the extension .desktop.

If you open the DASH and search your document with its filename, it will be shown under 'Applications' (and not under Files & Folders). You can simply drag and drop your document on the launcher! That's it :)

EDIT: remember: after this, do not remove the document from its path or the icon you have selected!

share|improve this answer
    
Thanks very much :D –  kikeriki Jul 24 '12 at 11:38
    
if you have any problem running the script because you haven't done it again, please say so –  hakermania Jul 24 '12 at 11:58

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.