├── img ├── 1.png ├── 2.png ├── 3.png ├── 4.png ├── 11.png ├── 11_white.png └── examples.gif ├── Theme.HC ├── update.sh ├── README.md └── generate_theme.py /img/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/duartebranco/TempleOs-pywal-colors/HEAD/img/1.png -------------------------------------------------------------------------------- /img/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/duartebranco/TempleOs-pywal-colors/HEAD/img/2.png -------------------------------------------------------------------------------- /img/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/duartebranco/TempleOs-pywal-colors/HEAD/img/3.png -------------------------------------------------------------------------------- /img/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/duartebranco/TempleOs-pywal-colors/HEAD/img/4.png -------------------------------------------------------------------------------- /img/11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/duartebranco/TempleOs-pywal-colors/HEAD/img/11.png -------------------------------------------------------------------------------- /img/11_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/duartebranco/TempleOs-pywal-colors/HEAD/img/11_white.png -------------------------------------------------------------------------------- /img/examples.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/duartebranco/TempleOs-pywal-colors/HEAD/img/examples.gif -------------------------------------------------------------------------------- /Theme.HC: -------------------------------------------------------------------------------- 1 | // This file was auto-generated by generate_theme.py using Pywal colors. 2 | // https://github.com/duartebranco/TempleOs-pywal-colors 3 | public CBGR48 gr_palette_pywal[COLORS_NUM]={ 4 | 0xc5c5c2c2c2c2, // BLACK 5 | 0x383839393d3d, // BLUE 6 | 0x47474c4c5151, // GREEN 7 | 0x686864645757, // CYAN 8 | 0x4e4e5a5a6363, // RED 9 | 0x282869696e6e, // PURPLE 10 | 0x4e4e6b6b6f6f, // BROWN 11 | 0x99998e8e8e8e, // LTGRAY 12 | 0x6f6f5a5a5a5a, // DKGRAY 13 | 0x4b4b4d4d5252, // LTBLUE 14 | 0x5f5f66666c6c, // LTGREEN 15 | 0x8b8b86867474, // LTCYAN 16 | 0x686879798585, // LTRED 17 | 0x36368d8d9393, // LTPURPLE 18 | 0x69698f8f9595, // YELLOW 19 | 0x1a1a0b0b0b0b // WHITE 20 | }; 21 | 22 | GrPaletteSet(gr_palette_pywal); 23 | 24 | -------------------------------------------------------------------------------- /update.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # update.sh 4 | # 5 | # This script mounts TempleOs C drive into a temporary mount folder, cp's the new Theme.HC file and checks if it's included in HomeSys.HC 6 | # 7 | # WARNING: 8 | # This script could vary given the TempleOs instalation and virtualization method 9 | # Given the ""intrusive"" tasks performed by this script, it's highly recommended to read it first and change everything accordingly 10 | 11 | set -e 12 | 13 | # Usage check 14 | if [[ $# -ne 2 ]]; then 15 | echo -e "${YELLOW}Usage:${NC} $0 " 16 | echo -e "Example: $0 templeos.img /tmp/templeos" 17 | exit 1 18 | fi 19 | 20 | IMAGE="$1" 21 | MOUNT_POINT="$2" 22 | SCRIPT_DIR="$(dirname "$0")" 23 | 24 | echo "Mounting TempleOs's C drive into "$MOUNT_POINT" ..." 25 | mkdir -p "$MOUNT_POINT" 26 | guestmount -a "$IMAGE" -m /dev/sda1 "$MOUNT_POINT" 27 | 28 | # Auto-clean on exit 29 | cleanup() { 30 | echo -e "Unmounting ..." 31 | guestunmount "$MOUNT_POINT" 32 | } 33 | trap cleanup EXIT 34 | 35 | echo "Replacing the Theme.HC file ..." 36 | cp "$SCRIPT_DIR/Theme.HC" "$MOUNT_POINT/Home/Theme.HC" 37 | 38 | HOMESYS="$MOUNT_POINT/Home/HomeSys.HC" 39 | if grep -q '#include "~/Theme.HC"' "$HOMESYS"; then 40 | echo -e "Theme.HC is already included in HomeSys.HC." 41 | else 42 | echo -e "Theme.HC is NOT included in HomeSys.HC." 43 | echo -e "You should add this line to it manually:" 44 | echo '#include "~/Theme.HC"' 45 | fi 46 | 47 | echo -e "Done. You may now boot into TempleOS." 48 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TempleOs-pywal-colors 2 | 3 | A Python script that generates a `Theme.HC` ([HolyC](https://holyc-lang.com/)) file, based on the generated [pywal](https://github.com/eylles/pywal16) colors, that can be used in [TempleOS](https://templeos.org/), so that it matches your desktop's colors/aesthetics. 4 | 5 | ## Examples 6 | 7 | ![examples](img/examples.gif) 8 | 9 | ### Dark and Light themes 10 | 11 | | ![darktheme](img/11.png) | ![lighttheme](img/11_white.png) | 12 | |----------------------------|----------------------------------| 13 | 14 | ## Usage 15 | 16 | After installing and running pywal (`wal -i /path/to/img`), run the python script: 17 | 18 | ```bash 19 | python3 generate_theme.py [--mode dark|light] 20 | ``` 21 | 22 | You can specify the mode to generate a dark or light theme. If no mode is specified, it will default to dark. The script will generate a `Theme.HC` file in the current directory, which you can then load in TempleOS. 23 | 24 | ### Loading the Theme in TempleOS 25 | 26 | To load the theme in TempleOS, you must: 27 | - Mount the C drive partition of your TempleOS installation. 28 | - Copy the `Theme.HC` file to the `C:/Home/` directory. 29 | - Make this theme load on boot, by adding the line `#include "~/Theme.HC"` into your `C:/Home/HomeSys.HC` file. (Optional) 30 | 31 | All of this loading process can be automated by running the `update.sh` script: 32 | 33 | ```bash 34 | ./update.sh 35 | ``` 36 | 37 | Be sure to replace `` with the path to your TempleOS image file and `` with the directory where you want to mount the image. 38 | 39 | And just as a warning, this process may vary depending on your TempleOs installation and virtualization method, so, please, **be sure to read the `update.sh` before running it** and adapt it to your needs. 40 | -------------------------------------------------------------------------------- /generate_theme.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | """ 3 | generate_theme.py 4 | Reads Pywal colors from ~/.cache/wal/colors and generate a Theme.HC file for TempleOS. 5 | palette with 48-bit CBGR color values. 6 | Usage: 7 | python3 update_theme.py [--mode dark|light] 8 | Default mode is 'dark'. In 'light' mode, the BLACK and WHITE colors are swapped. 9 | """ 10 | import os 11 | import argparse 12 | from pathlib import Path 13 | 14 | # Constants 15 | WAL_COLORS_PATH = Path.home() / ".cache/wal/colors" 16 | THEME_FILE_PATH = "Theme.HC" 17 | HEADER_COMMENT = "// This file was auto-generated by generate_theme.py using Pywal colors.\n" \ 18 | "// https://github.com/duartebranco/TempleOs-pywal-colors\n" 19 | 20 | # TempleOS color names mapping 21 | COLOR_NAMES = [ 22 | "BLACK", "BLUE", "GREEN", "CYAN", "RED", "PURPLE", "BROWN", "LTGRAY", 23 | "DKGRAY", "LTBLUE", "LTGREEN", "LTCYAN", "LTRED", "LTPURPLE", "YELLOW", "WHITE" 24 | ] 25 | 26 | def rgb8_to_rgb16(value8): 27 | return value8 * 257 # 0x101 28 | 29 | def hex_to_rgb(hex_color): 30 | hex_color = hex_color.strip().lstrip('#') 31 | return tuple(int(hex_color[i:i+2], 16) for i in (0, 2, 4)) 32 | 33 | def rgb_to_cbgr48(r, g, b): 34 | r16 = rgb8_to_rgb16(r) 35 | g16 = rgb8_to_rgb16(g) 36 | b16 = rgb8_to_rgb16(b) 37 | return (b16 << 0) | (g16 << 16) | (r16 << 32) 38 | 39 | def read_pywal_colors(path): 40 | if not path.exists(): 41 | raise FileNotFoundError(f"Colors file not found: {path}") 42 | with open(path) as f: 43 | lines = [line.strip() for line in f if line.strip()] 44 | if len(lines) != 16: 45 | raise ValueError("Expected 16 colors in the Pywal colors file.") 46 | return lines 47 | 48 | def convert_colors_to_cbgr48(hex_colors): 49 | cbgr_values = [] 50 | for i, color in enumerate(hex_colors): 51 | r, g, b = hex_to_rgb(color) 52 | value = rgb_to_cbgr48(r, g, b) 53 | comma = "," if i < len(hex_colors) - 1 else "" 54 | cbgr_values.append(f" 0x{value:012x}{comma} // {COLOR_NAMES[i]}") 55 | return cbgr_values 56 | 57 | def apply_mode_swap(colors, mode): 58 | if mode == "dark": 59 | colors[0], colors[15] = colors[15], colors[0] 60 | return colors 61 | 62 | def generate_theme_file(cbgr_palette): 63 | return ( 64 | HEADER_COMMENT + 65 | "public CBGR48 gr_palette_pywal[COLORS_NUM]={\n" + 66 | "\n".join(cbgr_palette) + "\n};\n\n" + 67 | "GrPaletteSet(gr_palette_pywal);\n\n" 68 | ) 69 | 70 | def write_theme_file(theme_path, content): 71 | with open(theme_path, "w") as f: 72 | f.write(content) 73 | print(f"Updated: {theme_path}") 74 | 75 | def parse_args(): 76 | parser = argparse.ArgumentParser(description="Generate Theme.HC from Pywal colors") 77 | parser.add_argument('--mode', choices=['dark', 'light'], default='dark', 78 | help="Color mode: 'dark' (swaps BLACK and WHITE) or 'light' (default)") 79 | return parser.parse_args() 80 | 81 | def main(): 82 | args = parse_args() 83 | hex_colors = read_pywal_colors(WAL_COLORS_PATH) 84 | hex_colors = apply_mode_swap(hex_colors, args.mode) 85 | cbgr_palette = convert_colors_to_cbgr48(hex_colors) 86 | theme_content = generate_theme_file(cbgr_palette) 87 | write_theme_file(THEME_FILE_PATH, theme_content) 88 | 89 | if __name__ == "__main__": 90 | main() 91 | --------------------------------------------------------------------------------