1

Compare commits

...

7 Commits

15 changed files with 396 additions and 209 deletions

View File

@ -1 +0,0 @@

View File

@ -1,86 +0,0 @@
[
{
"include": [
"~/.config/waybar/monitor.json"
],
"layer": "top",
"position": "top",
"height": 40,
"spacing": 4,
"modules-left": [
"custom/launcher",
"user",
"hyprland/window"
],
"modules-center": [
"hyprland/workspaces"
],
"modules-right": [
"pulseaudio",
"network",
"cpu",
"memory",
"temperature",
"clock",
"tray"
],
"custom/launcher": {
"format": "<span font=\"FontAwesome\"></span> ",
"interval": "once",
"tooltip": false
},
"hyprland/workspaces": {
"all-outputs": false,
"format": "{name}",
"on-click": "activate",
"sort-by-coordinates": false,
"sort-by-name": true,
"sort-by-number": false
},
"pulseaudio": {
"format": "<span font=\"FontAwesome\"></span> {volume}%",
"format-muted": "<span font=\"FontAwesome\"></span> ",
// "on-click": "alacritty -o font.size=12 -e ncpamixer -t o"
"on-click": "kitty ncpamixer -t o"
},
"network": {
"format": "<span font=\"FontAwesome\"></span> {ipaddr}",
"format-disconnected": "<span font=\"FontAwesome\"></span> ",
"interface": "enp8s0",
"tooltip-format": "{ifname} via {gwaddr}"
},
"cpu": {
"format": "<span font=\"FontAwesome\"></span> {load}%"
},
"memory": {
"format": "<span font=\"FontAwesome\"></span> {percentage}%"
},
"temperature": {
"format": "<span font=\"FontAwesome\"></span> {temperatureC}°C",
"thermal-zone": 3
},
"clock": {
"format": "<span font=\"FontAwesome\"></span> {:%H:%M}",
"timezone": "Europe/Berlin",
"tooltip-format": "<tt><small>{calendar}</small></tt>"
},
"tray": {
"icon-size": 20,
"show-passive-items": true,
"spacing": 5
}
}
]

View File

@ -1,59 +0,0 @@
/*TODO: Set this through nixos module programatically*/
/*@import url("colors/three-bears.css");*/
@import url("colors/foggy-lake.css");
/*Order is Top-Right-Bottom-Left for combined properties*/
window#waybar {
font-family: JetBrainsMono Nerd Font Mono;
font-weight: bold;
color: @base;
background-color: rgba(239,241,245,0.6);
}
/*Square Widgets*/
#custom-launcher,
#workspaces button,
#tray {
padding: 0px 10px 0px 10px;
margin: 5px 5px 5px 5px;
border-radius: 6px;
color: @base;
}
#workspaces button:hover {
color: @pink;
}
/*Tux Icon*/
#custom-launcher {
font-size: 18px;
padding-right: 0px;
}
/*Rectangle Widgets*/
#user,
#window,
#pulseaudio,
#network,
#cpu,
#memory,
#temperature,
#clock {
padding: 0px 10px 0px 10px;
margin: 8px 5px 8px 5px;
border-radius: 6px;
}
/*Colors*/
#custom-launcher { background-color: @flamingo; }
#user { background-color: @pink; }
#window { background-color: @mauve; }
#workspaces button { background-color: @red; }
#pulseaudio { background-color: @maroon; }
#network { background-color: @peach; }
#cpu { background-color: @yellow; }
#memory { background-color: @green; }
#temperature { background-color: @teal; }
#clock { background-color: @sky; }
#tray { background-color: @sapphire; }

View File

