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 \
--flake .#${hostname} \
--target-host ${machine.config.deployment.targetHost}
$@
'')
vpsMachines);
switch = lib.recurseIntoAttrs (lib.mapAttrs
(hostname: machine: pkgs.writeShellScript "switch-${hostname}" ''
${nixos-rebuild}/bin/nixos-rebuild switch --flake .#${hostname}
${nixos-rebuild}/bin/nixos-rebuild switch --flake .#${hostname} $@
'')
localMachines);
test = lib.recurseIntoAttrs (lib.mapAttrs
(hostname: machine: pkgs.writeShellScript "test-${hostname}" ''
${nixos-rebuild}/bin/nixos-rebuild test --flake .#${hostname}
${nixos-rebuild}/bin/nixos-rebuild test --flake .#${hostname} $@
'')
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/work_tools.nix
../../themes
../../themes/catppuccin/frappe.nix
];
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 = {
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
params: NotificationBlock((
monitor: 0,
border_width: 1.5,
border_width: 2.5,
border_rounding: 0.0,
background_color: Color(hex: "#ffffff"),
border_color: Color(hex: "#2e9afe"),
border_color_low: Color(hex: "#7f7f7f"),
border_color_critical: Color(hex: "#ea4300"),
border_color_paused: Color(hex: "#9058c7"),
background_color: Color(hex: "@background@"),
border_color: Color(hex: "@normalBorder@"),
border_color_low: Color(hex: "@lowBorder@"),
border_color_critical: Color(hex: "@criticalBorder@"),
border_color_paused: Color(hex: "@pausedBorder@"),
gap: Vec2(x: 0.0, y: 8.0),
notification_hook: Hook(parent_anchor: BL, self_anchor: TL),
@ -128,8 +128,7 @@
text: "%n",
font: "monospace 8",
ellipsize: Middle,
color: Color(hex: "#7f7f7f"),
color_hovered: Color(hex: "#7f7f7f"),
color: Color(hex: "@appName@"),
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)),
)),
@ -143,10 +142,9 @@
// https://github.com/Toqozz/wired-notify/wiki/TextBlock
params: TextBlock((
text: "%s",
font: "sans-serif Bold 13",
font: "sans-serif 13",
ellipsize: Middle,
color: Color(hex: "#17182b"),
color_hovered: Color(hex: "#2e9afe"),
color: Color(hex: "@summary@"),
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)),
)),
@ -161,8 +159,7 @@
params: TextBlock((
text: "%b",
font: "sans-serif 11",
color: Color(hex: "#17182b"),
color_hovered: Color(hex: "#17182b"),
color: Color(hex: "@body@"),
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)),
)),
@ -171,12 +168,12 @@
// https://github.com/Toqozz/wired-notify/wiki/Shortcuts
shortcuts: ShortcutsConfig (
notification_interact: 1,
// notification_interact: 1,
notification_close: 3,
// notification_closeall: 99,
// notification_pause: 99,
notification_action1: 2,
notification_action1: 1,
// notification_action2: 99,
// notification_action3: 99,
// notification_action4: 99,

View file

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

View file

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

View file

@ -1,5 +1,6 @@
{ config, lib, pkgs, ... }:
let themeCfg = config.local.theme; in
{
home.packages = with pkgs; [
xclip # access x clipboard from a console
@ -13,7 +14,13 @@
windowManager.xmonad = {
enable = 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: [
hp.dbus
hp.monad-logger

View file

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