Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Add an icon to an ubuntu app

Tags:

python

ubuntu

gtk

I have developed an App for ubuntu in python using quickly. I packaged it and is working perfectly but i could not find how to add an icon to my App currently its like a blank icon.

I have used Glade and gtk.

like image 692
gabber12 Avatar asked Jun 11 '12 11:06

gabber12


People also ask

How do I create an executable icon in Linux?

Executables on Linux do not have icons embedded (try to point your file manager to /usr/bin ). What you have seen is probably a Desktop Entry. That's a text file describing the icon, program name and the executable.


1 Answers

The best way is to install a "named icon". To do this, your installation script will copy the file to a specific location which is dependent up on the user's system, but typically <datadir>/icons/hicolor/<size>/app/<app-name.png|svg> where datadir is something like /usr/local/share. The minimum suggested icon sizes are typically a scalable icon with SVG format and a PNG icon that is 48x48 pixels.

Once you've copied the icons to the right place, you can update GTK's cache using the gtk-update-icon-cache command.

When you've installed a "named icon", your application can refer to it by name:

window = Gtk.Window
window.set_icon_name("myapp")

Now, one other thing you'll need to do, is install a "destop entry" file. These tell Ubuntu (or GNOME or KDE or Xfce) about your application so that it can be launched and also what it's icon is. You create the file according to the Desktop Entry Specification and copy it to <datadir>/share/applicaions/ with a .desktop file extension. You can see examples in /usr/share/applications/ from applications installed on your system. You could also use Desktop Entry Editor to create the .desktop file. In the desktop file, the icon would be set to your "named icon" too.

So all in all, to install a named icon and a desktop entry, you're looking at something like:

/usr/local/share/applications/myapp.desktop
/usr/local/share/icons/hicolor/scalable/apps/myapp.svg
/usr/local/share/icons/hicolor/48x48/apps/myapp.png
like image 169
Micah Carrick Avatar answered Oct 15 '22 21:10

Micah Carrick