2

I have changed general font size for gtk-2 applications by adding this to my gtkrc file:

gtk-font-name = "Sans 16"

this also affected the text size in the application "dock", or however it is called, in the panel:

enter image description here

Now even the text "New Tab - Chromium" does not fit there anymore.

Can I selectively only change the text size in the application dosck, while leaving the general gtk-2 test size ?

I am using openbox and fbpanel.

1 Answer 1

2
+125

You can use the GTK2_RC_FILES environment variable to control the appearance of (individual) GTK2 applications.

Create a custom gtkrc config (e.g. ~/.fbpanel-gtkrc) for fbpanel and set your font (or any style) settings in there:

style "custom-font" {
  font_name = "Sans 16"
}

class "*" style "custom-font"

Then modify the start command for fbpanel to set GTK2_RC_FILES=~/.fbpanel-gtkrc. For example, if you launch it through the .desktop file, change the Exec line like this:

Exec=env GTK2_RC_FILES=~/.fbpanel-gtkrc fbpanel

Explanation

When a GTK2 application starts, it loads settings in a particular sequence, layering configurations on top of each other. This layering allows later settings to override earlier ones. The sequence is as follows:

  1. GTK2 first loads the settings from the system-wide configuration file, usually found in /etc/gtk-2.0/gtkrc.
  2. Next, GTK2 loads the user's personal configuration file, typically ~/.gtkrc-2.0, if it exists.
  3. If the GTK2_RC_FILES environment variable is set, GTK2 will load the configuration files specified in that variable in the order they're listed (separated by colons). These settings can override any previously loaded settings.
  4. Finally, an application can have the application-specific settings that it applies after reading the GTK2 configurations. These might override or augment the loaded GTK2 settings. In the case of fbpanel, I didn't find a way to set fonts from its configs.

I hope this helps!

5
  • thank you, but can I change the font only for the "dock" element? I don't want to change other fonts that fbpanel uses. Commented Aug 13, 2023 at 11:36
  • 1
    You'll probably want to change class "*" style "custom-font" to some specific widget class that the dock component uses. However, it may use some generic widget class for all the components, so it won't be possible to do what you want. In any case, you'll need to dive deep into fbpanel's source code or use some gtk inspection tools/debugger to find out :/ Commented Aug 13, 2023 at 12:14
  • 1
    From my initial research, I could not find what widget class you need. I'll let you know if I find it Commented Aug 13, 2023 at 12:18
  • thank you. I am alredy compiling my own fbpanel with some additional patches. So could I hard code the font size in the source code, but only for that dock element ? Commented Aug 13, 2023 at 13:36
  • It would be something like GtkStyle *current_style = gtk_widget_get_style(dock_widget) and then font_desc = pango_font_description_from_string("Sans 10") Though it would be a challenge to find this "dock_widget" or something like that in the code Commented Aug 13, 2023 at 13:42

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.