@ -38,6 +38,12 @@ rec {
google = false;
};
color = {
enable = true; # You can't disable this
lightScheme = "catppuccin-latte";
darkScheme = "catppuccin-mocha";
};
firefox = {
enable = true;
wayland = true;

View File

@ -0,0 +1,29 @@
{
rosewater = "";
flamingo = "";
pink = "";
mauve = "";
red = "";
maroon = "";
peach = "";
yellow = "";
green = "";
teal = "";
sky = "";
sapphire = "";
blue = "";
lavender = "";
text = "";
subtext1 = "";
subtext0 = "";
overlay2 = "";
overlay1 = "";
overlay0 = "";
surface2 = "";
surface1 = "";
surface0 = "";
base = "";
mantle = "";
crust = "";
}

View File

@ -0,0 +1,29 @@
{
rosewater = "dc8a78";
flamingo = "dd7878";
pink = "ea76cb";
mauve = "8839ef";
red = "d20f39";
maroon = "e64553";
peach = "fe640b";
yellow = "df8e1d";
green = "40a02b";
teal = "179299";
sky = "04a5e5";
sapphire = "209fb5";
blue = "1e66f5";
lavender = "7287fd";
text = "4c4f69";
subtext1 = "5c5f77";
subtext0 = "6c6f85";
overlay2 = "7c7f93";
overlay1 = "8c8fa1";
overlay0 = "9ca0b0";
surface2 = "acb0be";
surface1 = "bcc0cc";
surface0 = "ccd0da";
base = "eff1f5";
mantle = "e6e9ef";
crust = "dce0e8";
}

View File

@ -0,0 +1,29 @@
{
rosewater = "f5e0dc";
flamingo = "f2cdcd";
pink = "f5c2e7";
mauve = "cba6f7";
red = "f38ba8";
maroon = "eba0ac";
peach = "fab387";
yellow = "f9e2af";
green = "a6e3a1";
teal = "94e2d5";
sky = "89dceb";
sapphire = "74c7ec";
blue = "89b4fa";
lavender = "b4befe";
text = "cdd6f4";
subtext1 = "bac2de";
subtext0 = "a6adc8";
overlay2 = "9399b2";
overlay1 = "7f849c";
overlay0 = "6c7086";
surface2 = "585b70";
surface1 = "45475a";
surface0 = "313244";
base = "1e1e2e";
mantle = "181825";
crust = "11111b";
}

View File

@ -0,0 +1,66 @@
{
config,
lib,
mylib,
...
}:
with lib;
with mylib.modules; let
cfg = config.modules.color;
# Options and assignments will be generated from those keys
colorKeys = [
# Colors
"rosewater"
"flamingo"
"pink"
"mauve"
"red"
"maroon"
"peach"
"yellow"
"green"
"teal"
"sky"
"sapphire"
"blue"
"lavender"
# 50 shades of gray
"text"
"subtext1"
"subtext0"
"overlay2"
"overlay1"
"overlay0"
"surface2"
"surface1"
"surface0"
"base"
"mantle"
"crust"
];
in {
options.modules.color = import ./options.nix {inherit lib mylib colorKeys;};
config = let
lightDefs = import ./${cfg.lightScheme}.nix;
darkDefs = import ./${cfg.darkScheme}.nix;
mkLightColorAssignment = key: {${key} = lightDefs.${key};};
mkDarkColorAssignment = key: {${key} = darkDefs.${key};};
in
mkIf cfg.enable {
# This module sets its own options
# to the values specified in a colorscheme file.
modules.color.light = lib.pipe colorKeys [
(builtins.map mkLightColorAssignment)
lib.mergeAttrsList
];
modules.color.dark = lib.pipe colorKeys [
(builtins.map mkDarkColorAssignment)
lib.mergeAttrsList
];
};
}

View File

@ -0,0 +1,58 @@
{
lib,
mylib,
colorKeys,
...
}:
with lib;
with mylib.modules; let
mkColorOption = key: {
light.${key} = mkOption {
type = types.str;
description = "The RGB hex color value for ${key} in the light scheme";
example = "EEEEEE";
};
dark.${key} = mkOption {
type = types.str;
description = "The RGB hex color value for ${key} in the dark scheme";
example = "111111";
};
};
in
(lib.pipe colorKeys [
(builtins.map mkColorOption)
lib.mergeAttrsList
])
// {
enable = mkEnableOption "Enable color schemes";
lightScheme = mkOption {
type = types.str;
description = "The color scheme to use for light colors";
example = "catppuccin-latte";
default = "catppuccin-latte";
};
darkScheme = mkOption {
type = types.str;
description = "The color scheme to use for dark colors";
example = "catppuccin-mocha";
default = "catppuccin-mocha";
};
keys = mkOption {
type = types.listOf types.str;
description = "The names of all possible colors";
default = colorKeys;
};
light = mkOption {
type = types.attrs;
description = "Colors belonging to the selected light scheme";
};
dark = mkOption {
type = types.attrs;
description = "Colors belonging to the selected dark scheme";
};
}

