Use xres and rc

Use xres and rc

  • mdo  DigitalBox
  •   System
  •   May 31, 2025

In case you need to play with resources files under Haiku, two commands are needed: xres and rc.

The first one "xres" - eXtended RESource - is used to handle the resources attached to a file, and the second one "rc" - Resource Compiler - is required when you need to compile a definition file into a resources file.

We will review in this article how to use both commands to handle easily resources attached to files.

Identify resources

Let's take a simple example.

First, we will make a copy of the StyledEdit application and we will display the resources attached to this application.

In a Terminal, type:

cp /system/apps/StyledEdit /boot/home/Desktop
xres -l /boot/home/Desktop/StyledEdit

Several entries are included in the resources:

  • The signature of the application (BEOS:APP_SIG)
  • The version of the application (BEOS:APP_VERSION)
  • The icon attached to the application (BEOS:ICON) 

Now let's check the values of the attributes attached to the application:

listattr /boot/home/Desktop/StyledEdit

It also contains the application signature, version and icon.

Remove attributes

In order to showcase the resources, we need to remove these attributes.

In a Terminal type:

rmattr BEOS:APP_SIG /boot/home/Desktop/StyledEdit
rmattr BEOS:ICON /boot/home/Desktop/StyledEdit
rmattr BEOS:APP_VERSION /boot/home/Desktop/StyledEdit
rmattr BEOS:L:STD_ICON /boot/home/Desktop/StyledEdit
rmattr BEOS:M:STD_ICON /boot/home/Desktop/StyledEdit


Then verify these attributes have been removed:

listattr /boot/home/Desktop/StyledEdit

Restart your system.

If you check the copied StyledEdit application, the icon is now no more visible like below:

However if you check the FileTypes, icon is still attached to the file:

The reason behind is that the resources part is containing the icon of the application, while the attribute representing the icon is not yet updated.

In order to update the corresponding attribute, right click on the application and select "Identify":

Now if you check the application on the Desktop :

  • The icon is now visible
  • The attributes corresponding to "BEOS:ICON" and "BEOS:APP_SIG" have been updated up to the resources attached to the application

You can check that by typing:

listattr /boot/home/Desktop/StyledEdit

Let's remove again these attributes:

rmattr BEOS:APP_SIG /boot/home/Desktop/StyledEdit
rmattr BEOS:ICON /boot/home/Desktop/StyledEdit

And check it's the case:

listattr /boot/home/Desktop/StyledEdit

We will now create a new resources file.

Resources definition

The first step to create a resources file is to edit a resources definition.

Open Pe editor with the name of the resources definition:

lpe /boot/home/Desktop/app.rdef




Copy/Paste the below content:

resource app_signature "application/x-vnd.MySampleApplication";

resource app_version {
    major  = 1,
    middle = 0,
    minor  = 0,

    variety = B_APPV_FINAL,
    internal = 0,

    short_info = "My Sample Application",
    long_info = "© 2025 Haiku Insider"
};

resource vector_icon {
    XXX
};

Save the file.

Then open Icon-O-Matic.

Drag and drop the WebPositive icon into Icon-O-Matic:

Export that icon:

Select the "HVIF RDef" format :

Indicate "web.rdef" as filename and confirm with "Save".

If you open the content of the file, it looks like below:

The last step is to copy the content of the icon RDef (web.rdef) into the application RDef.

Copy the content of the icon data into the "XXX" pattern of the "app.rdef" file, just after "resource vector_icon" like below:

Save your changes into "app.rdef".

The resources definition file is now completed.

Create resources file

We will now create the final resources file (.rsrc) via the resources compiler command "rc".

In a Terminal type:

rc -o /boot/home/Desktop/app.rsrc /boot/home/Desktop/app.rdef

The final step is to attach the resources to the application:)

Attach resources to application

In a Terminal type:

xres -o /boot/home/Desktop/StyledEdit /boot/home/Desktop/app.rsrc
xres -l /boot/home/Desktop/StyledEdit

The resources file is now attached to the copy of StyledEdit!

Let's identify the application to update the attributes:

As you can see, the webpositive icon coming from the resources file is now displayed: 

If you check the attributes on StyledEdit, you will notice:

  • The signature attribute has been added
  • The icon attribute is also visible

If you launch this copy of StyledEdit, the new icon is effective in the Tracker and the Deskbar:

I hope resources files will not have any secret for you now.

Any comment you would like to share?

You can put a comment below.


Powered by Bludit - Hosted by Planet Hoster
© 2025 Haiku Insider