In a former article, we have learned how to use Icon-O-Matic to create a nice icon to attach to a program.
Today, we will focus only on the command to attach the icon and propose a solution to facilitate its usage.
The way to add an icon to a program relies on the attributes.
The command to use for that is "addattr" :
addattr -f icon.hvif -t icon BEOS:ICON myapp
As you can see, this command will need :
Now let's do a quick demo.
Suppose you install the game "QSoloCards" via HaikuDepot :
When you look at the application QSoloCards in "boot/system/apps", it has an icon attached to the executable via the below attribute :
Let's suppose we would like to replace this icon by an image representing a gamepad available in the "/system/data/icons/haiku/categories/32" under the name "applications-games.svg :
In a Terminal call Icon-O-Matic to open this SVG file :
The below gamepad picture is loaded :
Select "File>Export As" in HVIF format :
Save that icon on the Desktop with the name "games.hvif".
Then create a new folder named "scripts" in "/boot/home"
Go into this folder and edit a file named "QSoloCards" :
lpe SoloCards &
Put in this file two lines :
#!/bin/bash
/boot/system/apps/QSoloCards
Save the file and quit Pe editor.
The aim of this bash script is to launch the game "QSoloCards".
Indicate this file can be executable :
chmod +x ./QSoloCards
Great !
If you look at its icon, it's the one used for text files :
Now let's attach to this script file the nice gamepad icon we have just saved before :
addattr -f /boot/home/Desktop/game.hvif -t icon BEOS:ICON /boot/scripts/QSoloCards
If you check in the Tracker for the information on this file, you can see the BEOS:ICON attribute is now attached :
And indeed, the Tracker is displaying this icon on the bash script "QSoloCards" :
Please note the addattr command will not work directly on the programs in the "/system/apps/" system folder because this folder and its content are not modifiable.
I really don't care about the details on the attributes command, so how to simplify this ?
In a Terminal, create a function by doing a copy/paste of the below :
seticon()
{
if [ $# -ne 2 ]; then
echo "Usage: seticon <icon-file> <executable>"
return 1
fi
addattr -f "$1" -t icon BEOS:ICON "$2"
}
Now if you need to call "addattr" again, just type :
seticon /boot/home/Desktop/game.hvif /boot/scripts/QSoloCards
Great, it's doing exactly the same job but more easily !
The command is now more explicit and only the minimum is required : the icon file as the first argument and the executable to modify :)
If you want to keep this function available after restarting your system, just update or create the "/boot/home/config/settings/profile" file by adding the seticon() function :
lpe /boot/home/config/settings/profile &
I hope you find this article useful to attach customized icons to your favorite applications :)