1 Themes
liquibyte edited this page 2026-11-19 16:23:31 -06:00

Themes

Hanshi has two kinds of themes. The window theme gives the colors of the scrollbar, the tabs, the menu and the dialogs. The terminal theme gives the colors of the terminal: its background and text, the 16 colors programs use, the styles of bold and italic text, and more. This page describes both, the four built-in terminal themes, and every key of a terminal theme file.

1. Window themes

Choose the window theme in Preferences > Window > Theme. Hanshi has 14 built-in window themes: Chocolate, Dark, Ember, Forest, Gold, Graphite, Light, Midnight, Ocean, Rose, Rust, Slate, Teal and Violet. Dark is the first choice.

  • At every start, Hanshi writes each built-in theme that is missing to ~/.config/hanshi/themes/ ($XDG_CONFIG_HOME/hanshi/themes/ when that variable is a full path, beside the settings file), one file for each, such as Dark.conf. Change a file there to change the theme, or add a file of your own: its name, without .conf, is the theme's name in Preferences.
  • Hanshi also lists the themes installed for Xtk programs: ~/.themes/NAME/xtk/, ~/.local/share/themes/NAME/xtk/ (or $XDG_DATA_HOME/themes/NAME/xtk/) and /usr/share/themes/NAME/xtk/. A theme in Hanshi's own folder wins over an installed one of the same name.
  • The list in Preferences is made when Hanshi starts: a theme file you add while it runs shows in the list at the next start.
  • A window theme file is an Xtk theme: a [colors] section of role colors (window, text, accent and others), from which every widget's colors follow, and sections that change single widgets. The built-in files show every key. A color in a window theme can be written #RGB, #RRGGBB, #RRGGBBAA, RRGGBB without the #, rgb(...), rgba(...), or a name such as white, and a line can be of any length.
  • The window theme of Preferences is found by its name; when no theme has exactly that name, upper and lower case do not matter.
  • The window theme gives the menu its frame, round corners and padding, and, in the built-in themes, an outline in the accent color around the item under the pointer. Tooltips take the size of their font in pixels, as the other widgets do, so their text is a little smaller than it was.
  • With the terminal's colors set to "As the window theme" (Preferences > Appearance), the terminal takes the window theme's text view colors: background, text, selection, selection text and cursor.

2. Where the terminal's look comes from

The terminal's colors come from a built-in theme, a theme file or the window theme; the terminal theme fills in every key left out; the settings of Preferences go over the theme's settings, and the result is the terminal of every tab

Preferences > Appearance > Colors chooses one of the three sources at the left. The settings of Preferences always go over the settings of the theme.

A theme gives the colors, the attribute styles and the rules. The settings in its [terminal-widget] section are the defaults of a terminal library, and in Hanshi the settings of Preferences take their place: only the font family and size are the theme's, when Preferences names none ("Default" and 0).

3. The built-in terminal themes

Theme What it is Background, text
Hosho Dark Dark grey with clear colors. The first choice. #1B1D21, #D7DAE0
Hosho Light Near white with dark text. #FAFAF7, #2A2C33
Sumi Ink: warm black, text the color of old paper, a red seal for the cursor. Each prompt's line has a background of its own. #14110F, #E6DFD3
Washi Paper: warm white, ink for the text, a red seal for the cursor. Each prompt's line has a background of its own. #F4EFE4, #3B3228

The four themes are part of the program. The folder themes/ of the source (installed in /usr/share/hanshi/themes/) has each of them as a file with every key and a line of words above each one: copy one to start a theme of your own.

4. Using a theme file

  1. Copy a theme, for example cp "/usr/share/hanshi/themes/Hosho Dark.conf" ~/.config/hanshi/mine.conf, and change its name and colors.
  2. In Preferences > Appearance, set Colors to "A theme file" and Theme file to mine.conf (a file name alone is looked for in ~/.config/hanshi; you can also give a full path or one that starts with ~/). Click Apply or OK.
  3. Edit the file and save it: the terminal shows the change within a moment, without Apply. Hanshi notices a change by the file's time, which has a resolution of one second.

A file that cannot be read gives the colors of Hosho Dark. A line or a value that Hanshi does not understand is skipped; the key keeps its fallback. A theme file is read up to its first 256 KB.

An editor theme of Unryu is a terminal theme too. For each of these [terminal] keys that a file leaves out, the terminal takes the color of its [editor] section: background, text, selection (and selection-text with it), caret for the cursor, line-numbers for prompt-mark, and compiler-success and compiler-error for prompt-success and prompt-failure; and the link of its [syntax] section for link. A [terminal] key always wins. So you can name one of Unryu's editor_themes files as the theme file, and the terminal looks as the editor does.

