41 Commits

Author SHA1 Message Date
8d73df8fb8 publish releases 2025-12-15 13:08:53 +03:00
c4bab31e3b added write permission for release step 2025-12-15 12:30:24 +03:00
8e65c52adc use ncipollo/release-action 2025-12-15 12:20:15 +03:00
164e6f9ac0 ci: do not use matrix 2025-12-15 12:10:49 +03:00
d951f8d9c8 ci: merged windows and linux builds 2025-12-15 12:03:13 +03:00
794193209b typo 2025-12-15 11:52:43 +03:00
2a10aa0226 ci: removed install cmake step for windows 2025-12-15 11:49:17 +03:00
8caddbbb80 ci: removed extra build for windows 2025-12-15 11:43:52 +03:00
c1474ccf0c ci: build only NSIS for windows 2025-12-15 11:39:44 +03:00
db4cc383d4 ci: test windows installer 2025-12-15 11:31:30 +03:00
52a4b096a5 updated readme 2025-12-15 11:11:22 +03:00
1e2c7faa38 cleaned up module and added package with overlay 2025-12-15 11:09:14 +03:00
cc4d8f9dbd updated readme 2025-12-15 01:19:07 +03:00
ad92d366b2 try to set default package 2025-12-15 00:24:26 +03:00
e44d441453 Merge branch 'master' of github.com:obsqrbtz/clrsync 2025-12-14 23:47:09 +03:00
bb1c14d566 fixed typo 2025-12-14 23:47:04 +03:00
2714ae51b7 Update README.md 2025-12-13 03:11:18 +03:00
881bc6e739 Update README.md 2025-12-13 03:03:18 +03:00
65e54f9c0b docs: added nixos instructions 2025-12-13 02:43:08 +03:00
2c452cb395 added home manager module 2025-12-13 02:25:14 +03:00
2a81fa7b1b updated flake 2025-12-12 14:06:33 +03:00
cf8c93e31b ci: set latest nix action ver 2025-12-09 16:36:01 +03:00
8770dbcef8 typo 2025-12-09 16:33:50 +03:00
236f948fcf ci: added flake test 2025-12-09 16:31:22 +03:00
3350c41ccc use sekf as source 2025-12-09 15:56:42 +03:00
44a34eb216 fix: do not copy whole dirs (doesnt work on nix-store) 2025-12-09 15:46:17 +03:00
7535bb51ce split cmakelists 2025-12-09 15:03:46 +03:00
4c135edc95 build: link freerype with imgui isstead of clrsync_gui 2025-12-09 14:47:31 +03:00
813396920c ci: add libxkbcommon-dev for ubuntu 2025-12-09 14:22:07 +03:00
0cee625e8b statically link glwf on windows and ubuntu 2025-12-09 14:17:30 +03:00
dfbcdb6e1c build: updated pkgbuild depends 2025-12-09 13:32:38 +03:00
23a6a9245d build: use glfw3.4 2025-12-09 13:04:51 +03:00
93ab7bef81 ci: added wayland packages to rpm test 2025-12-09 11:54:17 +03:00
792aed7439 build: add flake.nix and wayland deps (untested) 2025-12-09 11:48:40 +03:00
38318f0205 docs: update readme 2025-12-09 01:48:22 +03:00
8a9695f3b8 ci: add sudo to deb workflow 2025-12-09 01:25:41 +03:00
dd38d08914 ci: add rpm and deb build tests 2025-12-09 01:22:27 +03:00
f55d224fab ci: add pkgbuild-git tester 2025-12-09 00:55:21 +03:00
931277291b updated gitignore 2025-12-09 00:30:09 +03:00
d8baae2ae9 build: moved pkgbuilds to AUR dir 2025-12-09 00:26:28 +03:00
5dafb6ce8c build: set deb arch 2025-12-09 00:17:50 +03:00
31 changed files with 1352 additions and 345 deletions

1
.envrc Normal file
View File

@@ -0,0 +1 @@
use flake .

45
.github/workflows/Test PKGBUILD-git.yml vendored Normal file
View File

