diff --git a/.gitignore b/.gitignore
index 88e59de..cb1c37e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,17 +3,20 @@
.vs
out
-/build
-/build-*
+build/
+CMakeCache.txt
+CMakeFiles/
+cmake_install.cmake
+Makefile
+*.cmake
-/AUR/clrsync-git
-/AUR/pkg
-/AUR/src
+AUR/clrsync-git
+AUR/pkg
+AUR/src
-/result
-/result-*
-
-/.direnv
+result
+result-*
+.direnv/
*.log
*tar.zst
@@ -22,4 +25,13 @@ out
*.swp
*.bak
*.tmp
-.DS_Store
\ No newline at end of file
+.DS_Store
+
+*.swp
+*.swo
+*~
+
+*.o
+*.a
+*.so
+*.dylib
\ No newline at end of file
diff --git a/README.md b/README.md
index 8ce48e9..2b17e73 100644
--- a/README.md
+++ b/README.md
@@ -10,19 +10,41 @@ A theme management tool for synchronizing color schemes across multiple applicat

+## 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
-#### Home Manager Module
+
+Home Manager Module
1. Add clrsync to your flake inputs
@@ -37,21 +59,38 @@ A theme management tool for synchronizing color schemes across multiple applicat
}
```
-2. Import the Home Manager module
-
-In home.nix:
+2. Add clrsync to flake outputs
```nix
- imports = [
- inputs.clrsync.homemanagermodules.default
- ];
+outputs =
+ {
+ self,
+ nixpkgs,
+ home-manager,
+ clrsync,
+ ...
+ }@inputs:
+ let
+ system = "x86_64-linux";
+ pkgs = nixpkgs.legacyPackages.${system};
+ in
+ {
+ # ...
+ homeConfigurations. = home-manager.lib.homeManagerConfiguration {
+ inherit pkgs;
+ extraSpecialArgs = { inherit inputs; };
+ modules = [
+ ./home.nix
+ clrsync.homeManagerModules.default
+ ];
+ };
+ };
```
3. Configure in home manager
```nix
programs.clrsync = {
- enable = true;
package = inputs.clrsync.packages.x86_64-linux.default;
defaultTheme = "dark";
palettesPath = "~/.config/clrsync/palettes";
@@ -75,13 +114,17 @@ programs.clrsync = {
};
};
```
+
4. Rebuild
```nix
home-manager switch --flake .
```
-#### Package (For non-declarative configurations)
+
+
+
+Package
1. Add clrsync to your flake inputs
@@ -97,13 +140,31 @@ home-manager switch --flake .
```nix
# In NixOS configuration.nix:
-environment.systemPackages = [
- inputs.clrsync.packages.x86_64-linux.default
+nixpkgs.overlays = [
+ inputs.clrsync.overlays.default
];
-# Or in Home Manager:
+environment.systemPackages = [
+ clrsync
+];
+```
+
+Or for home manager:
+
+```nix
+# flake.nix
+pkgs = import nixpkgs {
+ inherit system;
+ overlays = [
+ clrsync.overlays.default
+ ];
+};
+```
+
+```nix
+# home.nix
home.packages = [
- inputs.clrsync.packages.x86_64-linux.default
+ clrsync
];
```
@@ -116,10 +177,30 @@ clrsync_gui
clrsync_cli --apply --theme dark
```
+
+
+
+Install to profile
+
+```shell
+nix profile add github:obsqrbtz/clrsync
+```
+
+
+
+
+Run without installing
+
+```shell
+nix run github:obsqrbtz/clrsync
+nix run github:obsqrbtz/clrsync#clrsync-cli
+```
+
+
+
### Other systems
Follow the steps from Building section then install with cmake:
-
```bash
cd build
cmake --install .
@@ -137,7 +218,6 @@ cmake --install .
- freetype
### With CMake
-
```bash
mkdir build && cd build
cmake ..
@@ -147,7 +227,6 @@ cmake --build .
## Configuration
Edit or create a configuration file at `~/.config/clrsync/config.toml`:
-
```toml
[general]
palettes_path = "~/.config/clrsync/palettes"
@@ -162,8 +241,10 @@ reload_cmd = "pkill -SIGUSR1 kitty"
### Palette Files
-Create palette files in your `palettes_path` directory:
+
+Example palette file
+Create palette files in your `palettes_path` directory:
```toml
# ~/.config/clrsync/palettes/dark.toml
[general]
@@ -222,10 +303,14 @@ surface_variant = '#1C1C1CFF'
warning = '#E1C135FF'
```
+
+
### Template Files
-Create template files at `~/.config/clrsync/templates` using color variables:
+
+Example template file
+Create template files at `~/.config/clrsync/templates` using color variables:
```conf
# ~/.config/clrsync/templates/kitty.conf
cursor {cursor}
@@ -253,10 +338,12 @@ color7 {base07}
color15 {base0F}
```
-#### Color Format Specifiers
+
+
+
+Color Format Specifiers
Format colors using dot notation:
-
```conf
# HEX formats
{color} # Default: #RRGGBB
@@ -286,42 +373,38 @@ Format colors using dot notation:
{color.a} # Alpha component
```
+
+
## 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 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
```
@@ -329,7 +412,6 @@ clrsync_cli --config /path/to/config.toml --apply
### GUI
Launch the graphical editor:
-
```bash
clrsync_gui
```
@@ -348,4 +430,4 @@ The GUI provides:
- **[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
+- **cursed** by **[pyratebeard](https://pyratebeard.net)** - Color scheme
\ No newline at end of file
diff --git a/flake.nix b/flake.nix
index 47e284a..748f56f 100644
--- a/flake.nix
+++ b/flake.nix
@@ -8,121 +8,79 @@
outputs =
{ self, nixpkgs, ... }:
let
- system = "x86_64-linux";
- pkgs = nixpkgs.legacyPackages.${system};
+ supportedSystems = [
+ "x86_64-linux"
+ ];
+ forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
+ nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
in
{
- packages.${system} = rec {
- clrsync = pkgs.stdenv.mkDerivation rec {
- pname = "clrsync";
- version = "unstable";
+ packages = forAllSystems (
+ system:
+ let
+ pkgs = nixpkgsFor.${system};
+ in
+ rec {
+ clrsync = pkgs.callPackage ./package.nix { };
+ default = clrsync;
+ }
+ );
- src = self;
-
- nativeBuildInputs = [
- pkgs.cmake
- pkgs.git
- pkgs.pkg-config
- pkgs.makeWrapper
- pkgs.wayland-protocols
- ];
-
- buildInputs = [
- pkgs.glfw
- pkgs.freetype
- pkgs.fontconfig
- pkgs.xorg.libXcursor
- pkgs.mesa
- pkgs.xorg.libX11
- pkgs.xorg.libXrandr
- pkgs.xorg.libXi
- pkgs.xorg.libXinerama
- pkgs.xorg.libXcursor
- pkgs.wayland
- pkgs.wayland-protocols
- pkgs.libxkbcommon
- pkgs.zlib
- pkgs.bzip2
- ];
-
- cmakeFlags = [
- "-DCMAKE_BUILD_TYPE=Release"
- "-DUSE_SYSTEM_GLFW=ON"
- ];
-
- installPhase = ''
- cmake --install . --prefix $out
- wrapProgram $out/bin/clrsync_gui \
- --prefix LD_LIBRARY_PATH : ${pkgs.lib.makeLibraryPath buildInputs}
- wrapProgram $out/bin/clrsync_cli \
- --prefix LD_LIBRARY_PATH : ${pkgs.lib.makeLibraryPath buildInputs}
- '';
-
- meta = with pkgs.lib; {
- description = "Color scheme manager (git version)";
- homepage = "https://github.com/obsqrbtz/clrsync";
- license = licenses.mit;
- platforms = platforms.linux;
- mainProgram = "clrsync_gui";
- };
- };
-
- default = clrsync;
+ homeModules = {
+ default = import ./home-manager-module.nix self;
+ clrsync = self.homeModules.default;
};
- homeManagerModules.default = import ./home-manager-module.nix;
- homeManagerModules.clrsync = self.homeManagerModules.default;
-
- apps.${system} = {
+ 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-gui;
+ 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;
};
-
- devShells.${system}.default = pkgs.mkShell {
- buildInputs = with pkgs; [
- cmake
- git
- pkg-config
- makeWrapper
- ninja
- stdenv.cc.cc.lib
- clang-tools
- gdb
-
- glfw
- freetype
- fontconfig
- mesa
- xorg.libX11
- xorg.libXrandr
- xorg.libXi
- xorg.libXinerama
- xorg.libXcursor
- libxkbcommon
- zlib
- bzip2
- wayland
- wayland-scanner
- wayland-protocols
- ];
-
- shellHook = ''
- export CMAKE_GENERATOR="Ninja"
- export CMAKE_EXPORT_COMPILE_COMMANDS=1
- export CPLUS_INCLUDE_PATH="${pkgs.gcc.cc}/include/c++/${pkgs.gcc.cc.version}:${pkgs.gcc.cc}/include/c++/${pkgs.gcc.cc.version}/x86_64-unknown-linux-gnu:$CPLUS_INCLUDE_PATH"
- export C_INCLUDE_PATH="${pkgs.gcc.cc}/include:$C_INCLUDE_PATH"
- export PATH=${pkgs.wayland-protocols}/bin:$PATH
- '';
- };
-
};
}
diff --git a/home-manager-module.nix b/home-manager-module.nix
index 74b23cb..21bdce5 100644
--- a/home-manager-module.nix
+++ b/home-manager-module.nix
@@ -1,3 +1,4 @@
+flake:
{
config,
lib,
@@ -8,11 +9,8 @@ with lib;
let
cfg = config.programs.clrsync;
- defaultPackage =
- if args ? inputs && args.inputs ? clrsync
- then args.inputs.clrsync.packages.${pkgs.system}.default or null
- else null;
-
+ clrsyncPackage = flake.packages.${pkgs.system}.default;
+
templateType = types.submodule {
options = {
enabled = mkOption {
@@ -35,6 +33,7 @@ let
};
};
};
+
configFormat = pkgs.formats.toml { };
configFile = configFormat.generate "config.toml" {
general = {
@@ -43,43 +42,44 @@ let
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;
+ 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";
- package = mkOption {
- type = types.nullOr types.package;
- default = defaultPackage;
- defaultText = literalExpression "inputs.clrsync.packages.\${pkgs.system}.default";
- description = "The clrsync package to use.";
- };
+
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 = { };
@@ -95,64 +95,61 @@ in
}
'';
};
+
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 (mkMerge [
- {
- assertions = [
- {
- assertion = cfg.package != null;
- message = ''
- programs.clrsync.package could not be automatically determined.
- Please add clrsync to your flake inputs and pass it via extraSpecialArgs:
-
- home-manager.extraSpecialArgs = { inherit inputs; };
-
- Or manually set:
- programs.clrsync.package = inputs.clrsync.packages.''${pkgs.system}.default;
- '';
- }
- ];
- }
- (mkIf (cfg.package != null) {
- home.packages = [ cfg.package ];
- xdg.configFile."clrsync/config.toml" = {
- source = configFile;
- force = true;
+
+ 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 ];
};
- 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 ${cfg.package}/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 = "${cfg.package}/bin/clrsync_cli --apply --theme ${cfg.defaultTheme}";
- RemainAfterExit = true;
- };
- Install = {
- WantedBy = [ cfg.systemdTarget ];
- };
+ Service = {
+ Type = "oneshot";
+ ExecStart = "${clrsyncPackage}/bin/clrsync_cli --apply --theme ${cfg.defaultTheme}";
+ RemainAfterExit = true;
};
- })
- ]);
-}
+ Install = {
+ WantedBy = [ cfg.systemdTarget ];
+ };
+ };
+ };
+}
\ No newline at end of file
diff --git a/package.nix b/package.nix
new file mode 100644
index 0000000..3207fc6
--- /dev/null
+++ b/package.nix
@@ -0,0 +1,93 @@
+{
+ lib,
+ stdenv,
+ cmake,
+ git,
+ pkg-config,
+ makeWrapper,
+ wayland-protocols,
+ glfw,
+ freetype,
+ fontconfig,
+ mesa,
+ xorg,
+ wayland,
+ libxkbcommon,
+ zlib,
+ bzip2,
+}:
+
+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-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 = [ ];
+ };
+}
\ No newline at end of file