View File

@ -4,6 +4,7 @@
# My own HM modules
./chromium
./color
./firefox
./fish
./hyprland

View File

@ -62,6 +62,7 @@ with mylib.modules; {
"kitty"
]
'';
default = [];
};
delayed = mkOption {

View File

@ -518,24 +518,29 @@ in {
h = ["clang-format"];
cpp = ["clang-format"];
hpp = ["clang-format"];
css = [["prettierd" "prettier"]];
html = [["prettierd" "prettier"]];
css = ["prettierd" "prettier"];
html = ["prettierd" "prettier"];
java = ["google-java-format"];
javascript = [["prettierd" "prettier"]];
javascript = ["prettierd" "prettier"];
lua = ["stylua"];
markdown = [["prettierd" "prettier"]];
markdown = ["prettierd" "prettier"];
nix = ["alejandra"];
python = ["black"];
rust = ["rustfmt"];
};
default_format_opts = {
lsp_format = "fallback";
stop_after_first = true;
};
format_on_save.__raw = ''
function(bufnr)
-- Disable with a global or buffer-local variable
if vim.g.disable_autoformat then
return
end
return { timeout_ms = 500, lsp_fallback = true }
return { timeout_ms = 500, lsp_format = "fallback", }
end
'';
};
@ -1734,6 +1739,25 @@ in {
height = 45;
winblend = 0;
};
# Hack to make toggleterm respect neotree:
# Open + close neotree once toggleterm is opened.
# Toggleterm will "glitch" when opening.
on_open.__raw = ''
function(...)
local name = vim.fn.bufname("neo-tree")
local winnr = vim.fn.bufwinnr(name)
if winnr ~= -1 then
vim.defer_fn(function()
local cmd = string.format("Neotree toggle")
vim.cmd(cmd)
vim.cmd(cmd)
vim.cmd("wincmd p")
end, 100)
end
end
'';
};
};

View File

