configure catpuccino theme via new module

This commit is contained in:
Dmitriy Pleshevskiy 2022-10-28 15:26:00 +03:00
parent ec0d692a87
commit 9e4ed09149
Signed by: pleshevskiy
GPG key ID: 1B59187B161C0215
13 changed files with 217 additions and 81 deletions

View file

@ -68,18 +68,19 @@
${nixos-rebuild}/bin/nixos-rebuild switch \ ${nixos-rebuild}/bin/nixos-rebuild switch \
--flake .#${hostname} \ --flake .#${hostname} \
--target-host ${machine.config.deployment.targetHost} --target-host ${machine.config.deployment.targetHost}
$@
'') '')
vpsMachines); vpsMachines);
switch = lib.recurseIntoAttrs (lib.mapAttrs switch = lib.recurseIntoAttrs (lib.mapAttrs
(hostname: machine: pkgs.writeShellScript "switch-${hostname}" '' (hostname: machine: pkgs.writeShellScript "switch-${hostname}" ''
${nixos-rebuild}/bin/nixos-rebuild switch --flake .#${hostname} ${nixos-rebuild}/bin/nixos-rebuild switch --flake .#${hostname} $@
'') '')
localMachines); localMachines);
test = lib.recurseIntoAttrs (lib.mapAttrs test = lib.recurseIntoAttrs (lib.mapAttrs
(hostname: machine: pkgs.writeShellScript "test-${hostname}" '' (hostname: machine: pkgs.writeShellScript "test-${hostname}" ''
${nixos-rebuild}/bin/nixos-rebuild test --flake .#${hostname} ${nixos-rebuild}/bin/nixos-rebuild test --flake .#${hostname} $@
'') '')
localMachines); localMachines);
}); });

View file

@ -0,0 +1,76 @@
{ config, ... }:
let
# See: https://github.com/catppuccin/catppuccin
# palettes
rosewater = "#f2d5cf"; # Links, URLs
flamingo = "#eebebe";
pink = "#f4b8e4";
mauve = "#ca9ee6"; # Mark 2
red = "#e78284";
maroon = "#ea999c"; # Errors
peach = "#ef9f76"; # Warnings
yellow = "#e5c890";
green = "#a6d189"; # Success
teal = "#81c8be";
sky = "#99d1db";
sapphire = "#85c1dc"; # Mark 3
blue = "#8caaee"; # Search Results, tags
lavender = "#babbf1"; # Mark 1
# Foreground: Main Text, Body Copy
text = "#c6d0f5";
# Subtext: Secondary Text, Headlines, Labels
subtext1 = "#b5bfe2";
subtext0 = "#a5adce";
# Overlays: Splits, Floating Elements
overlay2 = "#949cbb";
overlay1 = "#838ba7";
overlay0 = "#737994"; # Subtle: Comments, Footnotes, Inactive Text
# Surface Elements: Sign Columns, Cursor Line, Generic Buttons, Inputs
surface2 = "#626880";
surface1 = "#51576d";
surface0 = "#414559";
# Background Pane: main background pane
base = "#303446";
# Secondary Panes: Secondary Canvases, Content Boxes, Sidebars
mantle = "#292c3c";
crust = "#232634";
in
{
config.local.theme = {
bar = {
background = mantle;
mainText = text;
inactiveText = overlay0;
};
window = {
activeBorder = lavender;
inactiveBorder = overlay0;
};
notification = {
background = mantle;
summary = subtext0;
body = text;
appName = overlay0;
lowBorder = lavender;
normalBorder = teal;
criticalBorder = red;
pausedBorder = blue;
};
highlights = {
success = green;
warning = peach;
error = maroon;
critical = red;
link = rosewater;
tags = blue;
};
syntax = {
markText = crust;
mark1 = lavender;
mark2 = mauve;
mark3 = sapphire;
};
};
}

45
themes/default.nix Normal file
View file

