Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Ubuntu Unity: Creating an icon

  1. #1
    Join Date
    Aug 2011
    Location
    USA
    Beans
    48
    Distro
    Ubuntu 11.04 Natty Narwhal

    Ubuntu Unity: Creating an icon

    Hi everyone,

    I am looking for a tutorial to create my own icon.

    I have created a program (binary file) that I would like to run with an icon. I have an image for the icon and I know the location of the binary, but I do not know how I can create an icon that I could put in the Unity launch bar.

    I am running Ubuntu 11.10 but cannot find any tutorial for creating an icon (my searches only found how to modify the look and feel or update the launch bar).

    Could anyone please link me to a tutorial to do that, or tell me how to create an icon from the image and put in the location of the binary please?

    Thank you very much!

  2. #2
    Join Date
    Jun 2011
    Location
    United Kingdom
    Beans
    Hidden!
    Distro
    Lubuntu Development Release

    Re: Ubuntu Unity: Creating an icon

    Well, the essence of it is you copy the image to /usr/share/icons/hicolor, then the right size, then the right category - for instance, /usr/share/icons/hicolor/24x24/apps/ for a 24x24px icon for an application.

    Then you create a .desktop file:

    http://standards.freedesktop.org/des...ec-latest.html

    And fill in the fields as appropriate, then copy to /usr/share/applications. You should now see the launcher etc. in the Unity dash, complete with icon. This should work in all desktops, not just Unity.

  3. #3
    Join Date
    Jun 2011
    Location
    United Kingdom
    Beans
    Hidden!
    Distro
    Lubuntu Development Release

    Re: Ubuntu Unity: Creating an icon

    Example:

    Code:
    [Desktop Entry]
    Type=Application
    Name=Myapp
    Exec=/usr/bin/myapp
    GenericName=
    Comment=
    Icon=<your icon's name, e.g myicon, NOT /usr/share/icons/etc.>
    Terminal=False (if it doesn't need a terminal)
    Categories=<categories here>
    You could test this using a pre-made icon from usr/share/icons and a .desktop entry. Try making one for firefox to get the feel of things. It will appear as a shortcut straightaway, but if you copy it to /usr/share/applications it will show up in Unity.
    Last edited by MG&TL; November 11th, 2011 at 05:41 PM.

  4. #4
    Join Date
    Aug 2011
    Location
    USA
    Beans
    48
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: Ubuntu Unity: Creating an icon

    Quote Originally Posted by MG&TL View Post
    Example:

    Code:
    [Desktop Entry]
    Type=Application
    Name=Myapp
    GenericName=
    Comment=
    Icon=<your icon's name, e.g myicon, NOT /usr/share/icons/etc.>
    Terminal=False (if it doesn't need a terminal)
    Categories=<categories here>
    You could test this using a pre-made icon from usr/share/icons and a .desktop entry. Try making one for firefox to get the feel of things. It will appear as a shortcut straightaway, but if you copy it to /usr/share/applications it will show up in Unity.
    Woo, thanks a lot!!! You helped me a lot.

    I've got the icon on the desktop, with it's correct image and it launches the correct binary, yay! I am not sure I used the right thing for Icon because you say it should be the name.

    I have one question, using ~ does not seem to work, I have to replace it with /home/..., is it normal please?

    Here is my file (which seems to work, I would wish I could replace /home/rudys with ~)

    Code:
    [Desktop Entry]
    Type=Application
    Name=Remote
    Exec=/home/rudys/project/bin/Host/clientToDevice 192.168.0.119 3333
    TryExec=/home/rudys/project/bin/Host/clientToDevice
    Terminal=false
    Icon=/home/rudys/project/remote.png
    GenericName=Remote Control
    Categories=Application
    Please let me know if you see any error in my file. I haven't completely grasped the difference between TryExec and Exec. I thought TryExec was just the path, and Exec the actual binary name, but when I do have it cannot find the file.

    Thanks a lot for your help.

  5. #5
    Join Date
    Aug 2011
    Location
    USA
    Beans
    48
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: Ubuntu Unity: Creating an icon

    I have been reading that .desktop files only support absolute path and not relative path for security concerns, which is why '~' did not work.

    Would anyone please confirm if this information is right? I have not found any good workaround that problem, please let me know if you know one.

  6. #6
    Join Date
    Dec 2005
    Location
    Western Australia
    Beans
    11,480
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Ubuntu Unity: Creating an icon

    Rather than craft a .desktop file by hand, why not use the Main Menu (alacarte) program in Ubuntu? Open up the Dash and type 'main menu' and then click on the first search result that appears. Create a menu item, specifying the icon, name, and command (path to the file you want to run).

    This icon will appear in the Installed Applications part of the Dash, or you can search for it of course. Drag its icon from the Dash to the Launcher to store it in the Launcher.
    I try to treat the cause, not the symptom. I avoid the terminal in instructions, unless it's easier or necessary. My instructions will work within the Ubuntu system, instead of breaking or subverting it. Those are the three guarantees to the helpee.

  7. #7
    Join Date
    Aug 2011
    Location
    USA
    Beans
    48
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: Ubuntu Unity: Creating an icon

    Quote Originally Posted by 3rdalbum View Post
    Rather than craft a .desktop file by hand, why not use the Main Menu (alacarte) program in Ubuntu? Open up the Dash and type 'main menu' and then click on the first search result that appears. Create a menu item, specifying the icon, name, and command (path to the file you want to run).

    This icon will appear in the Installed Applications part of the Dash, or you can search for it of course. Drag its icon from the Dash to the Launcher to store it in the Launcher.
    The problem is that I am currently actually including the launcher (or .desktop) inside a folder part of the project. This folder is shared with other people (via svn), so I wanted them to be able to start the binary just by opening the .desktop file.

    It works fine on my machine and I can put it in the dash, the problem is when it comes to sharing it with other people.

  8. #8
    Join Date
    Jun 2011
    Location
    United Kingdom
    Beans
    Hidden!
    Distro
    Lubuntu Development Release

    Re: Ubuntu Unity: Creating an icon

    Yeah, as I understand it, not all shells/implementation of linux use ~/ as a shortcut to /home/$USER, so absolute paths are safest. Although 'security concerns'-really? I'm not sure how you would hack anything via a .desktop?

    Wow, 3rdalbum, I didn't know that was possible. Something new every day.
    Last edited by MG&TL; November 11th, 2011 at 05:40 PM.

  9. #9
    Join Date
    Jun 2011
    Location
    United Kingdom
    Beans
    Hidden!
    Distro
    Lubuntu Development Release

    Re: Ubuntu Unity: Creating an icon

    Because you would usually only include .desktop files when you are distributing it, (i.e via a deb package), it kinda assumes that you won't be using your home folder, more likely something in your $PATH like /usr/bin/ in your case (I suspect).

    And no, for the same reason as above (inconsistency across distros/shells) you need an absolute path even if it's in your $PATH.

    To find stuff in your path, do:

    Code:
    echo $PATH

  10. #10
    Join Date
    Jun 2011
    Location
    United Kingdom
    Beans
    Hidden!
    Distro
    Lubuntu Development Release

    Re: Ubuntu Unity: Creating an icon

    Quote Originally Posted by Jary316 View Post
    Woo, thanks a lot!!! You helped me a lot.

    ...thing for Icon because you say it should be the name.



    Please let me know if you see any error in my file. I haven't completely grasped the difference between TryExec and Exec. I thought TryExec was just the path, and Exec the actual binary name, but when I do have it cannot find the file.

    Thanks a lot for your help.
    No problem-I meant you only need the absolute path if you're *not* saving to anywhere with /usr/share/icons. Otherwise, normally you put it in /usr/share/icons, and just use the name.

    Difference between exec and Tryexec-absolutely no idea. I assume 'tryexec' this, and if it works, do 'exec' this. I think it should be in the freedesktop spec link I gave.

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •