From bf7848df01b1ce682a29301d8a3c776a2008a5b7 Mon Sep 17 00:00:00 2001 From: "Lennart J. Kurzweg (Nx2)" Date: Fri, 19 Apr 2024 17:28:08 +0200 Subject: [PATCH] nxricelib --- flake.nix | 65 +++++++++---------- home-modules/hyprland-autoname-workspaces.nix | 14 +--- home-modules/hyprland.nix | 24 +++---- home-modules/kitty.nix | 45 +++++++------ home-modules/mako.nix | 2 +- home-modules/vscode.nix | 4 +- home-modules/waybar.nix | 48 ++++++-------- home-modules/wlogout.nix | 2 +- nxlib/ricelib.nix | 64 ++++++++++++++++++ 9 files changed, 157 insertions(+), 111 deletions(-) create mode 100644 nxlib/ricelib.nix diff --git a/flake.nix b/flake.nix index bba8501..458f3ca 100644 --- a/flake.nix +++ b/flake.nix @@ -17,30 +17,22 @@ url = "github:hyprwm/hyprland-plugins"; inputs.hyprland.follows = "hyprland"; }; - - # hyprfocus = { - # url = "github:VortexCoyote/hyprfocus"; - # inputs.hyprland.follows = "hyprland"; - # }; - Hyprspace = { url = "github:KZDKM/Hyprspace"; inputs.hyprland.follows = "hyprland"; }; - # hycov = { - # url = "github:DreamMaoMao/hycov"; - # inputs.hyprland.follows = "hyprland"; - # }; }; outputs = { self, nixpkgs, nixpkgs-unstable, home-manager, ... }@inputs: - # outputs = { self, nixpkgs, nixpkgs-unstable, home-manager, hyprland, ... }@inputs: let system = "x86_64-linux"; pkgs = nixpkgs.legacyPackages.${system}; pkgs-unstable = nixpkgs-unstable.legacyPackages.${system}; + + overlays = [ inputs.nix-rice.overlays.default ]; + user = "nx2"; nvidia = rec { @@ -74,34 +66,39 @@ }; secrets = import ./secrets/passwords-and-certificates.nix; - - rice = { - transparency = "0.9"; + + rice = rec { + lib = import ./nxlib/ricelib.nix { lib = nixpkgs.lib; }; + transparency = 0.9; + rounding = 5; color = rec { - background = "000000"; # #000000 - foreground = "dddddd"; # #dddddd - black = "282B35"; # #282B35 - bright-black = "686A71"; # #686A71 - blue = "9d00ff"; # #9d00ff - bright-blue = "c76eff"; # #c76eff - cyan = "00ddff"; # #00ddff - bright-cyan = "33f9ff"; # #33f9ff - green = "0048ff"; # #0048ff - bright-green = "1166ff"; # #1166ff - magenta = "B21889"; # #B21889 - bright-magenta = "ff75f6"; # #ff75f6 - red = "ff0044"; # #ff0044 - bright-red = "ff4576"; # #ff4576 - white = "939599"; # #939599 - bright-white = "ffffff"; # #ffffff - yellow = "ff4000"; # #ff4000 - bright-yellow = "ff8454"; # #ff8454 + background = "#000000"; + foreground = "#dddddd"; + black = "#282B35"; + bright-black = "#686A71"; + blue = "#9d00ff"; + bright-blue = "#c76eff"; + cyan = "#00ddff"; + bright-cyan = "#33f9ff"; + green = "#0048ff"; + bright-green = "#1166ff"; + magenta = "#B21889"; + bright-magenta = "#ff75f6"; + red = "#ff0044"; + bright-red = "#ff4576"; + white = "#939599"; + bright-white = "#ffffff"; + yellow = "#ff4000"; + bright-yellow = "#ff8454"; border = red; }; font = { code = { - name = "CascadiaCove-NF"; - package = (pkgs.nerdfonts.override { fonts = [ "CascadiaCode" ]; }); + name = "JetBrainsMono-NF"; + name2 = "JetBrainsMono Nerd Font"; + package = (pkgs.nerdfonts.override { fonts = [ "JetBrainsMono" ]; }); + # name = "CascadiaCove-NF"; + # package = (pkgs.nerdfonts.override { fonts = [ "CascadiaCode" ]; }); }; base = { name = "Atkinson Hyperlegible"; diff --git a/home-modules/hyprland-autoname-workspaces.nix b/home-modules/hyprland-autoname-workspaces.nix index a597821..395b98b 100644 --- a/home-modules/hyprland-autoname-workspaces.nix +++ b/home-modules/hyprland-autoname-workspaces.nix @@ -63,17 +63,6 @@ [initial_class_active] [workspaces_name] - 10 = "ten" - 4 = "four" - 8 = "eight" - 9 = "nine" - 6 = "six" - 1 = "one" - 3 = "three" - 2 = "two" - 0 = "zero" - 7 = "seven" - 5 = "five" [title_in_class] [title_in_class_active] @@ -87,7 +76,6 @@ [exclude] "(?i)fcitx" = ".*" aProgram = "^$" - "ueberzug.*" = "" "" = "^$" "[Ss]team" = "^(Friends List.*)?$" "explorer.exe" = ".*" @@ -97,7 +85,7 @@ dedup = false dedup_inactive_fullscreen = false delim = " " - workspace = "{id}: {clients}" + workspace = "{id}:{clients}" workspace_empty = "{id}" client = "{icon}" client_fullscreen = "{icon}" diff --git a/home-modules/hyprland.nix b/home-modules/hyprland.nix index 96ef6ea..ce9b6c8 100644 --- a/home-modules/hyprland.nix +++ b/home-modules/hyprland.nix @@ -1,9 +1,9 @@ { config, pkgs, pkgs-unstable, inputs, host, nvidia, rice, lib, ... }: let animation-speed = "2"; - transparency = rice.transparency; + transparency = builtins.toString rice.transparency; gap-size = 10; - rounding = 3; + rounding = rice.rounding; border-width = 3; monitors = { xps = { @@ -143,8 +143,8 @@ in gaps_in = builtins.div gap-size 2; gaps_out = gap-size; border_size = border-width; - "col.active_border" = "rgba(${rice.color.red}ff) rgba(${rice.color.bright-cyan}ff) 45deg"; - "col.inactive_border" = "rgba(${rice.color.black}ff)"; + "col.active_border" = "rgba(${rice.lib.nohash rice.color.red}ff) rgba(${rice.lib.nohash rice.color.cyan}ff) 90deg"; + "col.inactive_border" = "rgba(${rice.lib.nohash rice.color.black}ff)"; cursor_inactive_timeout = 10; @@ -159,8 +159,8 @@ in shadow_range = "20"; shadow_offset = "0 0"; shadow_render_power = "4"; - "col.shadow" = "rgba(${rice.color.red}ff)"; - "col.shadow_inactive" = "rgba(${rice.color.black}ff)"; + "col.shadow" = "rgba(${rice.lib.nohash rice.color.red}ff)"; + "col.shadow_inactive" = "rgba(${rice.lib.nohash rice.color.black}ff)"; active_opacity = "1.0"; inactive_opacity = "1.0"; @@ -239,7 +239,7 @@ in windowrulev2 = [ "opacity ${transparency},class:^(com.chatterino.*)$" "opacity ${transparency},class:^(chatterino)$" - "bordercolor rgba(${rice.color.bright-magenta}ff), pinned:1" + "bordercolor rgba(${rice.lib.nohash rice.color.bright-magenta}ff), pinned:1" ]; windowrule = [ @@ -250,8 +250,8 @@ in "opacity ${transparency}, neovide" "opacity ${transparency}, obsidian" "opacity ${transparency}, zathura" - "bordercolor rgba(${rice.color.foreground}ff) rgba(${rice.color.background}b2), Alacritty" - "bordercolor rgba(${rice.color.foreground}ff) rgba(${rice.color.background}b2), Kitty" + "bordercolor rgba(${rice.lib.nohash rice.color.foreground}ff) rgba(${rice.lib.nohash rice.color.background}${rice.lib.float-to-drune rice.transparency}), Alacritty" + "bordercolor rgba(${rice.lib.nohash rice.color.foreground}ff) rgba(${rice.lib.nohash rice.color.background}${rice.lib.float-to-drune rice.transparency}), Kitty" "opacity ${transparency}, discord" "opacity ${transparency}, vesktop" "opacity ${transparency}, Element" @@ -313,8 +313,8 @@ in # "SUPER, F10, hyprload,update" "SUPER, F11, exec, waybar" "SUPER SHIFT, F11, exec, pkill waybar " - "SUPER, F12, exec, hyprland-autoname-workspaces --migrate-config &" - "SUPER SHIFT, F12, exec, pkill hyprland-autoname-workspaces " + "SUPER, F12, exec, hyprland-autoname-workspaces" + "SUPER SHIFT, F12, exec, pkill -9 hyprland-autoname-workspaces " ########################################################################### ## ROW 1: @@ -778,7 +778,7 @@ in hyprexpo { columns = 5 gap_size = ${builtins.toString gap-size} - bg_col = rgb(${rice.color.background}) + bg_col = rgb(${rice.lib.nohash rice.color.background}) workspace_method = first 10 # [center/first] [workspace] e.g. first 1 or center m+1 enable_gesture = false # laptop touchpad, 4 fingers diff --git a/home-modules/kitty.nix b/home-modules/kitty.nix index 41c544c..d95eefe 100644 --- a/home-modules/kitty.nix +++ b/home-modules/kitty.nix @@ -9,28 +9,31 @@ in programs.kitty = { enable = true; - font = rice.font.code; + font = { + name = rice.font.code.name2; + package = rice.font.code.package; + }; settings = { - background = "#${rice.color.background}"; - foreground = "#${rice.color.foreground}"; - cursor = "#${rice.color.foreground}"; - color0 = "#${rice.color.black}"; - color8 = "#${rice.color.bright-black}"; - color1 = "#${rice.color.red}"; - color9 = "#${rice.color.bright-red}"; - color2 = "#${rice.color.green}"; - color10 = "#${rice.color.bright-green}"; - color3 = "#${rice.color.yellow}"; - color11 = "#${rice.color.bright-yellow}"; - color4 = "#${rice.color.blue}"; - color12 = "#${rice.color.bright-blue}"; - color5 = "#${rice.color.magenta}"; - color13 = "#${rice.color.bright-magenta}"; - color6 = "#${rice.color.cyan}"; - color14 = "#${rice.color.bright-cyan}"; - color7 = "#${rice.color.white}"; - color15 = "#${rice.color.bright-white}"; - background_opacity = rice.transparency; + background = rice.color.background; + foreground = rice.color.foreground; + cursor = rice.color.foreground; + color0 = rice.color.black; + color8 = rice.color.bright-black; + color1 = rice.color.red; + color9 = rice.color.bright-red; + color2 = rice.color.green; + color10 = rice.color.bright-green; + color3 = rice.color.yellow; + color11 = rice.color.bright-yellow; + color4 = rice.color.blue; + color12 = rice.color.bright-blue; + color5 = rice.color.magenta; + color13 = rice.color.bright-magenta; + color6 = rice.color.cyan; + color14 = rice.color.bright-cyan; + color7 = rice.color.white; + color15 = rice.color.bright-white; + background_opacity = builtins.toString rice.transparency; transparency = true; scroll_multiplier = 9; window_padding_width = 5; diff --git a/home-modules/mako.nix b/home-modules/mako.nix index 01ee408..af16d73 100644 --- a/home-modules/mako.nix +++ b/home-modules/mako.nix @@ -11,6 +11,6 @@ backgroundColor = "#${rice.color.background}"; textColor = "#${rice.color.foreground}"; borderColor = "#${rice.color.border}"; - font = rice.font.code.name; + font = rice.font.code.name2; }; } \ No newline at end of file diff --git a/home-modules/vscode.nix b/home-modules/vscode.nix index 2fdee63..deb7c1c 100644 --- a/home-modules/vscode.nix +++ b/home-modules/vscode.nix @@ -1,4 +1,4 @@ -{ config, pkgs, lib, system, user, allowed, secrets, ... }: +{ config, pkgs, lib, user, rice, allowed, ... }: { home.packages = [ @@ -78,7 +78,7 @@ ]; userSettings = { workbench.colorTheme = "Just Black"; - editor.fontFamily = "'CaskaydiaCove Nerd Font', 'monospace', monospace"; + editor.fontFamily = "'${rice.font.code.name2}', 'monospace', monospace"; emote.SSH.useLocalServer = false; }; enableUpdateCheck = false; diff --git a/home-modules/waybar.nix b/home-modules/waybar.nix index 292d2bf..dba86d9 100644 --- a/home-modules/waybar.nix +++ b/home-modules/waybar.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, ... }: +{ config, lib, pkgs, rice, ... }: let in { @@ -60,6 +60,7 @@ in bar = { height = 20; layer = "top"; + # position = "top"; position = "bottom"; margin-top = 0; margin-left = 0; @@ -153,30 +154,29 @@ in ]; }; network = { - format-wifi = "直 {essid}"; - format-ethernet = " Wired"; - format-disconnected = "睊 Disconnected"; + format-wifi = " {essid}"; + format-ethernet = "󰈀 Wired"; + format-disconnected = "󰌙 Disconnected"; }; wireplumber = { format = "󰕾 {volume}%"; - format-muted = "婢 Muted"; + format-muted = " Muted"; }; }; }; style = '' * { - font-family: Atkinson Hyperlegible, Caskaydia Cove NF, Noto Sans; - font-weight: bold; - font-size: 1.01em; + font-family: ${rice.font.code.name2}; + font-size: 1em; min-height: 0; } window#waybar { - background-color: rgba(0, 0, 0, 0.85); + background-color: rgba(${rice.lib.hex-to-rgb-comma-string rice.color.background},${builtins.toString rice.transparency}); transition-duration: 0.5s; padding: 0.1em 1em; padding-top: 0.1em; - border: 0px solid transparent; + border: None; } #clock, @@ -195,40 +195,34 @@ in #workspaces { padding: 0px 3px; margin-top: 0.3em; - border-radius: 0.8em; - color: white; - } - - #window { - font-weight: normal; + border-radius: ${builtins.toString rice.rounding}px; + color: rgb(${rice.lib.hex-to-rgb-comma-string rice.color.foreground}); } #workspaces button { - color: grey; + color: rgb(${rice.lib.hex-to-rgb-comma-string rice.color.bright-black}); padding: 0px 10px; margin: 1px; - border-radius: 0.2em; - border: 0px solid transparent; - } - - #workspaces button.focused { - background-color: darkred; + border-radius: ${builtins.toString rice.rounding}px; + border: None; } #workspaces button:hover { - background-color: green; + color: rgb(${rice.lib.hex-to-rgb-comma-string rice.color.background}); + background-color: rgba(${rice.lib.hex-to-rgb-comma-string rice.color.foreground},${builtins.toString rice.transparency}); } #workspaces button.active { - color: white; + color: rgb(${rice.lib.hex-to-rgb-comma-string rice.color.foreground}); + background-color: rgba(${rice.lib.hex-to-rgb-comma-string rice.color.background},${builtins.toString rice.transparency}); } #workspaces button.urgent { - background-color: darkorchid; + background-color: rgba(${rice.lib.hex-to-rgb-comma-string rice.color.magenta},${builtins.toString rice.transparency}); } #custom-mode { - color: crimson; + color: rgb(${rice.lib.hex-to-rgb-comma-string rice.color.red}); } #cpu { diff --git a/home-modules/wlogout.nix b/home-modules/wlogout.nix index 9ea6402..e0473be 100644 --- a/home-modules/wlogout.nix +++ b/home-modules/wlogout.nix @@ -12,7 +12,7 @@ font-family: ${rice.font.code.name}, monospace; font-size: 12pt; color: ${rice.color.foreground}; - background-color: rgba(0, 0, 0, ${rice.transparency}); + background-color: rgba(0, 0, 0, ${builtins.toString rice.transparency}); } button { diff --git a/nxlib/ricelib.nix b/nxlib/ricelib.nix new file mode 100644 index 0000000..65d5753 --- /dev/null +++ b/nxlib/ricelib.nix @@ -0,0 +1,64 @@ +{ lib, ... }: +rec +{ + nohash = s: builtins.substring 1 7 s; + + slice-hex = hex: { r = builtins.substring 0 2 hex; g = builtins.substring 2 2 hex; b = builtins.substring 4 5 hex; }; + + # https://github.com/bertof/nix-rice + rune-to-num = c: + let + k = lib.strings.toUpper c; + dict = { + "0" = 0; + "1" = 1; + "2" = 2; + "3" = 3; + "4" = 4; + "5" = 5; + "6" = 6; + "7" = 7; + "8" = 8; + "9" = 9; + "A" = 10; + "B" = 11; + "C" = 12; + "D" = 13; + "E" = 14; + "F" = 15; + }; + in + assert(builtins.hasAttr k dict); + builtins.getAttr k dict; + + drune-to-255 = hex: (rune-to-num (builtins.substring 0 1 hex)) * 15 + (rune-to-num (builtins.substring 1 2 hex)); + + hex-to-rgb-comma-string = hex: let color = (slice-hex (nohash hex)); in "${builtins.toString (drune-to-255 color.r)},${builtins.toString (drune-to-255 color.g)},${builtins.toString (drune-to-255 color.b)}"; + + num-to-rune = n: + let + ns = builtins.toString n; + dict = { + "0" = "0"; + "1" = "1"; + "2" = "2"; + "3" = "3"; + "4" = "4"; + "5" = "5"; + "6" = "6"; + "7" = "7"; + "8" = "8"; + "9" = "9"; + "10" = "A"; + "11" = "B"; + "12" = "C"; + "13" = "D"; + "14" = "E"; + "15" = "F"; + }; + in + assert(builtins.hasAttr ns dict); + builtins.getAttr ns dict; + + float-to-drune = f: "${num-to-rune (builtins.floor((255*f) / 16))}${num-to-rune (builtins.floor(255*f) - (builtins.floor((255 * f) / 16) * 16))}"; +} \ No newline at end of file