This page looks best with JavaScript enabled

Changing Urxvt theme through pop-up menu

 ·  🎃 kr0m

Sometimes, reading configuration files can be difficult due to syntax highlighting. For example, when editing crontabs, comments appear in dark blue, making them impossible to read. However, with Urxvt, we can quickly switch between color profiles to view the output with a different color scheme and return to the profile we were using when we finish with the problematic file.

The idea is to program a Perl extension for Urxvt that reads the running-config of .Xresources in search of color themes and shows us a menu to choose from.

Depending on the operating system we use, the path of Urxvt extensions will be in one place or another:

/usr/local/lib/urxvt/perl/
/usr/lib64/urxvt/perl/

Nos bajamos la extensión que parseará running-config del .Xresources como root:

su -l
cd /usr/local/lib/urxvt/perl/
fetch https://alfaexploit.com/files/theme
exit

Como usuario regular editamos la configuración de nuestro .Xresources, primero añadimos un tema y luego habilitamos la extensión llamada theme.

vi .Xresources

! Urxvt themes  
URxvt.theme.Solarized.background: #fdf6e3  
URxvt.theme.Solarized.foreground: #657b83  
URxvt.theme.Solarized.color0: #073642  
URxvt.theme.Solarized.color15: #fdf6e3  
  
URxvt.perl-ext-common: default,kr0m,searchable-scrollback,theme

Merge the current Xresources configuration with the running-config:

xrdb .Xresources

Now, with Ctrl + right-click (without releasing Ctrl), a menu will appear to change the theme. To make it disappear, we will have to right-click while the mouse is over the menu. You can see how it works in this video .

NOTE: A second menu is shown because I have another text selection extension enabled that also works through pop-up menus.

If you liked the article, you can treat me to a RedBull here