@ -1,5 +1,3 @@
# TODO: Generate the config modularly, like with hyprland
# - It should especially be possible to set styling programatically, for themes
{
config,
lib,
@ -10,70 +8,162 @@
with lib;
with mylib.modules; let
cfg = config.modules.waybar;
hyprcfg = config.modules.hyprland;
in {
options.modules.waybar = import ./options.nix {inherit lib mylib;};
/*
config = let
# Taken from https://github.com/Ruixi-rebirth/flakes/blob/main/modules/programs/wayland/waybar/workspace-patch.nix
hyprctl = "${pkgs.hyprland}/bin/hyprctl";
workspaces-patch = pkgs.writeTextFile {
name = "waybar-hyprctl.diff";
text = ''
diff --git a/src/modules/wlr/workspace_manager.cpp b/src/modules/wlr/workspace_manager.cpp
index 6a496e6..a689be0 100644
--- a/src/modules/wlr/workspace_manager.cpp
+++ b/src/modules/wlr/workspace_manager.cpp
@@ -511,7 +511,9 @@ auto Workspace::handle_clicked(GdkEventButton *bt) -> bool {
if (action.empty())
return true;
else if (action == "activate") {
- zext_workspace_handle_v1_activate(workspace_handle_);
+ // zext_workspace_handle_v1_activate(workspace_handle_);
+ const std::string command = "${hyprctl} dispatch workspace " + name_;
+ system(command.c_str());
} else if (action == "close") {
zext_workspace_handle_v1_remove(workspace_handle_);
} else {
'';
};
waybar-hyprland = pkgs.waybar.overrideAttrs (oldAttrs: {
mesonFlags = oldAttrs.mesonFlags ++ ["-Dexperimental=true"];
patches = (oldAttrs.patches or []) ++ [workspaces-patch];
});
in
*/
config = mkIf cfg.enable {
programs.waybar = {
enable = true;
# package = waybar-hyprland;
package = pkgs.waybar;
systemd.enable = true;
systemd = {
enable = false; # Gets started by hyprland
settings = {
mainBar = {
layer = "top";
position = "top";
height = 40;
spacing = 4;
output = ["${cfg.monitor}"];
modules-left = ["custom/launcher" "user" "hyprland/window"];
modules-center = ["hyprland/workspaces"];
modules-right = ["pulseaudio" "network" "cpu" "memory" "temperature" "clock" "tray"];
"custom/launcher" = {
format = "<span font='FontAwesome'></span> ";
interval = "once";
tooltip = false;
};
"hyprland/workspaces" = {
all-outputs = false;
format = "{name}";
on-click = "activate";
sort-by-coordinates = false;
sort-by-name = true;
sort-by-number = false;
};
"pulseaudio" = {
format = "<span font='FontAwesome'></span> {volume}%";
format-muted = "<span font='FontAwesome'></span> ";
on-click = "kitty ncpamixer -t o";
};
"network" = {
format = "<span font='FontAwesome'></span> {ipaddr}";
format-disconnected = "<span font='FontAwesome'></span> ";
interface = "enp8s0";
tooltip-format = "{ifname} via {gwaddr}";
};
cpu = {
format = "<span font='FontAwesome'></span> {load}%";
};
memory = {
format = "<span font='FontAwesome'></span> {percentage}%";
};
temperature = {
format = "<span font='FontAwesome'></span> {temperatureC}°C";
thermal-zone = 3;
};
clock = {
format = "<span font='FontAwesome'></span> {:%H:%M}";
timezone = "Europe/Berlin";
tooltip-format = "<tt><small>{calendar}</small></tt>";
};
tray = {
icon-size = 20;
show-passive-items = true;
spacing = 5;
};
};
};
modules.hyprland.autostart.immediate = let
waybar-reload = pkgs.writeScript "waybar-reload" ''
#! ${pkgs.bash}/bin/bash
style =
(builtins.readFile ./colors/${hyprcfg.theme}.css)
+ ''
/*Order is Top-Right-Bottom-Left for combined properties*/
window#waybar {
font-family: JetBrainsMono Nerd Font Mono;
font-weight: bold;
color: @base;
background-color: rgba(239, 241, 245, 0.6);
}
trap "${pkgs.procps}/bin/pkill waybar" EXIT
/*Square Widgets*/
#custom-launcher,
#workspaces button,
#tray {
padding: 0px 10px 0px 10px;
margin: 5px 5px 5px 5px;
border-radius: 6px;
color: @base;
}
while true; do
${pkgs.waybar}/bin/waybar -c $HOME/NixFlake/config/waybar/config.json -s $HOME/NixFlake/config/waybar/style.css &
${pkgs.inotifyTools}/bin/inotifywait -e create,modify $HOME/NixFlake/config/waybar/config.json $HOME/NixFlake/config/waybar/style.css
${pkgs.procps}/bin/pkill waybar
done
'';
in [
"${waybar-reload}"
];
#workspaces button:hover {
color: @pink;
}
home.file.".config/waybar/monitor.json".text = ''
{
"output": "${cfg.monitor}"
/*Tux Icon*/
#custom-launcher {
font-size: 18px;
padding-right: 0px;
}
/*Rectangle Widgets*/
#user,
#window,
#pulseaudio,
#network,
#cpu,
#memory,
#temperature,
#clock {
padding: 0px 10px 0px 10px;
margin: 8px 5px 8px 5px;
border-radius: 6px;
}
/*Colors*/
#custom-launcher {
background-color: @flamingo;
}
#user {
background-color: @pink;
}
#window {
background-color: @mauve;
}
#workspaces button {
background-color: @red;
}
#pulseaudio {
background-color: @maroon;
}
#network {
background-color: @peach;
}
#cpu {
background-color: @yellow;
}
#memory {
background-color: @green;
}
#temperature {
background-color: @teal;
}
#clock {
background-color: @sky;
}
#tray {
background-color: @sapphire;
}
'';
};
};
}