5. The theme file

A theme file has sections and key = value lines; a line that starts with ; is a comment. A theme can be as short as three lines: every key it leaves out takes a fallback.

[theme]
name = My Theme

[terminal]
background = #14110F
text = #E6DFD3
cursor = #C8553D
; the background of each line with a prompt
prompt-line = #1D1916

[palette]
red = #E06C75

[attributes]
; bold text with no color of its own: white, in the regular face
bold = #FFFFFF -
; italic text: its own color, drawn italic
italic = - - italic

[rules]
; the words error, failed and fatal in red and bold, in upper or lower case
error = #FF5555 - bold /error|failed|fatal/i

A color is #rrggbb or #rgb (#fa0 is #ffaa00). For a key whose words say so, - means "each character's own color", and none means "not drawn". On a key that needs a color of its own, such as background or cursor, - gives the key its fallback color.

A style is foreground background [bold] [italic], where - is the text's own color or the cell's own background.

[theme]

Key What it is
name, description The theme's name and a line about it.

[terminal]: the view

Each background key has a key for the text on it (-text).

Key What it colors Fallback
background The view's background. #1B1D21
text Text with no other color. light on a dark background, dark on a light one
selection, selection-text The selection; its text (-: each character's own color). a quarter of the way from the background to the text; -
cursor, cursor-text The cursor; the character under a block cursor (-: the background's color). the text color; -
link A hyperlink, and a link under the pointer. bright blue (blue on a light background)
gutter The margin where the prompt marks are drawn. the background
prompt-mark The mark of a prompt whose command still runs or gave no result. halfway from the background to the text
prompt-success, prompt-failure The mark after a command that ended with status 0, or with another status. They are also the colors of a tab's label after a command (The Window and Tabs). green, red of the palette
prompt-line, prompt-line-text The background of each prompt's line (none: not drawn); the text on it. none; -
output-failure, output-failure-text The background of the output of a command that failed; its text. none; -
fold The words "... N lines" in place of a command's hidden output. the prompt-mark color
search-match, search-match-text Each match of a search; its text. the palette's yellow, halfway into the background; -
search-current, search-current-text The match the search is at, and the letters on links (Ctrl+Shift+O); its text. the palette's yellow; the background (on a dark theme)

[palette]: the 16 colors

black, red, green, yellow, blue, magenta, cyan, white (colors 0 to 7) and bright-black to bright-white (colors 8 to 15). A color left out comes from one of two fallback palettes, one made for a dark background and one for a light one, chosen by the theme's background. The 240 colors above them are those of xterm's 256-color palette. Yellow and bright blue are also the amber and blue of a tab's label.

[attributes]: the styles of marked text

A style for text a program marks bold, faint, italic, underline or blink. A color here is only for text that has no color of its own: a program's color always wins. Without the word bold, bold text keeps the regular face; without the word italic, italic text stays upright. Faint text with no color here is drawn halfway between its color and the background. The built-in themes have bold = - - bold and italic = - - italic.

[rules]: words in a program's output

Each rule is name = foreground background [bold] [italic] /pattern/, with an i after the last / when upper and lower case do not matter. The pattern is a POSIX extended regular expression, of up to 159 characters, run on each line as it is drawn. The rule's colors are only for text with no color of its own; its bold and italic choose the face. When two rules find the same text, their faces add up: one rule's bold and another's italic give bold italic text. A theme has up to 32 rules; a rule with the name of an earlier one replaces it, and a rule whose name is longer than 31 bytes is skipped. A pattern that is not correct finds nothing. The built-in themes have no rules.

[rules]
error = #FF5555 - bold /error|failed|fatal/i
warning = #FFD700 #3A3000 /warning:/

[terminal-widget]: the settings

The same keys as the [terminal-widget] section of hanshi.conf: font-family, font-size, cursor-shape, cursor-blink, padding, gutter-width, line-spacing, scrollback-lines, bold-bright, clipboard-read, clipboard-write, keyboard, answerback, paste-confirm, ligatures, bell, minimum-contrast, notify-command-seconds, log-file, background-image, background-opacity, window-ops and print-command (Preferences says what each does). In Hanshi only font-family and font-size of a theme are used, and only when Preferences names no font; the others are those of Preferences.

6. Known limitations

  • In a terminal theme file a color is written in hexadecimal: names such as red are not read there (programs can use X11 color names when they set colors, Terminal Features). Window theme files take every form (section 1).