Making the Codeblocks IDE Look Good on Linux

How to Override GTK3 and Apply GTK2 Themes to Codeblocks

Image for post
Image for post

Introduction

Image for post
Image for post
A GTK3 theme applied to codeblocks being drawn by GTK2.

The Solution

Looking at a Codeblocks Installation

About wxWidgets

Inspecting Dependencies with Pactree

$ pacman -S pacman-contrib
$ pactree -d 1 codeblocks

Installing Codeblocks via the SVN Repository

$ sudo pacman -Rcns codeblocks
$ yay -S codeblocks-svn
$ pactree -d 1 codeblocks
Image for post
Image for post
Codeblocks now depends on wxgtk2.

Applying a GTK2 Theme

  # Enter downloaded directory
$ cd 121685-BSM\ Simple\ 13
# Rename theme directory to remove spaces
$ mv BSM\ Simple\ Dark\ Menu/ BSM-Simple-Dark-Menu
# Create a .themes directory in home folder
$ mkdir ~/.themes
# Copy the theme to the new .themes folder
$ cp -R BSM-Simple-Dark-Menu ~/.themes
# (Optional) Delete downloaded files
$ cd ..
$ rm -fr BSM\ Simple\ Dark\ Menu/
$ GTK2_RC_FILES=~/.themes/BSM-Simple-Dark-Menu/gtk-2.0/gtkrc 
codeblocks
Image for post
Image for post
The GTK2 theme is now applied to codeblocks.

Modifying the Font

vim ~/.themes/BSM-Simple-Dark-Menu/gtk-2.0/gtkrc
style = “font”
{
font_name = “Open Sans 11”
}
widget_class “*” style “font”
gtk_font_name = “Open Sans 11”
$ GTK2_RC_FILES=~/.themes/BSM-Simple-Dark-Menu/gtk-2.0/gtkrc 
codeblocks
Image for post
Image for post
The new font settings seen in codeblocks.

Launching Codeblocks Efficiently

Creating an Alias

$ vim ~/.bashrc
alias cb=”GTK2_RC_FILES=~/.themes/BSM-Simple-Dark-Menu/gtk-2.0/gtkrc 
codeblocks”
$ source ~/.bashrc
$ cb&

Creating an Openbox Keybinding

$ mkdir ~/.scripts
$ touch ~/.scripts/launch-codeblocks.sh
$ vim ~/.scripts/launch-codeblocks.sh# In launch-codeblocks.sh
GTK2_RC_FILES=~/.themes/BSM-Simple-Dark-Menu/gtk-2.0/gtkrc
codeblocks
$ vim ~/.config/openbox/rc.xml
<keybind key=”W-c”>
<action name=”Execute”>
<startupnotify>
<enabled>true</enabled>
<name>CodeBlocks</name>
</startupnotify>
<command>./.scripts/launch-codeblocks.sh</command>
</action>
</keybind>

In Conclusion

MSc. Programmer and fan of open source software.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store