Skip to content

[Mirror] Tool to build Tempus themes on demand. Tempus is a collection of themes for Vim, text editors, and terminal emulators that are compliant at the very least with the WCAG AA accessibility standard for colour contrast.

License

Notifications You must be signed in to change notification settings

protesilaos/tempus-themes-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tempus Themes Generator

A nimble tool to automate the process of exporting the Tempus colour schemes into a variety of file formats.

Tempus is a collection of themes for Vim, text editors, and terminal emulators that are at minimum compliant with the WCAG AA accessibility standard for colour contrast.

The generator consists of a bash script which parses the sets of variables of each scheme through templates and outputs the result to the terminal (stdout).

Table of Contents

Usage

Start by cloning the repo:

git clone https://gitlab.com/protesilaos/tempus-themes-generator.git --depth 1

Then enter the directory:

cd tempus-themes-generator

NOTE all subsequent commands assume you are working within the tempus-themes-generator directory.

Run the script with the necessary arguments:

./tempus-themes-generator.sh [scheme] [template]

These are the commands for finding the available arguments (lines starting with # are comments):

# List `scheme` options
ls schemes

# List `template` options
ls templates

Tips:

  • Running the script without an argument will print a detailed help message.
  • Passing a scheme name as the sole argument will print a timed preview of the scheme's palette.

Examples

Print the winter theme for vim to the terminal output:

./tempus-themes-generator.sh winter vim

Directly create a new file named tempus_winter.vim containing the output and place it on the ~/Desktop:

./tempus-themes-generator.sh winter vim > ~/Desktop/tempus_winter.vim

File type extensions

When exporting to a new file, make sure to use the appropriate file type extension.

gtksourceview3 = .xml
konsole = .colorscheme
tilix = .json
urvxt = .Xcolors, .Xresources, .Xdefaults
vim = .vim
xcolors = .Xcolors, .Xresources, .Xdefaults
xfce4-terminal = .theme
xterm = .Xcolors, .Xresources, .Xdefaults
yaml = .yml, .yaml

NOTE. Styling options read by the X session can omit the file type extension. Not recommended.

Applying the themes

Each application uses a different set of conventions. Below are some tried and tested examples that I have run on Arch Linux as well as the latest version of Debian and Debian-based distros (Ubuntu and Linux Mint).

Template-specific repositories

Before trying to do things manually, you may want to check out the following repos with pre-built ports.

GTK3 Source View

This is the file used by GTK3 programs to highlight code syntax. Typically implemented by text editors. Some of the popular choices are Gedit (default GNOME), Pluma (default MATE), Mousepad (default Xfce), and Xed (default Linux Mint Cinnamon).

The theme files can be located in either of two places:

  • At /usr/share/gtksourceview-3.0/styles/ which makes them accessible to all users (requires root privileges).
  • Or ~/.local/share/gtksourceview-3.0/styles/ for use by the current user (directory path needs to be created if it does not already exist).

Choose whatever option suits your needs. The following commands use the latter as an example.

# Create destination directory if it does not already exist
mkdir -p ~/.local/share/gtksourceview-3.0/styles/

# Generate the theme and place it in the created directory
./tempus-themes-generator.sh winter gtksourceview3 > ~/.local/share/gtksourceview-3.0/styles/tempus_winter.xml

The theme will then be available from the supported app's preferences window.

GTK4 Source View

This is the file used by GTK4 programs to highlight code syntax (GNOME Builder is the first known editor to support it). Typically implemented by text editors. Some of the popular choices are Gedit (default GNOME), Pluma (default MATE), Mousepad (default Xfce), and Xed (default Linux Mint Cinnamon).

The theme files can be located in either of two places:

  • At /usr/share/gtksourceview-4/styles/ which makes them accessible to all users (requires root privileges).
  • Or ~/.local/share/gtksourceview-4/styles/ for use by the current user (directory path needs to be created if it does not already exist).

Choose whatever option suits your needs. The following commands use the latter as an example.

# Create destination directory if it does not already exist
mkdir -p ~/.local/share/gtksourceview-4/styles/

# Generate the theme and place it in the created directory
./tempus-themes-generator.sh winter gtksourceview4 > ~/.local/share/gtksourceview-4/styles/tempus_winter.xml

The theme will then be available from the supported app's preferences window.

Alacritty

Alacritty has two ways to read themes: (i) directly from the configuration file, which is typically stored in ~/.config/alacritty/alacritty.yml, or (ii) from another file which is imported into the configuration file.

In the former case, users must manually copy the contents of their theme of choice into the file. In the latter case, start by commenting out all colour-related options in alacritty.yml. Replace them with:

import:
  - ~/.config/alacritty/MY-TEMPUS-THEME.yml

Substitute MY-TEMPUS-THEME with the one of your choice. To then get such a theme, we can use the following, using tempus-winter as an example:

# Store all the Tempus themes in a directory, inside the Alacritty setup
mkdir -p ~/.config/alacritty/tempus-themes

# Generate the desired theme and place it in the directory
./tempus-themes-generator.sh winter alacritty > ~/.config/alacritty/tempus-themes/tempus_winter.yml

Highlight

Use -s flag directly or add it to the HIGHLIGHT_OPTIONS enironvment variable.

# Generate the desired theme in the current directory
./tempus-themes-generator.sh winter highlight > tempus_winter.theme

# Apply the theme
highlight -s tempus_winter.theme file

Kitty

By default all of Kitty's theme-releated options are defined in a single configuration file. As such, I recommend you read the tempus-themes-kitty README and adapt accordingly.

Konsole

Konsole is the default terminal for KDE. Its theme files can be located in either of two places:

  • At /usr/share/konsole/ which makes them accessible to all users (requires root privileges).
  • Or ~/.local/share/konsole/ for use by the current user (directory path needs to be created if it does not already exist).

Choose whatever option suits your needs. The following commands use the latter as an example.

# Create destination directory if it does not already exist
mkdir -p ~/.local/share/konsole/

# Generate the theme and place it in the created directory
./tempus-themes-generator.sh winter konsole > ~/.local/share/konsole/tempus_winter.colorscheme

The theme will then be available from the profile preferences window under the "Appearance" tab.

Pygments

# Generate the desired theme in the current directory
./tempus-themes-generator.sh winter pygments > tempus_winter.py
from pygments import highlight
from pygments.lexers import PythonLexer
from pygments.formatters import HtmlFormatter

from tempus_winter import TempusWinterStyle

code = 'print("Hello World")'
print(highlight(code, PythonLexer(), HtmlFormatter(style=TempusWinterStyle)))

Roxterm

Roxterm stores its colour themes in two places:

  • System-wide at /usr/share/roxterm/Config/Colours (requires root).
  • Per-user at ~/.config/roxterm.sourceforge.net/Colours/.

Choose whatever option suits your needs. The following commands use the latter as an example.

# Create destination directory if it does not already exist
mkdir -p ~/.config/roxterm.sourceforge.net/Colours

# Generate the theme and place it in the created directory
./tempus-themes-generator.sh winter roxterm > ~/.config/roxterm.sourceforge.net/Colours/tempus_winter

The theme will be available under the menubar's Preferences > Select Colour Scheme. You might need to restart the application for changes to take effect.

Tilix

Tilix theme files can be located in either of two places:

  • At /usr/share/tilix/schemes/ which makes them accessible to all users (requires root privileges).
  • Or ~/.config/tilix/schemes/ for use by the current user (directory path needs to be created if it does not already exist).

Choose whatever option suits your needs. The following commands use the latter as an example.

# Create destination directory if it does not already exist
mkdir -p ~/.config/tilix/schemes/

# Generate the theme and place it in the created directory
./tempus-themes-generator.sh winter tilix > ~/.config/tilix/schemes/tempus_winter.json

The theme will then be available from the application's preferences window, in the profiles' section (under the colours tab).

URxvt (Rxvt-Unicode)

URxvt saves colour values in either of two places. The most common use case is within the ~/.Xresources. Since that file can contain all sorts of configurations, it is best to append the output of the tempus-themes-generator.sh rather than overwrite its contents.

As such, run the following command:

./tempus-themes-generator.sh winter urxvt >> ~/.Xresources

Notice the use of >>. It is what appends the output to the file. If your .Xresources is empty (or does not exist), then just run the following instead (notice the single >):

./tempus-themes-generator.sh winter urxvt > ~/.Xresources

The other approach to having colour values for URxvt is to source an .Xcolors file from within the .Xresources. The file can be located anywhere. For the purposes of this tutorial, it is assumed you have created a hidden directory ~/.urxvt-themes/:

# Create directory for urxvt Xcolors
mkdir ~/.urxvt-themes

# Generate the desired theme and place it in the new directory
./tempus-themes-generator.sh winter urxvt > ~/.urxvt-themes/tempus_winter.Xcolors

Then source that file from within the .Xresources with the following line (note that comments in .Xresources start with a !, not an #):

#include </home/YOUR-USERNAME/.urxvt-themes/tempus_winter.Xcolors>

Whatever method you use, do not forget to reload the configurations, with xrdb -merge ~/.Xresources (may need to close all terminals and re-open them).

Xterm

Much like URxvt, Xterm stores its configurations in ~/.Xresources. Append the theme of your choice to the existing configs with the following:

./tempus-themes-generator.sh winter xterm >> ~./Xresources

Xfce4-terminal

The theme files can be located in either of two places:

  • At /usr/share/xfce4/terminal/colorschemes/ which makes them accessible to all users (requires root privileges).
  • Or ~/.local/share/xfce4/terminal/colorschemes/ for use by the current user (directory path needs to be created if it does not already exist).

Choose whatever option suits your needs, modifying the following command accordingly:

# Create directory if it does not already exist (ONLY for the .local option)
mkdir -p ~/.local/share/xfce4/terminal/colorschemes/

# Generate the theme and place it in the created directory
./tempus-themes-generator.sh winter xfce4-terminal > ~/.local/share/xfce4/terminal/colorschemes/tempus_winter.theme

The theme will then be available from the terminal's preferences window. Specifically, open the Xfce4 Terminal, navigate to Preferences > Colours. The themes should be available in the Presets section, named as "Tempus [scheme name]" (e.g Tempus winter).

Vim

The theme files can be copied manually or installed as a bundle with a plugin.

The manual method requires you to copy the file to ~/.vim/colors/. Run the following command:

# Create path to colors directory if it does not already exist
mkdir -p ~/.vim/colors/

# Generate theme and place it in the newly created directory
# NOTE the output file has a full name of tempus_winter.vim
./tempus-themes-generator.sh winter vim > ~/.vim/colors/tempus_winter.vim

As for the plugin, you can use your favourite plugin manager. With vim-plug add the following line to your .vimrc:

Plug 'protesilaos/tempus-themes-vim'

Then execute the plugin manager's command to update the plugin files.

Once available, the theme is declared with the following options inside the .vimrc:

" Theme
syntax enable
colorscheme tempus_winter

By default, the theme does not set the background color when used in a terminal to play well with transparent terminals. The background color can be set by adding the following option in the .vimrc:

let g:tempus_enforce_background_color=1

IMPORTANT. Note that tempus_winter is the full name of the winter scheme as outputted by the generator. To avoid conflicts with any other themes that may exist, it is recommended that all Tempus schemes are declared in vim with tempus_ prepended to their name.

Roadmap (help is much appreciated)

  • Refine the code where necessary.
  • Improve the templates where possible.
  • Produce templates for other popular apps.

Contributing

See CONTRIBUTING.md

Changelog

Refer to the CHANGELOG

Additional resources

For a hub with all available ports, see the main Tempus themes repo.

License

GNU General Public License Version 3.

See LICENSE

Donations

If you appreciate this work, consider donating via PayPal.

About

[Mirror] Tool to build Tempus themes on demand. Tempus is a collection of themes for Vim, text editors, and terminal emulators that are compliant at the very least with the WCAG AA accessibility standard for colour contrast.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project