PDA

View Full Version : Application icon for Linux



Relfos
25-10-2011, 11:15 AM
I recently compiled my game to Linux with fpc, and while it works perfectly, now I want to add an icon to it.
Is there anyway to embed an icon inside the executable?

paul_nicholls
25-10-2011, 11:29 AM
I think Lazarus can do that, there is some setting in the program I believe...not sure about pure fpc though

Andru
25-10-2011, 12:12 PM
Is there anyway to embed an icon inside the executable?
No, icons can't be inside the executable and shows somewhere in file browser/etc. You can show your icon only in menus/etc. For this you need to place your icon into /usr/share/pixmaps(with name equal to executable). Or if you can provide different sizes for icon then place them here: /usr/share/icons/hicolor/size/apps.

Relfos
25-10-2011, 12:13 PM
From what I've read in the wiki, it seems that even lazarus only supports icons on Windows and Mac, and in Linux icons need to be in a specific folder.

Relfos
25-10-2011, 12:14 PM
No, icons can't be inside the executable and shows somewhere in file browser/etc. You can show your icon only in menus/etc. For this you need to place your icon into /usr/share/pixmaps(with name equal to executable). Or if you can provide different sizes for icon then place them here: /usr/share/icons/hicolor/size/apps.
That means the only way to supply a icon is to have some kind of installer, right?

Andru
25-10-2011, 01:30 PM
to have some kind of installer, right?
Yes, and this "some kind of installer" is a "package"(most popular - deb and rpm). But different GNU/Linux distros use different type of packages.

code_glitch
25-10-2011, 02:05 PM
Although if you made a deb/rpm solution you'd cover roughly 80% of the linux market, I know a lot of people are now distributing tar.gz packages with a install.sh script which is nice since it build from source/.a and .o files upon installation and does all the dirty work - be it debian, redhat, the pacman system arch uses etc... All you'd need in the dep list are the fpc meta package and the appropriate dev libs. Although, you could include the *-dev .so files in your gz archive...

The niceness of just doing a


tar xvf somepackage.tar.gz
cd somepackage
sudo ./install.sh


In 50 less keystrokes thanks to tab in tty is so nice for the end user.... even the make $ make install route is nice :D

Relfos
25-10-2011, 05:37 PM
I see, but does that means that the package needs to include the source?
This is a comercial project, also available for other platforms, so I don't want to release the source for now.
Right now I've simply put the compiled executable along with the resource files in a tar.gz file, would there be any problem with this approach?

code_glitch
25-10-2011, 05:54 PM
Unless I am mistaken you could just include the .a and .o file and then just do the linking on the target - I recall some closed source codecs and etc worked that way...

In your instance (executable in tar.gz) I guess you would just have to link it dynamically and hope for the best - just be warned that if any bugs arise with this setup, you cant ask for compiler messages and you may end up having a super fun time with clients... Or at least thats my experience with the last Ludum dare fiasco.

Andru
25-10-2011, 06:56 PM
I see, but does that means that the package needs to include the source?
If you don't use libraries with GPL-like license(or LGPL with static linking) - then no need to include source code. For Linux rules of opening source code is the same as for other platforms :)

cairnswm
26-10-2011, 05:54 AM
I do not use Linux so my suggestion could be hopelessly wrong.

Could your executable not create the icon in the correct directory(ies) on first run? So the executable starts up, checks in the directory for the icon file, if it does not find it, creates/copies it and carries on.

As part of your install process/instructions you could just execute the program once to create the icons.

Andru
26-10-2011, 06:04 AM
Could your executable not create the icon in the correct directory(ies) on first run?
Can't, because writing to / needs root privileges :)

cairnswm
26-10-2011, 06:17 AM
So how does an installer copy files there?

Andru
26-10-2011, 08:09 AM
So how does an installer copy files there?
Installing packages also needs a root privileges, but in this case system will ask user about a password. Linux and MacOS X are not a Windows where you can setup any <censored> in your system(with by default settings) :)

code_glitch
26-10-2011, 06:04 PM
Aaah, the magic of sudo...

@carinswm: Its not just installers that can't mess with system files in Linux, viruses, little children, accidental keystrokes, hackers, spammers and etc... In linux - if you ain't got the sudo code - you ain't got acces to me system files... Your files fine, but the system files or someone else's files higher in the permission heirachy - no sudo code, no can do.

Its a nice system when you use it every day though, and since you haven't got to worry about viruses being able to do anything, you don't have to spend any resources on an antivirus etc...

Carver413
27-10-2011, 05:27 AM
you can sudo just about anything so why not just sudo your file to do the setup

code_glitch
27-10-2011, 12:37 PM
And you do. Sudo runs the command after it with root privileges, after prompting you for you password. The downside, is that if you ran a command from a shell after a 'sudo su' and in many instances a 'sudo xyz' where xyz was your command, xyz would use /root as the home directory where to store preferences, documents etc... Instead of /home/yourhomedirectory and inputting your password every run is tedious too.

I hope that clears up your understanding of how sudo works on Linux. :)