@ -0,0 +1,45 @@
{ lib, ... }:
let
mkColorOption = description: lib.mkOption {
type = lib.types.str;
inherit description;
};
in
{
options.local.theme = {
bar = {
background = mkColorOption "Background pane color";
mainText = mkColorOption "Main text color";
inactiveText = mkColorOption "Inactive text color";
};
window = {
activeBorder = mkColorOption "Color for window active border";
inactiveBorder = mkColorOption "Color for window inactive border";
};
notification = {
background = mkColorOption "Notification background color";
summary = mkColorOption "Notification summary text color";
body = mkColorOption "Notification body text color";
appName = mkColorOption "Notification app name text color";
lowBorder = mkColorOption "Notification low priority border color";
normalBorder = mkColorOption "Notification normal priority border color";
criticalBorder = mkColorOption "Notification critical priority border color";
pausedBorder = mkColorOption "Notification paused border color";
};
highlights = {
success = mkColorOption "Success color";
warning = mkColorOption "Warnings color";
error = mkColorOption "Errors color";
critical = mkColorOption "Clitical color";
link = mkColorOption "Links color";
tags = mkColorOption "Search results, tags color";
};
syntax = {
markText = mkColorOption "Text color for marked background";
mark1 = mkColorOption "Marked color 1";
mark2 = mkColorOption "Marked color 2";
mark3 = mkColorOption "Marked color 3";
};
};
}

View file

@ -19,6 +19,9 @@
../modules/editor.nix ../modules/editor.nix
../modules/work_tools.nix ../modules/work_tools.nix
../../themes
../../themes/catppuccin/frappe.nix
]; ];
xdg.enable = true; xdg.enable = true;

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

View file