@@ -0,0 +1,45 @@
name: Test PKGBUILD-git
on:
push:
branch: master
pull_request:
branches: master
jobs:
build:
runs-on: ubuntu-latest
container: archlinux:latest
steps:
- name: Setup Arch
run: |
pacman -Sy --noconfirm --needed base-devel git sudo
useradd -m builder
echo "builder ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set permissions
run: chown -R builder:builder .
- name: Build
run: |
sudo -u builder bash -c '
cd AUR
makepkg -p PKGBUILD-git -si --noconfirm
'
- name: Test
run: |
clrsync_cli --help
pacman -Ql clrsync-git
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: clrsync-git
path: AUR/*.pkg.tar.zst

32
.github/workflows/Test flake.yml vendored Normal file
View File

@@ -0,0 +1,32 @@
name: Test flake.nix
on:
push:
branches: [master]
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Nix
uses: cachix/install-nix-action@v31
with:
extra_nix_config: |
experimental-features = nix-command flakes
- name: Build clrsync package
run: |
nix --extra-experimental-features "flakes nix-command" build .#packages.x86_64-linux.clrsync
- name: Enter devShell
run: |
nix --extra-experimental-features "flakes nix-command" develop .#default --command true
- name: Test clrsync CLI
run: |
nix --extra-experimental-features "flakes nix-command" run .#clrsync-cli -- --help

139
.github/workflows/publish-release.yml vendored Normal file
View File

@@ -0,0 +1,139 @@
name: Build and Release Packages
on:
push:
tags:
- 'v*'
jobs:
build-windows:
runs-on: windows-latest
outputs:
artifact-path: ${{ steps.upload.outputs.artifact-path }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install NSIS
run: choco install nsis --no-progress -y
- name: Setup MSVC
uses: microsoft/setup-msbuild@v2
- name: Configure project
run: cmake -B build -S . -A x64
- name: Build project
run: cmake --build build --config Release
- name: Generate NSIS installer
run: cd build && cpack -G NSIS
- name: Upload installer
id: upload
uses: actions/upload-artifact@v6
with:
name: windows-installer
path: build/*.exe
build-ubuntu:
runs-on: ubuntu-latest
outputs:
artifact-path: ${{ steps.upload.outputs.artifact-path }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake build-essential git \
libglfw3-dev libfreetype6-dev libfontconfig1-dev \
libx11-dev libxrandr-dev libxi-dev \
mesa-common-dev libgl1-mesa-dev libglu1-mesa-dev \
libxinerama-dev libxcursor-dev libxkbcommon-dev
- name: Configure CMake
run: cmake -B build -DCMAKE_BUILD_TYPE=Release -DUSE_SYSTEM_GLFW=OFF
- name: Build
run: cmake --build build --config Release
- name: Package DEB
run: cd build && cpack -G DEB
- name: Upload DEB
id: upload
uses: actions/upload-artifact@v6
with:
name: deb-package
path: build/*.deb
build-fedora:
runs-on: ubuntu-latest
container:
image: fedora:latest
outputs:
artifact-path: ${{ steps.upload.outputs.artifact-path }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install dependencies
run: |
dnf install -y cmake gcc gcc-c++ make rpm-build git \
glfw-devel freetype-devel fontconfig-devel \
libX11-devel libXrandr-devel libXi-devel \
mesa-libGL-devel mesa-libGLU-devel \
libXinerama-devel libXcursor-devel \
wayland-devel wayland-protocols-devel
- name: Configure CMake
run: cmake -B build -DCMAKE_BUILD_TYPE=Release -DUSE_SYSTEM_GLFW=ON
- name: Build
run: cmake --build build --config Release
- name: Package RPM
run: cd build && cpack -G RPM
- name: Upload RPM
id: upload
uses: actions/upload-artifact@v6
with:
name: rpm-package
path: build/*.rpm
release:
needs: [build-windows, build-ubuntu, build-fedora]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download Windows artifact
uses: actions/download-artifact@v6
with:
name: windows-installer
path: artifacts/
- name: Download DEB artifact
uses: actions/download-artifact@v6
with:
name: deb-package
path: artifacts/
- name: Download RPM artifact
uses: actions/download-artifact@v6
with:
name: rpm-package
path: artifacts/
- name: Create Release and Upload Assets
uses: ncipollo/release-action@v1
with:
tag: ${{ github.ref_name }}
name: Release ${{ github.ref_name }}
artifacts: |
artifacts/*.exe
artifacts/*.deb
artifacts/*.rpm

25
.gitignore vendored
View File

@@ -3,8 +3,20 @@
.vs
out
/build
/build-*
build/
CMakeCache.txt
CMakeFiles/
cmake_install.cmake
Makefile
*.cmake
AUR/clrsync-git
AUR/pkg
AUR/src
result
result-*
.direnv/
*.log
*tar.zst
@@ -14,3 +26,12 @@ out
*.bak
*.tmp
.DS_Store
*.swp
*.swo
*~
*.o
*.a
*.so
*.dylib

View File

@@ -1,24 +1,33 @@
# Maintainer: Daniel Dada <dan@binarygoose.dev>
pkgname=clrsync
pkgver=0.1.3
pkgver=0.1.4
pkgrel=1
pkgdesc="Color scheme manager"
arch=('x86_64')
url="https://github.com/obsqrbtz/clrsync"
license=('MIT')
depends=(
glfw-x11
glfw
freetype2
fontconfig
mesa
libglvnd
libxcursor
)
makedepends=(
cmake
glfw
libx11
libxrandr
libxi
mesa
libglvnd
libxinerama
libxcursor
wayland
wayland-protocols
)
makedepends=('cmake')
source=("$pkgname-$pkgver.tar.gz::https://github.com/obsqrbtz/clrsync/archive/refs/tags/v$pkgver.tar.gz")
sha256sums=('SKIP')
@@ -26,6 +35,7 @@ build() {
cd "$pkgname-$pkgver"
cmake -B build -S . \
-DCMAKE_BUILD_TYPE=Release \
-DUSE_SYSTEM_GLFW=ON \
-DCMAKE_INSTALL_PREFIX=/usr
cmake --build build
}
@@ -33,5 +43,5 @@ build() {
package() {
cd "$pkgname-$pkgver"
DESTDIR="$pkgdir" cmake --install build
install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
install -Dm644 LICENSE.txt "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}

53
AUR/PKGBUILD-git Normal file
View File

@@ -0,0 +1,53 @@
# Maintainer: Daniel Dada <dan@binarygoose.dev>
pkgname=clrsync-git
pkgver=r22.d8baae2
pkgrel=1
pkgdesc="Color scheme manager (git version)"
arch=('x86_64')
url="https://github.com/obsqrbtz/clrsync"
license=('MIT')
depends=(
glfw
freetype2
fontconfig
mesa
libglvnd
libxcursor
)
makedepends=(
cmake
git
glfw
libx11
libxrandr
libxi
libxinerama
libxcursor
wayland
wayland-protocols
)
provides=('clrsync')
conflicts=('clrsync')
source=("$pkgname::git+https://github.com/obsqrbtz/clrsync.git")
sha256sums=('SKIP')
pkgver() {
cd "$srcdir/$pkgname"
printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}
build() {
cd "$srcdir/$pkgname"
cmake -B build -S . \
-DCMAKE_BUILD_TYPE=Release \
-DUSE_SYSTEM_GLFW=ON \
-DCMAKE_INSTALL_PREFIX=/usr
cmake --build build
}
package() {
cd "$srcdir/$pkgname"
DESTDIR="$pkgdir" cmake --install build
install -Dm644 LICENSE.txt "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}

View File

@@ -6,19 +6,28 @@ pkgdesc="Color scheme manager"
arch=('x86_64')
url="https://github.com/obsqrbtz/clrsync"
license=('MIT')
depends=(
glfw-x11
glfw
freetype2
fontconfig
mesa
libglvnd
libxcursor
)
makedepends=(
cmake
glfw
libx11
libxrandr
libxi
mesa
libglvnd
libxinerama
libxcursor
wayland
wayland-protocols
)
makedepends=('cmake')
source=("$pkgname-$pkgver.tar.gz::https://github.com/obsqrbtz/clrsync/archive/refs/tags/v$pkgver.tar.gz")
sha256sums=('SKIP')
@@ -26,6 +35,7 @@ build() {
cd "$pkgname-$pkgver"
cmake -B build -S . \
-DCMAKE_BUILD_TYPE=Release \
-DUSE_SYSTEM_GLFW=ON \
-DCMAKE_INSTALL_PREFIX=/usr
cmake --build build
}
@@ -33,5 +43,5 @@ build() {
package() {
cd "$pkgname-$pkgver"
DESTDIR="$pkgdir" cmake --install build
install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
install -Dm644 LICENSE.txt "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}

View File

@@ -1,11 +1,18 @@
cmake_minimum_required(VERSION 3.25)
project(clrsync VERSION 0.1.3 LANGUAGES CXX)
project(clrsync VERSION 0.1.4 LANGUAGES CXX)
include(GNUInstallDirs)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
option(USE_SYSTEM_GLFW "Use system-installed GLFW instead of fetching it statically" OFF)
message(STATUS "USE_SYSTEM_GLFW: ${USE_SYSTEM_GLFW}")
if(WIN32)
set(CMAKE_INSTALL_PREFIX "C:/Program Files/clrsync")
set(CMAKE_INSTALL_BINDIR "bin")
@@ -26,195 +33,24 @@ configure_file(
)
configure_file(
${CMAKE_SOURCE_DIR}/PKGBUILD.in
${CMAKE_SOURCE_DIR}/PKGBUILD
${CMAKE_SOURCE_DIR}/AUR/PKGBUILD.in
${CMAKE_SOURCE_DIR}/AUR/PKGBUILD
@ONLY
)
find_package(OpenGL REQUIRED)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
include(Dependencies)
include(ImGui)
if(WIN32)
include(FetchContent)
FetchContent_Declare(
freetype
URL https://download.savannah.gnu.org/releases/freetype/freetype-2.14.1.tar.gz
)
FetchContent_MakeAvailable(freetype)
add_subdirectory(src/core)
add_subdirectory(src/cli)
add_subdirectory(src/gui)
FetchContent_Declare(
glfw
GIT_REPOSITORY https://github.com/glfw/glfw.git
GIT_TAG 3.3.10
)
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(glfw)
else()
find_package(Freetype REQUIRED)
find_package(PkgConfig REQUIRED)
find_package(Fontconfig REQUIRED)
pkg_check_modules(GLFW REQUIRED glfw3)
endif()
set(CORE_SOURCES
src/core/palette/color.cpp
src/core/io/toml_file.cpp
src/core/config/config.cpp
src/core/utils.cpp
src/core/version.cpp
src/core/theme/theme_template.cpp
)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
add_library(clrsync_core SHARED ${CORE_SOURCES})
target_include_directories(clrsync_core PUBLIC src SYSTEM lib)
target_compile_definitions(clrsync_core PUBLIC
CLRSYNC_DATADIR=\"${CMAKE_INSTALL_FULL_DATADIR}/clrsync\"
)
add_executable(clrsync_cli src/cli/main.cpp)
target_include_directories(clrsync_cli PRIVATE src SYSTEM lib)
target_link_libraries(clrsync_cli PRIVATE clrsync_core)
set(GUI_SOURCES
src/gui/main.cpp
src/gui/color_scheme_editor.cpp
src/gui/template_editor.cpp
src/gui/palette_controller.cpp
src/gui/template_controller.cpp
lib/color_text_edit/TextEditor.cpp
src/gui/imgui_helpers.cpp
src/gui/imgui_helpers.hpp
src/gui/about_window.cpp
src/gui/settings_window.cpp
src/gui/font_loader.cpp
)
add_executable(clrsync_gui ${GUI_SOURCES})
target_include_directories(clrsync_gui PRIVATE src SYSTEM lib)
# if(WIN32)
# set_target_properties(clrsync_gui PROPERTIES
# LINK_FLAGS "/SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup"
# )
# endif()
if(WIN32)
target_link_libraries(clrsync_gui PRIVATE clrsync_core glfw freetype imgui OpenGL::GL)
else()
target_include_directories(clrsync_gui PRIVATE ${FREETYPE_INCLUDE_DIRS} ${GLFW_INCLUDE_DIRS})
target_link_libraries(clrsync_gui PRIVATE clrsync_core imgui ${FREETYPE_LIBRARIES} ${GLFW_LIBRARIES} X11 Xrandr Xi Fontconfig::Fontconfig OpenGL::GL)
endif()
set(imgui_SOURCE_DIR lib/imgui)
add_library(imgui STATIC
${imgui_SOURCE_DIR}/imgui.cpp
${imgui_SOURCE_DIR}/imgui_draw.cpp
${imgui_SOURCE_DIR}/imgui_widgets.cpp
${imgui_SOURCE_DIR}/imgui_tables.cpp
${imgui_SOURCE_DIR}/backends/imgui_impl_glfw.cpp
${imgui_SOURCE_DIR}/backends/imgui_impl_opengl3.cpp
${imgui_SOURCE_DIR}/misc/freetype/imgui_freetype.cpp
)
target_include_directories(imgui PUBLIC SYSTEM
${imgui_SOURCE_DIR}
${imgui_SOURCE_DIR}/backends
)
if(WIN32)
target_include_directories(imgui PUBLIC ${GLFW_INCLUDE_DIRS} ${freetype_SOURCE_DIR}/include)
else()
target_include_directories(imgui PUBLIC ${GLFW_INCLUDE_DIRS} ${FREETYPE_INCLUDE_DIRS})
endif()
target_link_libraries(imgui PUBLIC glfw OpenGL::GL freetype)
target_compile_definitions(imgui PUBLIC IMGUI_ENABLE_FREETYPE)
install(TARGETS clrsync_core
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT Core
)
install(TARGETS clrsync_cli
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT CLI
)
install(TARGETS clrsync_gui
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT GUI
)
install(FILES
example_config/config.toml
DESTINATION ${CMAKE_INSTALL_DATADIR}/clrsync
COMPONENT Core
)
install(DIRECTORY example_config/templates
DESTINATION ${CMAKE_INSTALL_DATADIR}/clrsync
COMPONENT Core
FILES_MATCHING PATTERN "*"
)
install(DIRECTORY example_config/palettes
DESTINATION ${CMAKE_INSTALL_DATADIR}/clrsync
COMPONENT Core
FILES_MATCHING PATTERN "*.toml"
)
if(UNIX AND NOT APPLE)
install(FILES resources/clrsync.desktop
DESTINATION ${CMAKE_INSTALL_DATADIR}/applications
COMPONENT Core
)
endif()
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE.txt")
set(CPACK_COMPONENTS_ALL Core GUI CLI)
set(CPACK_PACKAGE_NAME "clrsync")
set(CPACK_PACKAGE_VENDOR "Daniel Dada")
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Color scheme manager")
set(CPACK_COMPONENTS_ALL Core GUI CLI)
set(CPACK_COMPONENT_CORE_DISPLAY_NAME "Core Library")
set(CPACK_COMPONENT_CORE_DESCRIPTION "clrsync core library and default configs (required)")
set(CPACK_COMPONENT_CORE_REQUIRED ON)
set(CPACK_COMPONENT_GUI_DISPLAY_NAME "GUI Application")
set(CPACK_COMPONENT_GUI_DESCRIPTION "clrsync GUI app")
set(CPACK_COMPONENT_GUI_DEPENDS Core)
set(CPACK_COMPONENT_CLI_DISPLAY_NAME "Command Line Tool")
set(CPACK_COMPONENT_CLI_DESCRIPTION "clrsync CLI app")
set(CPACK_COMPONENT_CLI_DEPENDS Core)
set(CPACK_GENERATOR "NSIS;DEB;RPM")
set(CPACK_NSIS_INSTALLED_NAME "clrsync")
set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES64")
set(CPACK_NSIS_MODIFY_PATH ON)
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
set(CPACK_NSIS_MENU_LINKS "bin/clrsync_gui.exe" "clrsync")
set(CPACK_NSIS_CREATE_DESKTOP_LINKS "bin/clrsync_gui.exe;clrsync")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Daniel Dada <dan@binarygoose.dev>")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.31), libglfw3, libfreetype6")
set(CPACK_DEBIAN_PACKAGE_SECTION "utils")
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
set(CPACK_RPM_PACKAGE_LICENSE "MIT")
set(CPACK_RPM_PACKAGE_GROUP "Applications/System")
set(CPACK_RPM_PACKAGE_URL "https://github.com/obsqrbtz/clrsync")
set(CPACK_RPM_PACKAGE_REQUIRES "freetype, glfw, fontconfig")
include(Install)
include(Packaging)
message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
message(STATUS "CMAKE_INSTALL_FULL_DATADIR: ${CMAKE_INSTALL_FULL_DATADIR}")
include(CPack)
message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
message(STATUS "CMAKE_INSTALL_FULL_DATADIR: ${CMAKE_INSTALL_FULL_DATADIR}")

373
README.md
View File

@@ -1,56 +1,236 @@
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Nix Flake](https://img.shields.io/badge/Nix-Flake-blue.svg)](https://nixos.wiki/wiki/Flakes)
# clrsync
A theme management tool for synchronizing color schemes across multiple applications. clrsync allows you to define color palettes once and apply them consistently to all your terminal emulators, editors, and other configurable applications.
**Notice:** This application is not yet released and is subject to change.
Deb, RPM, and AUR packages, as well as a Windows installer, will be available soon.
A theme management tool for synchronizing color schemes across multiple applications. clrsync allows to define color palettes once and apply them consistently to all configurable applications.
![Preview](assets/screenshot.png)
## Table of Contents
- [Features](#features)
- [Installation](#installation)
- [NixOS](#nixos)
- [Home Manager Module](#home-manager-module)
- [Package](#package)
- [Install to profile](#install-to-profile)
- [Run without installing](#run-without-installing)
- [Other systems](#other-systems)
- [Building](#building)
- [Prerequisites](#prerequisites)
- [With CMake](#with-cmake)
- [Configuration](#configuration)
- [Palette Files](#palette-files)
- [Template Files](#template-files)
- [Color Format Specifiers](#color-format-specifiers)
- [Usage](#usage)
- [CLI](#cli)
- [GUI](#gui)
- [Acknowledgments](#acknowledgments)
## Features
- **Unified Color Management**: Define color palettes in TOML format and apply them across multiple applications
- **CLI & GUI**: Choose between a command-line interface or a graphical editor
- **Live Reload**: Define post-apply hooks (configurable per template)
- **Flexible Color Formats**: Support for HEX, RGB, HSL with multi-component access (e.g., `{color.r}`, `{color.hex}`, `{color.hsl}`)
- **Pre-built Themes**: Includes popular themes
## Installation
### NixOS
<details>
<summary>Home Manager Module</summary>
1. Add clrsync to your flake inputs
```nix
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
home-manager.url = "github:nix-community/home-manager";
clrsync.url = "github:obsqrbtz/clrsync";
};
}
```
2. Add clrsync to flake outputs
```nix
outputs =
{
self,
nixpkgs,
home-manager,
clrsync,
...
}@inputs:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
in
{
# ...
homeConfigurations.<Your user name> = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
extraSpecialArgs = { inherit inputs; };
modules = [
./home.nix
clrsync.homeModules.default
];
};
};
```
3. Configure in home manager
```nix
programs.clrsync = {
package = inputs.clrsync.packages.x86_64-linux.default;
defaultTheme = "dark";
palettesPath = "~/.config/clrsync/palettes";
font = "JetBrainsMono Nerd Font Mono";
fontSize = 14;
applyTheme = true;
templates = {
kitty = {
enabled = true;
inputPath = "~/.config/clrsync/templates/kitty.conf";
outputPath = "~/.config/kitty/clrsync.conf";
reloadCmd = "pkill -SIGUSR1 kitty";
};
rofi = {
enabled = true;
inputPath = "~/.config/clrsync/templates/rofi.rasi";
outputPath = "~/.config/rofi/clrsync.rasi";
};
};
};
```
4. Rebuild
```nix
home-manager switch --flake .
```
</details>
<details>
<summary>Package</summary>
1. Add clrsync to your flake inputs
```nix
{
inputs = {
clrsync.url = "github:obsqrbtz/clrsync";
};
}
```
2. Install the package
```nix
# In NixOS configuration.nix:
nixpkgs.overlays = [
inputs.clrsync.overlays.default
];
environment.systemPackages = [
clrsync
];
```
Or for home manager:
```nix
# flake.nix
pkgs = import nixpkgs {
inherit system;
overlays = [
clrsync.overlays.default
];
};
```
```nix
# home.nix
home.packages = [
clrsync
];
```
3. Use the app manually
```shell
clrsync_gui
# or
clrsync_cli --apply --theme dark
```
</details>
<details>
<summary>Install to profile</summary>
```shell
nix profile add github:obsqrbtz/clrsync
```
</details>
<details>
<summary>Run without installing</summary>
```shell
nix run github:obsqrbtz/clrsync
nix run github:obsqrbtz/clrsync#clrsync-cli
```
</details>
### Other systems
Follow the steps from Building section then install with cmake:
```bash
cd build
cmake --install .
```
## Building
### Prerequisites
- C++20 compatible compiler (GCC, Clang, or MSVC)
- CMake or Meson
- CMake
- OpenGL
- glfw
- fontconfig
- freetype
### Using CMake
### With CMake
```bash
mkdir build && cd build
cmake ..
cmake --build .
```
### Using Meson
```bash
meson setup builddir
meson compile -C builddir
```
## Installation
After building, you'll have:
- `clrsync_cli` - CLI
- `clrsync_gui` - GUI
- `libclrsync_core` - Shared lib
## Configuration
Create a configuration file at `~/.config/clrsync/config.toml`:
Edit or create a configuration file at `~/.config/clrsync/config.toml`:
```toml
[general]
palettes_path = "~/.config/clrsync/palettes"
default_theme = "dark"
default_theme = "cursed"
[templates.kitty]
input_path = "~/.config/clrsync/templates/kitty.conf"
@@ -61,79 +241,109 @@ reload_cmd = "pkill -SIGUSR1 kitty"
### Palette Files
Create palette files in your `palettes_path` directory:
<details>
<summary>Example palette file</summary>
Create palette files in your `palettes_path` directory:
```toml
# ~/.config/clrsync/palettes/dark.toml
[general]
name = "dark"
name = 'cursed'
[colors]
background = "#111318FF"
surface = "#1E1F25FF"
surface_variant = "#282A2FFF"
foreground = "#E2E2E9FF"
foreground_secondary = "#A8ABB3FF"
accent = "#00AA56FF"
outline = "#44474FFF"
shadow = "#00000080"
cursor = "#FFFFFFFF"
error = "#FF5F5FFF"
warning = "#FFC966FF"
success = "#6AD68BFF"
info = "#5DB2FFFF"
term_black = "#111318FF"
term_red = "#FF5F5FFF"
term_green = "#00AA56FF"
term_yellow = "#FFC966FF"
term_blue = "#5DB2FFFF"
term_magenta = "#DEBCDFFF"
term_cyan = "#86C9FFFF"
term_white = "#E2E2E9FF"
term_black_bright = "#33353AFF"
term_red_bright = "#FFB780FF"
term_green_bright = "#00CC6AFF"
term_yellow_bright = "#FFD580FF"
term_blue_bright = "#86C9FFFF"
term_magenta_bright = "#F0D6F0FF"
term_cyan_bright = "#BFEFFFFF"
term_white_bright = "#FFFFFFFF"
accent = '#B44242FF'
background = '#151515FF'
base00 = '#151515FF'
base01 = '#B44242FF'
base02 = '#95A328FF'
base03 = '#E1C135FF'
base04 = '#60928FFF'
base05 = '#7C435AFF'
base06 = '#A48B4AFF'
base07 = '#C2C2B0FF'
base08 = '#3F3639FF'
base09 = '#DC7671FF'
base0A = '#E8E85AFF'
base0B = '#9E9052FF'
base0C = '#76C39BFF'
base0D = '#86596CFF'
base0E = '#CEB34FFF'
base0F = '#B0AFA8FF'
border = '#3F3639FF'
border_focused = '#E1C135FF'
cursor = '#E1C135FF'
editor_background = '#151515FF'
editor_command = '#CEB34FFF'
editor_comment = '#3F3639FF'
editor_disabled = '#3F3639FF'
editor_emphasis = '#DC7671FF'
editor_error = '#B44242FF'
editor_inactive = '#3F3639FF'
editor_line_number = '#86596CFF'
editor_link = '#60928FFF'
editor_main = '#C2C2B0FF'
editor_selected = '#3F3639FF'
editor_selection_inactive = '#2A2A2AFF'
editor_string = '#76C39BFF'
editor_success = '#95A328FF'
editor_warning = '#E1C135FF'
error = '#B44242FF'
foreground = '#C2C2B0FF'
info = '#60928FFF'
on_background = '#C2C2B0FF'
on_error = '#151515FF'
on_info = '#151515FF'
on_success = '#151515FF'
on_surface = '#C2C2B0FF'
on_surface_variant = '#C2C2B0FF'
on_warning = '#151515FF'
success = '#95A328FF'
surface = '#1C1C1CFF'
surface_variant = '#1C1C1CFF'
warning = '#E1C135FF'
```
</details>
### Template Files
Create template files using color variables with flexible format specifiers:
<details>
<summary>Example template file</summary>
Create template files at `~/.config/clrsync/templates` using color variables:
```conf
# ~/.config/clrsync/templates/kitty.conf
cursor {foreground}
cursor {cursor}
cursor_text_color {background}
foreground {foreground}
background {background}
selection_foreground {foreground_secondary}
selection_foreground {on_surface}
selection_background {surface}
url_color {accent}
color0 {background}
color1 {term_red}
color2 {term_green}
color3 {term_yellow}
color4 {term_blue}
color5 {term_magenta}
color6 {term_cyan}
color7 {term_white}
color0 {base00}
color8 {base08}
color1 {base01}
color9 {base09}
color2 {base02}
color10 {base0A}
color3 {base03}
color11 {base0B}
color4 {base04}
color12 {base0C}
color5 {base05}
color13 {base0D}
color6 {base06}
color14 {base0E}
color7 {base07}
color15 {base0F}
```
#### Color Format Specifiers
</details>
Access color components using dot notation:
<details>
<summary>Color Format Specifiers</summary>
Format colors using dot notation:
```conf
# HEX formats
{color} # Default: #RRGGBB
@@ -163,42 +373,38 @@ Access color components using dot notation:
{color.a} # Alpha component
```
</details>
## Usage
### CLI
List available themes:
```bash
clrsync_cli --list-themes
```
Apply the default theme:
```bash
clrsync_cli --apply
```
Apply a specific theme:
```bash
clrsync_cli --apply --theme rose-pine
clrsync_cli --apply --theme cursed
```
Apply a theme from a file path:
```bash
clrsync_cli --apply --path /path/to/theme.toml
```
Show available color variables:
```bash
clrsync_cli --show-vars
```
Use a custom config file:
```bash
clrsync_cli --config /path/to/config.toml --apply
```
@@ -206,7 +412,6 @@ clrsync_cli --config /path/to/config.toml --apply
### GUI
Launch the graphical editor:
```bash
clrsync_gui
```
@@ -219,10 +424,10 @@ The GUI provides:
## Acknowledgments
This project uses the following open-source libraries:
- **[matugen](https://github.com/InioX/matugen)** - A material you color generation tool
- **[Dear ImGui](https://github.com/ocornut/imgui)** - Bloat-free graphical user interface library for C++
- **[GLFW](https://www.glfw.org/)** - Multi-platform library for OpenGL, OpenGL ES and Vulkan development
- **[toml++](https://github.com/marzer/tomlplusplus)** - Header-only TOML config file parser and serializer for C++17
- **[argparse](https://github.com/p-ranav/argparse)** - Argument Parser for Modern C++
- **[ImGuiColorTextEdit](https://github.com/BalazsJako/ImGuiColorTextEdit)** - Syntax highlighting text editor for ImGui
- **cursed** by **[pyratebeard](https://pyratebeard.net)** - Color scheme

67
cmake/Dependencies.cmake Normal file
View File

@@ -0,0 +1,67 @@
find_package(OpenGL REQUIRED)
if(WIN32)
include(FetchContent)
FetchContent_Declare(
freetype
URL https://download.savannah.gnu.org/releases/freetype/freetype-2.14.1.tar.gz
)
FetchContent_MakeAvailable(freetype)
else()
find_package(Freetype REQUIRED)
find_package(PkgConfig REQUIRED)
find_package(Fontconfig REQUIRED)
find_package(ZLIB REQUIRED)
find_package(BZip2 REQUIRED)
find_package(PNG REQUIRED)
find_library(BROTLIDEC_LIBRARY NAMES brotlidec)
find_library(BROTLICOMMON_LIBRARY NAMES brotlicommon)
pkg_check_modules(HARFBUZZ harfbuzz)
pkg_check_modules(WAYLAND_CLIENT wayland-client)
pkg_check_modules(WAYLAND_EGL wayland-egl)
endif()
if(USE_SYSTEM_GLFW)
pkg_check_modules(GLFW REQUIRED glfw3)
else()
include(FetchContent)
FetchContent_Declare(
glfw
GIT_REPOSITORY https://github.com/glfw/glfw.git
GIT_TAG 3.4
)
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
set(GLFW_INSTALL OFF CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(glfw)
set(GLFW_FOUND TRUE)
set(GLFW_INCLUDE_DIRS ${glfw_SOURCE_DIR}/include)
set(GLFW_LIBRARIES glfw)
endif()
set(FREETYPE_EXTRA_LIBS "")
if(BROTLIDEC_LIBRARY AND BROTLICOMMON_LIBRARY)
list(APPEND FREETYPE_EXTRA_LIBS ${BROTLIDEC_LIBRARY} ${BROTLICOMMON_LIBRARY})
message(STATUS "Found Brotli libraries")
endif()
if(HARFBUZZ_FOUND)
list(APPEND FREETYPE_EXTRA_LIBS ${HARFBUZZ_LIBRARIES})
message(STATUS "Found HarfBuzz")
endif()
set(WAYLAND_LIBS "")
if(WAYLAND_CLIENT_FOUND)
list(APPEND WAYLAND_LIBS ${WAYLAND_CLIENT_LIBRARIES})
message(STATUS "Found Wayland client")
endif()
if(WAYLAND_EGL_FOUND)
list(APPEND WAYLAND_LIBS ${WAYLAND_EGL_LIBRARIES})
message(STATUS "Found Wayland EGL")
endif()

32
cmake/ImGui.cmake Normal file
View File

@@ -0,0 +1,32 @@
set(IMGUI_SOURCE_DIR ${CMAKE_SOURCE_DIR}/lib/imgui)
add_library(imgui STATIC
${IMGUI_SOURCE_DIR}/imgui.cpp
${IMGUI_SOURCE_DIR}/imgui_draw.cpp
${IMGUI_SOURCE_DIR}/imgui_widgets.cpp
${IMGUI_SOURCE_DIR}/imgui_tables.cpp
${IMGUI_SOURCE_DIR}/backends/imgui_impl_glfw.cpp
${IMGUI_SOURCE_DIR}/backends/imgui_impl_opengl3.cpp
${IMGUI_SOURCE_DIR}/misc/freetype/imgui_freetype.cpp
)
target_include_directories(imgui PUBLIC SYSTEM
${IMGUI_SOURCE_DIR}
${IMGUI_SOURCE_DIR}/backends
)
target_compile_definitions(imgui PUBLIC IMGUI_ENABLE_FREETYPE)
if(WIN32)
target_include_directories(imgui PUBLIC ${GLFW_INCLUDE_DIRS} ${freetype_SOURCE_DIR}/include)
target_link_libraries(imgui PUBLIC freetype)
else()
target_include_directories(imgui PUBLIC ${GLFW_INCLUDE_DIRS} ${FREETYPE_INCLUDE_DIRS})
target_link_libraries(imgui PRIVATE
Freetype::Freetype
${FREETYPE_EXTRA_LIBS}
ZLIB::ZLIB
BZip2::BZip2
PNG::PNG
)
endif()

39
cmake/Install.cmake Normal file
View File

@@ -0,0 +1,39 @@
install(TARGETS clrsync_core
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT Core
)
install(TARGETS clrsync_cli
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT CLI
)
install(TARGETS clrsync_gui
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT GUI
)
install(FILES example_config/config.toml
DESTINATION ${CMAKE_INSTALL_DATADIR}/clrsync
COMPONENT Core
)
install(DIRECTORY example_config/templates
DESTINATION ${CMAKE_INSTALL_DATADIR}/clrsync
COMPONENT Core
FILES_MATCHING PATTERN "*"
)
install(DIRECTORY example_config/palettes
DESTINATION ${CMAKE_INSTALL_DATADIR}/clrsync
COMPONENT Core
FILES_MATCHING PATTERN "*.toml"
)
if(UNIX AND NOT APPLE)
install(FILES resources/clrsync.desktop
DESTINATION ${CMAKE_INSTALL_DATADIR}/applications
COMPONENT Core
)
endif()

41
cmake/Packaging.cmake Normal file
View File

@@ -0,0 +1,41 @@
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE.txt")
set(CPACK_PACKAGE_NAME "clrsync")
set(CPACK_PACKAGE_VENDOR "Daniel Dada")
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Color scheme manager")
set(CPACK_GENERATOR "NSIS;DEB;RPM")
# Components
set(CPACK_COMPONENTS_ALL Core GUI CLI)
set(CPACK_COMPONENT_CORE_DISPLAY_NAME "Core Library")
set(CPACK_COMPONENT_CORE_DESCRIPTION "clrsync core library and default configs (required)")
set(CPACK_COMPONENT_CORE_REQUIRED ON)
set(CPACK_COMPONENT_GUI_DISPLAY_NAME "GUI Application")
set(CPACK_COMPONENT_GUI_DESCRIPTION "clrsync GUI app")
set(CPACK_COMPONENT_GUI_DEPENDS Core)
set(CPACK_COMPONENT_CLI_DISPLAY_NAME "Command Line Tool")
set(CPACK_COMPONENT_CLI_DESCRIPTION "clrsync CLI app")
set(CPACK_COMPONENT_CLI_DEPENDS Core)
# NSIS
set(CPACK_NSIS_INSTALLED_NAME "clrsync")
set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES64")
set(CPACK_NSIS_MODIFY_PATH ON)
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
set(CPACK_NSIS_MENU_LINKS "bin/clrsync_gui.exe" "clrsync")
set(CPACK_NSIS_CREATE_DESKTOP_LINKS "bin/clrsync_gui.exe;clrsync")
# Debian
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Daniel Dada <dan@binarygoose.dev>")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.31), libglfw3, libfreetype6")
set(CPACK_DEBIAN_PACKAGE_SECTION "utils")
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
# RPM
set(CPACK_RPM_PACKAGE_LICENSE "MIT")
set(CPACK_RPM_PACKAGE_GROUP "Applications/System")
set(CPACK_RPM_PACKAGE_URL "https://github.com/obsqrbtz/clrsync")
set(CPACK_RPM_PACKAGE_REQUIRES "freetype, glfw, fontconfig")
include(CPack)

View File

@@ -7,7 +7,7 @@ surface = "#e8e8e8FF"
on_surface = "#3d3d2fFF"
surface_variant = "#d0d0c8FF"
on_surface_varuant = "#3d3d2fFF"
on_surface_variant = "#3d3d2fFF"
border_focused = "#c9a305FF"
border = "#d0d0c8FF"

View File

@@ -43,7 +43,7 @@ on_error = '#151515FF'
on_info = '#151515FF'
on_success = '#151515FF'
on_surface = '#C2C2B0FF'
on_surface_varuant = '#C2C2B0FF'
on_surface_variant = '#C2C2B0FF'
on_warning = '#151515FF'
success = '#95A328FF'
surface = '#1C1C1CFF'

View File

@@ -7,34 +7,26 @@ selection_foreground {on_surface}
selection_background {surface}
url_color {accent}
# Base colors (dark variants)
color0 {base00}
color8 {base08}
# Red
color1 {base01}
color9 {base09}
# Green
color2 {base02}
color10 {base0A}
# Yellow
color3 {base03}
color11 {base0B}
# Blue
color4 {base04}
color12 {base0C}
# Magenta
color5 {base05}
color13 {base0D}
# Cyan
color6 {base06}
color14 {base0E}
# White
color7 {base07}
color15 {base0F}

27
flake.lock generated Normal file
View File

@@ -0,0 +1,27 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1764950072,
"narHash": "sha256-BmPWzogsG2GsXZtlT+MTcAWeDK5hkbGRZTeZNW42fwA=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "f61125a668a320878494449750330ca58b78c557",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

86
flake.nix Normal file
View File

@@ -0,0 +1,86 @@
{
description = "clrsync - Color scheme manager";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs =
{ self, nixpkgs, ... }:
let
supportedSystems = [
"x86_64-linux"
];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
in
{
packages = forAllSystems (
system:
let
pkgs = nixpkgsFor.${system};
in
rec {
clrsync = pkgs.callPackage ./package.nix { };
default = clrsync;
}
);
homeModules = {
default = import ./home-manager-module.nix self;
clrsync = self.homeModules.default;
};
apps = forAllSystems (system: {
clrsync-gui = {
type = "app";
program = "${self.packages.${system}.clrsync}/bin/clrsync_gui";
meta = {
description = "clrsync gui app";
license = self.packages.x86_64-linux.licenses.mit;
maintainers = [ "Daniel Dada" ];
};
};
clrsync-cli = {
type = "app";
program = "${self.packages.${system}.clrsync}/bin/clrsync_cli";
meta = {
description = "clrsync cli app";
license = self.packages.x86_64-linux.licenses.mit;
maintainers = [ "Daniel Dada" ];
};
};
default = self.apps.${system}.clrsync-cli;
});
devShells = forAllSystems (
system:
let
pkgs = nixpkgsFor.${system};
in
{
default = pkgs.mkShell {
inputsFrom = [ self.packages.${system}.clrsync ];
buildInputs = with pkgs; [
cmake
ninja
clang-tools
gdb
];
shellHook = ''
export CMAKE_GENERATOR="Ninja"
export CMAKE_EXPORT_COMPILE_COMMANDS=1
'';
};
}
);
overlays.default = final: prev: {
clrsync = self.packages.${final.system}.clrsync;
};
};
}

155
home-manager-module.nix Normal file
View File

@@ -0,0 +1,155 @@
flake:
{
config,
lib,
pkgs,
...
}:
with lib;
let
cfg = config.programs.clrsync;
clrsyncPackage = flake.packages.${pkgs.system}.default;
templateType = types.submodule {
options = {
enabled = mkOption {
type = types.bool;
default = true;
description = "Whether to enable this template.";
};
inputPath = mkOption {
type = types.str;
description = "Path to the template input file.";
};
outputPath = mkOption {
type = types.str;
description = "Path where the generated output will be written.";
};
reloadCmd = mkOption {
type = types.str;
default = "";
description = "Command to run after generating the output.";
};
};
};
configFormat = pkgs.formats.toml { };
configFile = configFormat.generate "config.toml" {
general = {
default_theme = cfg.defaultTheme;
palettes_path = cfg.palettesPath;
font = cfg.font;
font_size = cfg.fontSize;
};
templates = mapAttrs (
name: template: {
enabled = template.enabled;
input_path = template.inputPath;
output_path = template.outputPath;
reload_cmd = template.reloadCmd;
}
) cfg.templates;
};
in
{
options.programs.clrsync = {
enable = mkEnableOption "clrsync color synchronization";
defaultTheme = mkOption {
type = types.str;
default = "cursed";
description = "Default theme to use.";
};
palettesPath = mkOption {
type = types.str;
default = "~/.config/clrsync/palettes";
description = "Path to color palettes directory.";
};
font = mkOption {
type = types.str;
default = "JetBrainsMono Nerd Font Mono";
description = "Font family to use.";
};
fontSize = mkOption {
type = types.int;
default = 14;
description = "Font size.";
};
templates = mkOption {
type = types.attrsOf templateType;
default = { };
description = "Template configurations.";
example = literalExpression ''
{
kitty = {
enabled = true;
inputPath = "~/.config/clrsync/templates/kitty.conf";
outputPath = "~/.config/kitty/kitty_test.conf";
reloadCmd = "pkill -SIGUSR1 kitty";
};
}
'';
};
applyTheme = mkOption {
type = types.bool;
default = false;
description = "Whether to apply the default theme on activation.";
};
systemdTarget = mkOption {
type = types.str;
default = "graphical-session.target";
description = "Systemd target to bind the clrsync service to.";
};
};
config = mkIf cfg.enable {
home.packages = [ clrsyncPackage ];
xdg.enable = true;
home.activation.clrsyncDesktop = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
if [ -d "$HOME/.nix-profile/share/applications" ]; then
${pkgs.desktop-file-utils}/bin/update-desktop-database "$HOME/.nix-profile/share/applications" || true
fi
'';
xdg.configFile."clrsync/config.toml" = {
source = configFile;
force = true;
};
home.activation.clrsyncConfig = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
run --quiet mkdir -p $HOME/.config/clrsync
run --quiet cp -f ${configFile} $HOME/.config/clrsync/config.toml
'';
home.activation.clrsyncApply = mkIf cfg.applyTheme (
lib.hm.dag.entryAfter [ "clrsyncConfig" ] ''
run --quiet ${clrsyncPackage}/bin/clrsync_cli --apply --theme ${cfg.defaultTheme}
''
);
systemd.user.services.clrsync = mkIf cfg.applyTheme {
Unit = {
Description = "Apply clrsync color palette";
After = [ cfg.systemdTarget ];
PartOf = [ cfg.systemdTarget ];
};
Service = {
Type = "oneshot";
ExecStart = "${clrsyncPackage}/bin/clrsync_cli --apply --theme ${cfg.defaultTheme}";
RemainAfterExit = true;
};
Install = {
WantedBy = [ cfg.systemdTarget ];
};
};
};
}

97
package.nix Normal file
View File

@@ -0,0 +1,97 @@
{
lib,
stdenv,
cmake,
git,
pkg-config,
makeWrapper,
wayland-protocols,
glfw,
freetype,
fontconfig,
mesa,
xorg,
wayland,
libxkbcommon,
zlib,
bzip2,
wayland-scanner,
}:
stdenv.mkDerivation rec {
pname = "clrsync";
version = "unstable-2024-12-15";
src = lib.cleanSourceWith {
src = ./.;
filter =
path: type:
let
baseName = baseNameOf path;
in
!(
lib.hasSuffix ".o" baseName
|| lib.hasSuffix ".a" baseName
|| baseName == "build"
|| baseName == "CMakeCache.txt"
|| baseName == "CMakeFiles"
|| baseName == ".git"
|| baseName == "result"
|| baseName == ".direnv"
);
};
nativeBuildInputs = [
cmake
git
pkg-config
makeWrapper
wayland-protocols
];
buildInputs = [
glfw
freetype
fontconfig
xorg.libXcursor
mesa
xorg.libX11
xorg.libXrandr
xorg.libXi
xorg.libXinerama
wayland
wayland-scanner
wayland-protocols
libxkbcommon
zlib
bzip2
];
cmakeFlags = [
"-DCMAKE_BUILD_TYPE=Release"
"-DUSE_SYSTEM_GLFW=ON"
];
installPhase = ''
runHook preInstall
cmake --install . --prefix $out
wrapProgram $out/bin/clrsync_gui \
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath buildInputs}
wrapProgram $out/bin/clrsync_cli \
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath buildInputs}
runHook postInstall
'';
meta = with lib; {
description = "Color scheme manager with GUI and CLI";
homepage = "https://github.com/obsqrbtz/clrsync";
license = licenses.mit;
platforms = platforms.linux;
mainProgram = "clrsync_gui";
maintainers = [ ];
};
}

8
src/cli/CMakeLists.txt Normal file
View File

@@ -0,0 +1,8 @@
add_executable(clrsync_cli main.cpp)
target_include_directories(clrsync_cli PRIVATE
${CMAKE_SOURCE_DIR}/src
SYSTEM ${CMAKE_SOURCE_DIR}/lib
)
target_link_libraries(clrsync_cli PRIVATE clrsync_core)

View File

@@ -1,16 +1,16 @@
#include <iostream>
#include <cstdlib>
#include <iostream>
#include <string>
#include <argparse/argparse.hpp>
#include <core/utils.hpp>
#include <core/config/config.hpp>
#include <core/io/toml_file.hpp>
#include <core/palette/palette_file.hpp>
#include <core/palette/palette_manager.hpp>
#include <core/theme/theme_template.hpp>
#include <core/theme/theme_renderer.hpp>
#include <core/theme/theme_template.hpp>
#include <core/utils.hpp>
#include <core/version.hpp>
void handle_show_vars()
@@ -21,8 +21,7 @@ void handle_show_vars()
void handle_list_themes()
{
auto palette_manager = clrsync::core::palette_manager<clrsync::core::io::toml_file>();
palette_manager.load_palettes_from_directory(
clrsync::core::config::instance().palettes_path());
palette_manager.load_palettes_from_directory(clrsync::core::config::instance().palettes_path());
const auto &palettes = palette_manager.palettes();
std::cout << "Available themes:" << std::endl;
@@ -70,28 +69,20 @@ void initialize_config(const std::string &config_path)
void setup_argument_parser(argparse::ArgumentParser &program)
{
program.add_argument("-a", "--apply")
.help("applies default theme")
.flag();
program.add_argument("-a", "--apply").help("applies default theme").flag();
program.add_argument("-c", "--config")
.default_value(clrsync::core::get_default_config_path())
.help("sets config file path")
.metavar("PATH");
program.add_argument("-l", "--list-themes")
.help("lists available themes")
.flag();
program.add_argument("-l", "--list-themes").help("lists available themes").flag();
program.add_argument("-s", "--show-vars")
.help("shows color keys")
.flag();
program.add_argument("-s", "--show-vars").help("shows color keys").flag();
auto &group = program.add_mutually_exclusive_group();
group.add_argument("-t", "--theme")
.help("sets theme <theme_name> to apply");
group.add_argument("-p", "--path")
.help("sets theme file <path/to/theme> to apply");
group.add_argument("-t", "--theme").help("sets theme <theme_name> to apply");
group.add_argument("-p", "--path").help("sets theme file <path/to/theme> to apply");
}
int main(int argc, char *argv[])

21
src/core/CMakeLists.txt Normal file
View File

@@ -0,0 +1,21 @@
set(CORE_SOURCES
palette/color.cpp
io/toml_file.cpp
config/config.cpp
utils.cpp
version.cpp
theme/theme_template.cpp
)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
add_library(clrsync_core SHARED ${CORE_SOURCES})
target_include_directories(clrsync_core PUBLIC
${CMAKE_SOURCE_DIR}/src
SYSTEM ${CMAKE_SOURCE_DIR}/lib
)
target_compile_definitions(clrsync_core PUBLIC
CLRSYNC_DATADIR=\"${CMAKE_INSTALL_FULL_DATADIR}/clrsync\"
)

View File

@@ -3,6 +3,7 @@
#include <core/palette/color.hpp>
#include <filesystem>
#include <fstream>
#include <stdexcept>
#ifdef _WIN32
@@ -56,25 +57,66 @@ std::filesystem::path config::get_data_dir()
#endif
}
void config::copy_file(const std::filesystem::path &src, const std::filesystem::path &dst)
{
if (std::filesystem::exists(dst))
return;
std::ifstream in(src, std::ios::binary);
std::ofstream out(dst, std::ios::binary);
out << in.rdbuf();
}
void config::copy_dir(const std::filesystem::path &src, const std::filesystem::path &dst)
{
for (auto const &entry : std::filesystem::recursive_directory_iterator(src))
{
auto rel = std::filesystem::relative(entry.path(), src);
auto out = dst / rel;
if (entry.is_directory())
{
std::filesystem::create_directories(out);
}
else if (entry.is_regular_file())
{
copy_file(entry.path(), out);
}
}
}
void config::copy_default_configs()
{
std::filesystem::path user_config = get_user_config_dir();
std::filesystem::path default_dir = get_data_dir();
std::filesystem::path user_dir = get_user_config_dir();
std::filesystem::path system_dir = get_data_dir();
std::filesystem::create_directories(user_dir);
if (!std::filesystem::exists(user_config))
{
std::filesystem::create_directories(user_config);
std::filesystem::copy(default_dir / "config.toml", user_config / "config.toml");
std::filesystem::copy(default_dir / "templates", user_config / "templates",
std::filesystem::copy_options::recursive);
std::filesystem::copy(default_dir / "palettes", user_config / "palettes",
std::filesystem::copy_options::recursive);
return;
auto src = system_dir / "config.toml";
auto dst = user_dir / "config.toml";
if (!std::filesystem::exists(dst))
copy_file(src, dst);
}
if (!std::filesystem::exists(user_config / "config.toml"))
{
std::filesystem::copy(default_dir / "config.toml", user_config / "config.toml");
auto src = system_dir / "templates";
auto dst = user_dir / "templates";
if (!std::filesystem::exists(dst))
std::filesystem::create_directories(dst);
copy_dir(src, dst);
}
{
auto src = system_dir / "palettes";
auto dst = user_dir / "palettes";
if (!std::filesystem::exists(dst))
std::filesystem::create_directories(dst);
copy_dir(src, dst);
}
}

View File

@@ -42,6 +42,8 @@ class config
std::string m_palettes_dir{};
std::unique_ptr<io::file> m_file;
std::unordered_map<std::string, theme_template> m_themes{};
static void copy_file(const std::filesystem::path& src, const std::filesystem::path& dst);
static void copy_dir(const std::filesystem::path& src, const std::filesystem::path& dst);
void copy_default_configs();
};
} // namespace clrsync::core

View File

@@ -14,7 +14,7 @@ constexpr const char* COLOR_KEYS[] = {
"on_surface",
"surface_variant",
"on_surface_varuant",
"on_surface_variant",
"border_focused",
"border",

View File

@@ -9,7 +9,7 @@ namespace clrsync::core
constexpr uint8_t VERSION_MAJOR = 0;
constexpr uint8_t VERSION_MINOR = 1;
constexpr uint8_t VERSION_PATCH = 3;
constexpr uint8_t VERSION_PATCH = 4;
const std::string version_string();
} // namespace clrsync::core

41
src/gui/CMakeLists.txt Normal file
View File

@@ -0,0 +1,41 @@
set(GUI_SOURCES
main.cpp
color_scheme_editor.cpp
template_editor.cpp
palette_controller.cpp
template_controller.cpp
imgui_helpers.cpp
imgui_helpers.hpp
about_window.cpp
settings_window.cpp
font_loader.cpp
${CMAKE_SOURCE_DIR}/lib/color_text_edit/TextEditor.cpp
)
add_executable(clrsync_gui ${GUI_SOURCES})
target_include_directories(clrsync_gui PRIVATE
${CMAKE_SOURCE_DIR}/src
SYSTEM ${CMAKE_SOURCE_DIR}/lib
)
if(WIN32)
target_link_libraries(clrsync_gui PRIVATE
clrsync_core
glfw
imgui
OpenGL::GL
)
else()
target_link_libraries(clrsync_gui PRIVATE
clrsync_core
imgui
${GLFW_LIBRARIES}
${WAYLAND_LIBS}
X11
Xrandr
Xi
Fontconfig::Fontconfig
OpenGL::GL
)
endif()

View File

@@ -305,7 +305,7 @@ void color_scheme_editor::render_color_table()
};
draw_table("General UI", {"background", "on_background", "surface", "on_surface",
"surface_variant", "on_surface_varuant", "foreground",
"surface_variant", "on_surface_variant", "foreground",
"cursor", "accent"});
draw_table("Borders", {"border_focused", "border"});

View File

@@ -1,6 +1,8 @@
#include <memory>
#include <GLFW/glfw3.h>
#include <GLFW/glfw3native.h>
#include "core/config/config.hpp"
#include "core/io/toml_file.hpp"
@@ -27,6 +29,18 @@ int main(int, char**)
GLFWwindow* window = init_glfw();
if (!window) return 1;
printf("GLFV Version: %s\n", glfwGetVersionString());
std::cout << "GLFW runtime platform: ";
switch (glfwGetPlatform()) {
case GLFW_PLATFORM_WAYLAND: std::cout << "Wayland\n"; break;
case GLFW_PLATFORM_X11: std::cout << "X11\n"; break;
case GLFW_PLATFORM_COCOA: std::cout << "Cocoa\n"; break;
case GLFW_PLATFORM_WIN32: std::cout << "Win32\n"; break;
default: std::cout << "Unknown\n";
}
init_imgui(window, ini_path);
font_loader loader;