@ -1,8 +1,9 @@
{ ... }: { config, pkgs, ... }:
let themeCfg = config.local.theme; in
{ {
services.wired = { services.wired = {
enable = true; enable = true;
config = ./wired.ron; config = pkgs.substituteAll ({ src = ./wired.ron; } // themeCfg.notification);
}; };
} }

View file

@ -88,13 +88,13 @@
// https://github.com/Toqozz/wired-notify/wiki/NotificationBlock // https://github.com/Toqozz/wired-notify/wiki/NotificationBlock
params: NotificationBlock(( params: NotificationBlock((
monitor: 0, monitor: 0,
border_width: 1.5, border_width: 2.5,
border_rounding: 0.0, border_rounding: 0.0,
background_color: Color(hex: "#ffffff"), background_color: Color(hex: "@background@"),
border_color: Color(hex: "#2e9afe"), border_color: Color(hex: "@normalBorder@"),
border_color_low: Color(hex: "#7f7f7f"), border_color_low: Color(hex: "@lowBorder@"),
border_color_critical: Color(hex: "#ea4300"), border_color_critical: Color(hex: "@criticalBorder@"),
border_color_paused: Color(hex: "#9058c7"), border_color_paused: Color(hex: "@pausedBorder@"),
gap: Vec2(x: 0.0, y: 8.0), gap: Vec2(x: 0.0, y: 8.0),
notification_hook: Hook(parent_anchor: BL, self_anchor: TL), notification_hook: Hook(parent_anchor: BL, self_anchor: TL),
@ -128,8 +128,7 @@
text: "%n", text: "%n",
font: "monospace 8", font: "monospace 8",
ellipsize: Middle, ellipsize: Middle,
color: Color(hex: "#7f7f7f"), color: Color(hex: "@appName@"),
color_hovered: Color(hex: "#7f7f7f"),
padding: Padding(left: 16.0, right: 0.0, top: 6.0, bottom: 0.0), padding: Padding(left: 16.0, right: 0.0, top: 6.0, bottom: 0.0),
dimensions: (width: (min: 0, max: 150), height: (min: 0, max: 0)), dimensions: (width: (min: 0, max: 150), height: (min: 0, max: 0)),
)), )),
@ -143,10 +142,9 @@
// https://github.com/Toqozz/wired-notify/wiki/TextBlock // https://github.com/Toqozz/wired-notify/wiki/TextBlock
params: TextBlock(( params: TextBlock((
text: "%s", text: "%s",
font: "sans-serif Bold 13", font: "sans-serif 13",
ellipsize: Middle, ellipsize: Middle,
color: Color(hex: "#17182b"), color: Color(hex: "@summary@"),
color_hovered: Color(hex: "#2e9afe"),
padding: Padding(left: 16.0, right: 16.0, top: 4.0, bottom: 0.0), padding: Padding(left: 16.0, right: 16.0, top: 4.0, bottom: 0.0),
dimensions: (width: (min: 300, max: 300), height: (min: 0, max: 0)), dimensions: (width: (min: 300, max: 300), height: (min: 0, max: 0)),
)), )),
@ -161,8 +159,7 @@
params: TextBlock(( params: TextBlock((
text: "%b", text: "%b",
font: "sans-serif 11", font: "sans-serif 11",
color: Color(hex: "#17182b"), color: Color(hex: "@body@"),
color_hovered: Color(hex: "#17182b"),
padding: Padding(left: 16.0, right: 16.0, top: 7.0, bottom: 12.0), padding: Padding(left: 16.0, right: 16.0, top: 7.0, bottom: 12.0),
dimensions: (width: (min: 300, max: 300), height: (min: 0, max: 150)), dimensions: (width: (min: 300, max: 300), height: (min: 0, max: 150)),
)), )),
@ -171,12 +168,12 @@
// https://github.com/Toqozz/wired-notify/wiki/Shortcuts // https://github.com/Toqozz/wired-notify/wiki/Shortcuts
shortcuts: ShortcutsConfig ( shortcuts: ShortcutsConfig (
notification_interact: 1, // notification_interact: 1,
notification_close: 3, notification_close: 3,
// notification_closeall: 99, // notification_closeall: 99,
// notification_pause: 99, // notification_pause: 99,
notification_action1: 2, notification_action1: 1,
// notification_action2: 99, // notification_action2: 99,
// notification_action3: 99, // notification_action3: 99,
// notification_action4: 99, // notification_action4: 99,

View file

@ -6,21 +6,31 @@ let
cfg = config.local.polybar; cfg = config.local.polybar;
inherit (config.services.polybar) package; inherit (config.services.polybar) package;
# TODO: create a theme themeCfg = config.local.theme;
colors = {
orange = "#ee9a00"; exchangerate_unwrapped = pkgs.writeShellScriptBin "exchangerate"
red = "#ff5555"; (builtins.readFile (pkgs.substituteAll ({ src = ./scripts/exchangerate.sh; } // themeCfg.highlights)));
green = "#50fa7b";
exchangerate = pkgs.symlinkJoin {
name = "exchangerate";
paths = [ exchangerate_unwrapped ] ++ (with pkgs; [ curl gnugrep gnused coreutils ]);
buildInputs = [ pkgs.makeWrapper ];
postBuild = ''
wrapProgram $out/bin/exchangerate --prefix PATH : @out/bin
'';
}; };
in in
{ {
options.local.polybar = with lib; { options.local.polybar = with lib;
wifiDevice = mkOption { {
type = types.str; wifiDevice = mkOption {
example = "wlp11s0f3u2"; type = types.str;
description = "Set your wifi device"; example = "wlp11s0f3u2";
description = "Set your wifi device";
};
}; };
};
config = { config = {
systemd.user.services.polybar = { systemd.user.services.polybar = {
@ -32,24 +42,37 @@ in
enable = true; enable = true;
script = "MONITOR=$(xrandr | grep \"connected primary\" | awk '{print $1;}') polybar &"; script = "MONITOR=$(xrandr | grep \"connected primary\" | awk '{print $1;}') polybar &";
settings = settings =
let padding = 1; in let
padding = 1;
# See: https://github.com/polybar/polybar/issues/478
fontVerticalOffset = "2";
in
{ {
settings = {
pseudo-transparency = true;
};
"bar/main" = { "bar/main" = {
monitor = "\${env:MONITOR:DisplayPort-1}"; monitor = "\${env:MONITOR:DisplayPort-1}";
width = "100%";
height = "20px";
font = [ font = [
"Fira Code:size=9:antialias=true" "Fira Code:size=9:antialias=true;${fontVerticalOffset}"
"Fira Code:bold:size=9:antialias=true" "Fira Code:bold:size=9:antialias=true;${fontVerticalOffset}"
"FiraCode Nerd Font Mono:size=9:antialias=true" "FiraCode Nerd Font Mono:size=9:antialias=true;${fontVerticalOffset}"
"FiraCode Nerd Font Mono:size=14:antialias=true" "FiraCode Nerd Font Mono:size=14:antialias=true;${fontVerticalOffset}"
]; ];
radius = 0;
modules = { modules = {
left = "xmonad"; left = "xmonad";
center = "date wifi"; center = "date wifi";
right = "exchangerate volume battery lang time"; right = "exchangerate volume battery lang time";
}; };
offset-x = "6px";
offset-y = "6px";
width = "100%:-12px";
height = "26px";
padding = 1;
radius = 6.0;
background = themeCfg.bar.background;
foreground = themeCfg.bar.mainText;
}; };
"module/date" = { "module/date" = {
@ -66,7 +89,7 @@ in
label = { label = {
text = "%time%"; text = "%time%";
font = 2; font = 2;
foreground = colors.orange; foreground = themeCfg.highlights.warning;
}; };
}; };
@ -81,7 +104,7 @@ in
"module/volume" = { "module/volume" = {
type = "custom/script"; type = "custom/script";
exec = "~/scripts/get_volume.sh"; exec = "${./scripts/get_volume.sh}";
interval = 1; interval = 1;
format = { format = {
inherit padding; inherit padding;
@ -99,25 +122,25 @@ in
format.charging = { format.charging = {
inherit padding; inherit padding;
text = "%{T3}%{T-} <label-charging>"; text = "%{T3}%{T-} <label-charging>";
foreground = colors.green; foreground = themeCfg.highlights.success;
}; };
format.discharging = { format.discharging = {
inherit padding; inherit padding;
text = "%{T3}<ramp-capacity>%{T-} <label-discharging>"; text = "%{T3}<ramp-capacity>%{T-} <label-discharging>";
foreground = colors.orange; foreground = themeCfg.highlights.warning;
}; };
format.full = { format.full = {
inherit padding; inherit padding;
text = "%{T3}%{T-} <label-full>"; text = "%{T3}%{T-} <label-full>";
foreground = colors.green; foreground = themeCfg.highlights.success;
}; };
format.low = { format.low = {
inherit padding; inherit padding;
text = "%{T3}%{T-} <label-low>"; text = "%{T3}%{T-} <label-low>";
foreground = colors.red; foreground = themeCfg.highlights.critical;
}; };
# Only applies if <ramp-capacity> is used # Only applies if <ramp-capacity> is used
@ -146,7 +169,7 @@ in
"module/exchangerate" = { "module/exchangerate" = {
type = "custom/script"; type = "custom/script";
exec = "~/scripts/exchangerate.sh"; exec = "${exchangerate}/bin/exchangerate";
interval = 60; interval = 60;
format = { format = {
inherit padding; inherit padding;

View file

@ -1,4 +1,4 @@
#!/bin/sh #!/usr/bin/env bash
set -e set -e
@ -31,11 +31,11 @@ cc=($(curl_cbr))
diff=$(echo ${cc[-1]} ${cc[-2]} | awk '{ print $1 - $2 }') diff=$(echo ${cc[-1]} ${cc[-2]} | awk '{ print $1 - $2 }')
arror="↑" arror="↑"
color='#50fa7b' color='@success@'
if [ ${diff:0:1} == '-' ]; then if [ ${diff:0:1} == '-' ]; then
diff=${diff:1} diff=${diff:1}
arror="↓" arror="↓"
color='#ff5555' color='@error@'
fi fi
case $bar_name in case $bar_name in

View file

@ -1,4 +1,5 @@
#!/bin/sh #!/usr/bin/env bash
enabled=$(amixer sget Master | egrep -o "\[on\]" | wc -l) enabled=$(amixer sget Master | egrep -o "\[on\]" | wc -l)
if [[ $enabled == "0" ]]; then if [[ $enabled == "0" ]]; then
echo "off" echo "off"

View file

@ -1,5 +1,6 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
let themeCfg = config.local.theme; in
{ {
home.packages = with pkgs; [ home.packages = with pkgs; [
xclip # access x clipboard from a console xclip # access x clipboard from a console
@ -13,7 +14,13 @@
windowManager.xmonad = { windowManager.xmonad = {
enable = true; enable = true;
enableContribAndExtras = true; enableContribAndExtras = true;
config = ./xmonad_config.hs; config = pkgs.substituteAll {
src = ./xmonad_config.hs;
inherit (themeCfg.bar) background mainText inactiveText;
inherit (themeCfg.window) activeBorder inactiveBorder;
inherit (themeCfg.highlights) critical warning success;
inherit (themeCfg.syntax) mark1 mark2 mark3;
};
extraPackages = (hp: [ extraPackages = (hp: [
hp.dbus hp.dbus
hp.monad-logger hp.monad-logger

View file

@ -83,24 +83,6 @@ devWs = ["dev", "dev2", "dev3"]
myWorkspaces = [webWs] <> devWs <> [finWs, sysWs, comWs] myWorkspaces = [webWs] <> devWs <> [finWs, sysWs, comWs]
-- Colors
blue = "#2E9AFE"
gray = "#7F7F7F"
orange = "#ea4300"
purple = "#9058c7"
red = "#722222"
-- Border colors for unfocused and focused windows, respectively.
--
myNormalBorderColor = gray
myFocusedBorderColor = blue
main :: IO () main :: IO ()
main = mkDbusClient >>= main' main = mkDbusClient >>= main'
@ -115,8 +97,8 @@ main' dbus =
borderWidth = myBorderWidth, borderWidth = myBorderWidth,
modMask = myModMask, modMask = myModMask,
workspaces = myWorkspaces, workspaces = myWorkspaces,
normalBorderColor = myNormalBorderColor, normalBorderColor = "@inactiveBorder@",
focusedBorderColor = myFocusedBorderColor, focusedBorderColor = "@activeBorder@",
-- key bindings -- key bindings
keys = myKeys, keys = myKeys,
mouseBindings = myMouseBindings, mouseBindings = myMouseBindings,
@ -156,12 +138,12 @@ polybarHook dbus =
let wrapper c = wrap ("%{F" <> c <> "}") "%{F-}" let wrapper c = wrap ("%{F" <> c <> "}") "%{F-}"
in def in def
{ ppOutput = dbusOutput dbus, { ppOutput = dbusOutput dbus,
ppCurrent = wrapper blue, ppCurrent = wrapper "@success@",
ppVisible = wrapper purple, ppVisible = wrapper "@mark3@",
ppUrgent = wrapper orange, ppUrgent = wrapper "@critical@",
ppHidden = wrapper gray, ppHidden = wrapper "@mark1@",
ppHiddenNoWindows = wrapper red, ppHiddenNoWindows = wrapper "@inactiveText@",
ppTitle = wrapper purple . shorten 90 ppTitle = wrapper "@mark3@" . shorten 60
} }
myPolybarLogHook dbus = myLogHook <+> dynamicLogWithPP (polybarHook dbus) myPolybarLogHook dbus = myLogHook <+> dynamicLogWithPP (polybarHook dbus)
@ -430,11 +412,11 @@ myPromptConfig =
def def
{ position = Top, { position = Top,
font = "xft:Fira Code:size=12:antialias=true", font = "xft:Fira Code:size=12:antialias=true",
borderColor = "#333333", borderColor = "@inactiveBorder@",
bgColor = "#222222", bgColor = "@background@",
fgColor = blue, fgColor = "@mainText@",
bgHLight = "#222222", bgHLight = "@background@",
fgHLight = purple, fgHLight = "@mark3@",
height = 25 height = 25
} }