From 2ea60f205cd4aa6a94d6e8624b0cf98eda6ac762 Mon Sep 17 00:00:00 2001 From: Evie Litherland-Smith Date: Mon, 10 Jul 2023 11:24:42 +0100 Subject: [PATCH] Nix-ify waybar config --- flake.nix | 17 +-- home/desktop/hyprland.nix | 2 +- home/desktop/waybar.nix | 41 ------- home/desktop/waybar/default.nix | 11 ++ home/desktop/waybar/laptop.nix | 42 +++++++ home/desktop/waybar/main.nix | 41 +++++++ home/desktop/waybar/modules.nix | 188 +++++++++++++++++++++++++++++++ home/desktop/waybar/style.css | 151 +++++++++++++++++++++++++ home/desktop/waybar/vertical.nix | 20 ++++ 9 files changed, 460 insertions(+), 53 deletions(-) delete mode 100644 home/desktop/waybar.nix create mode 100644 home/desktop/waybar/default.nix create mode 100644 home/desktop/waybar/laptop.nix create mode 100644 home/desktop/waybar/main.nix create mode 100644 home/desktop/waybar/modules.nix create mode 100644 home/desktop/waybar/style.css create mode 100644 home/desktop/waybar/vertical.nix diff --git a/flake.nix b/flake.nix index d83113eb..e25ddb5e 100644 --- a/flake.nix +++ b/flake.nix @@ -163,6 +163,9 @@ hyprland.homeManagerModules.default ./home/work.nix ./home/desktop/hyprland.nix + ./home/desktop/waybar/main.nix + ./home/desktop/waybar/laptop.nix + ./home/desktop/waybar/vertical.nix ./home/gui ]; home = { @@ -172,17 +175,9 @@ }; programs.neovim.package = pkgs.neovim-nightly; programs.waybar.settings = { - main."output" = "eDP-1"; - ext = { - "include" = [ - "~/.config/waybar/modules.json" - "~/.config/waybar/layout.json" - ]; - "output" = "!eDP-1"; - "modules-left" = ["clock" "cpu" "memory" "temperature"]; - "modules-center" = ["wlr/workspaces"]; - "modules-right" = ["pulseaudio" "bluetooth" "network#compact" "battery" "tray"]; - }; + main."output" = "desc:Iiyama North America PLB2403WS 0574281251316"; + laptop."output" = "eDP-1"; + vertical."output" = "desc:Dell Inc. DELL U2417H 5K9YD872FY1L"; }; xdg.configFile."hypr/hyprpaper.conf".text = '' preload = ${wallpapers.outputs.default} diff --git a/home/desktop/hyprland.nix b/home/desktop/hyprland.nix index 0766c604..883574dd 100644 --- a/home/desktop/hyprland.nix +++ b/home/desktop/hyprland.nix @@ -24,8 +24,8 @@ }; in { imports = [ + ./waybar ./swaylock.nix - ./waybar.nix ./gtk.nix ./dunst.nix ./rofi.nix diff --git a/home/desktop/waybar.nix b/home/desktop/waybar.nix deleted file mode 100644 index 89523fc7..00000000 --- a/home/desktop/waybar.nix +++ /dev/null @@ -1,41 +0,0 @@ -{ - pkgs, - lib, - ... -}: { - home.packages = with pkgs; [ - (nerdfonts.override {fonts = ["FiraCode"];}) - networkmanagerapplet - bluez - ]; - xdg.configFile."waybar" = { - source = ./config/waybar; - recursive = true; - }; - programs.waybar = { - enable = true; - settings.main = { - "include" = [ - "~/.config/waybar/modules.json" - "~/.config/waybar/layout.json" - ]; - "modules-left" = lib.mkDefault [ - "clock" - "cpu" - "memory" - "temperature" - ]; - "modules-center" = lib.mkDefault [ - "wlr/workspaces" - ]; - "modules-right" = lib.mkDefault [ - "pulseaudio" - "bluetooth" - "network#compact" - "backlight" - "battery" - "tray" - ]; - }; - }; -} diff --git a/home/desktop/waybar/default.nix b/home/desktop/waybar/default.nix new file mode 100644 index 00000000..187aeffa --- /dev/null +++ b/home/desktop/waybar/default.nix @@ -0,0 +1,11 @@ +{pkgs, ...}: { + home.packages = with pkgs; [ + (nerdfonts.override {fonts = ["FiraCode"];}) + networkmanagerapplet + bluez + ]; + programs.waybar = { + enable = true; + style = ./style.css; + }; +} diff --git a/home/desktop/waybar/laptop.nix b/home/desktop/waybar/laptop.nix new file mode 100644 index 00000000..a70b7973 --- /dev/null +++ b/home/desktop/waybar/laptop.nix @@ -0,0 +1,42 @@ +{...}: let + modules = import ./modules.nix; +in { + imports = [./default.nix]; + programs.waybar.settings.laptop = { + layer = "top"; + position = "top"; + spacing = 10; + margin-top = 10; + margin-left = 20; + margin-right = 20; + margin-bottom = 5; + "modules-left" = [ + "clock#compact" + "cpu" + "memory" + "temperature" + ]; + "modules-center" = [ + "wlr/workspaces" + ]; + "modules-right" = [ + "pulseaudio" + "bluetooth" + "network#compact" + "backlight" + "battery" + "tray" + ]; + "clock#compact" = modules."clock#compact"; + cpu = modules.cpu; + memory = modules.memory; + temperature = modules.temperature; + "wlr/workspaces" = modules."wlr/workspaces"; + pulseaudio = modules.pulseaudio; + bluetooth = modules.bluetooth; + "network#compact" = modules."network#compact"; + backlight = modules.backlight; + battery = modules.battery; + tray = modules.tray; + }; +} diff --git a/home/desktop/waybar/main.nix b/home/desktop/waybar/main.nix new file mode 100644 index 00000000..81531700 --- /dev/null +++ b/home/desktop/waybar/main.nix @@ -0,0 +1,41 @@ +{...}: let + modules = import ./modules.nix; +in { + imports = [./default.nix]; + programs.waybar.settings.main = { + layer = "top"; + position = "top"; + spacing = 10; + margin-top = 10; + margin-left = 20; + margin-right = 20; + margin-bottom = 5; + "modules-left" = [ + "clock" + "cpu" + "memory" + "temperature" + ]; + "modules-center" = [ + "wlr/workspaces" + ]; + "modules-right" = [ + "pulseaudio" + "bluetooth" + "network" + "battery" + "tray" + ]; + clock = modules.clock; + cpu = modules.cpu; + memory = modules.memory; + temperature = modules.temperature; + "wlr/workspaces" = modules."wlr/workspaces"; + pulseaudio = modules.pulseaudio; + bluetooth = modules.bluetooth; + network = modules.network; + backlight = modules.backlight; + battery = modules.battery; + tray = modules.tray; + }; +} diff --git a/home/desktop/waybar/modules.nix b/home/desktop/waybar/modules.nix new file mode 100644 index 00000000..157af43d --- /dev/null +++ b/home/desktop/waybar/modules.nix @@ -0,0 +1,188 @@ +{ + keyboard-state = { + numlock = true; + capslock = true; + format = "{name} {icon}"; + format-icons = { + locked = ""; + unlocked = ""; + }; + }; + tray.spacing = 10; + clock = { + format = "{:%A %Y-%m-%d 󰃭 | %R 󰅐 }"; + tooltip-format = "{calendar}"; + calendar = { + mode = "year"; + mode-mon-col = 3; + weeks-pos = "right"; + on-scroll = 1; + on-click-right = "mode"; + format = { + months = "{}"; + days = "{}"; + weeks = "W{}"; + weekdays = "{}"; + today = "{}"; + }; + }; + actions = { + on-click-right = "mode"; + on-click-forward = "tz_up"; + on-click-backward = "tz_down"; + on-scroll-up = "shift_up"; + on-scroll-down = "shift_down"; + }; + }; + "clock#compact" = { + format = "{:%R 󰅐 }"; + tooltip-format = "{:%A %Y-%m-%d 󰃭 }"; + }; + cpu = { + format = "{usage}% 󰻠"; + tooltip = false; + }; + memory.format = "{}% 󰍛"; + temperature = { + critical-threshold = 80; + format = "{temperatureC}°C {icon}"; + format-icons = [ + "󱃃" + "󰔏" + "󱃂" + ]; + }; + backlight = { + format = "{percent}% {icon}"; + format-icons = [ + "" + "" + "" + "" + "" + "" + "" + "" + "" + ]; + }; + battery = { + states = { + warning = 30; + critical = 15; + }; + format = "{capacity}% {icon}"; + format-charging = "{capacity}% 󰂄"; + format-plugged = "{capacity}% 󰚥"; + format-alt = "{time} {icon}"; + format-icons = [ + "󱃍" + "󰁺" + "󰁻" + "󰁼" + "󰁽" + "󰁾" + "󰁿" + "󰂀" + "󰂁" + "󰂂" + "󰁹" + ]; + }; + network = { + format-wifi = "{essid} ({signalStrength}%) 󰖩"; + format-ethernet = "Connected 󰈁"; + tooltip-format = "{ifname}"; + format-linked = "{ifname} (No IP) 󰈁"; + format-disconnected = "Disconnected 󰈂"; + format-alt = "{ifname}: {ipaddr}/{cidr}"; + on-click = "nm-connection-editor"; + }; + "network#compact" = { + format-wifi = "({signalStrength}%) 󰖩"; + format-ethernet = "󰈁"; + tooltip-format = "{essid}"; + format-linked = "(No IP) 󰈁"; + format-disconnected = "󰈂"; + on-click = "nm-connection-editor"; + }; + bluetooth = { + format = "󰂯 {status}"; + format-disabled = "󰂲 {status}"; + format-off = "󰂲 {status}"; + format-on = "󰂯 {status}"; + format-connected = "󰂱 {device_alias}"; + on-click = "blueman-manager"; + }; + pulseaudio = { + scroll-step = 5; + format = "{volume}% {icon} {format_source}"; + format-bluetooth = "{volume}% {icon} {format_source}"; + format-bluetooth-muted = "󰝟 {icon} {format_source}"; + format-muted = "󰝟 {format_source}"; + format-source = "{volume}% 󰍬"; + format-source-muted = "󰍭"; + format-icons = { + headphone = "󰋋"; + hands-free = "󰥰"; + headset = "󰋎"; + phone = "󰏲"; + portable = "󰏳"; + car = "󰄍"; + default = [ + "󰕿" + "󰖀" + "󰕾" + ]; + }; + on-click = "pavucontrol"; + }; + "pulseaudio#compact" = { + scroll-step = 5; + format = "{icon} {format_source}"; + format-bluetooth = "{icon} {format_source}"; + format-bluetooth-muted = "󰝟 {icon} {format_source}"; + format-muted = "󰝟 {format_source}"; + format-source = "󰍬"; + format-source-muted = "󰍭"; + format-icons = { + headphone = "󰋋"; + hands-free = "󰥰"; + headset = "󰋎"; + phone = "󰏲"; + portable = "󰏳"; + car = "󰄍"; + default = [ + "󰕿" + "󰖀" + "󰕾" + ]; + }; + on-click = "pavucontrol"; + }; + "custom/power" = { + format = "󰐥"; + on-click = "powermenu"; + }; + "wlr/workspaces" = { + on-click = "activate"; + disable-scroll = true; + all-outputs = true; + format = "{icon}"; + format-icons = { + "1" = "󰟀"; + "2" = "󰅴"; + "3" = "󰈹"; + "4" = "󰝰"; + "5" = "󰭹"; + "6" = ""; + "7" = "󰓓"; + "8" = "󰣙"; + urgent = ""; + default = "󰣘"; + }; + sort-by-name = true; + sort-by-coordinates = false; + sort-by-number = false; + }; +} diff --git a/home/desktop/waybar/style.css b/home/desktop/waybar/style.css new file mode 100644 index 00000000..818bb04e --- /dev/null +++ b/home/desktop/waybar/style.css @@ -0,0 +1,151 @@ +@define-color base #24273a; +@define-color mantle #1e2030; +@define-color crust #181926; + +@define-color text #cad3f5; +@define-color subtext0 #a5adcb; +@define-color subtext1 #b8c0e0; + +@define-color surface0 #363a4f; +@define-color surface1 #494d64; +@define-color surface2 #5b6078; + +@define-color overlay0 #6e738d; +@define-color overlay1 #8087a2; +@define-color overlay2 #939ab7; + +@define-color blue #8aadf4; +@define-color lavender #b7bdf8; +@define-color sapphire #7dc4e4; +@define-color sky #91d7e3; +@define-color teal #8bd5ca; +@define-color green #a6da95; +@define-color yellow #eed49f; +@define-color peach #f5a97f; +@define-color maroon #ee99a0; +@define-color red #ed8796; +@define-color mauve #c6a0f6; +@define-color pink #f5bde6; +@define-color flamingo #f0c6c6; +@define-color rosewater #f4dbd6; + +* { + border: none; + border-radius: 10px; + font-family: "FiraCode Nerd Font"; + font-size: 18px; +} + +window#waybar { + background: transparent; +} +window#waybar.hidden { + opacity: 0.2; +} +#window { + margin-top: 6px; + padding-left: 10px; + padding-right: 10px; + border-radius: 10px; + transition: none; + color: transparent; + background: transparent; +} + +#workspaces button { + transition: none; + color: @overlay0; + box-shadow: inset 0 -3px transparent; + border-radius: 2px; +} +#workspaces button.active, +#workspaces button.focused { + color: @base; +} +#workspaces button:hover { + transition: none; + box-shadow: inherit; + text-shadow: inherit; + color: @base; + border-color: #e8a2af; + color: @base; +} +#workspaces button.focused:hover { + color: @base; +} + +/* left section */ +#clock, +#cpu, +#memory, +#temperature, +/* centre section */ +#workspaces, +/* right section */ +#pulseaudio, +#bluetooth, +#network, +#backlight, +#battery, +#tray { + margin-top: 0px; + margin-bottom: 0px; + margin-left: 0px; + margin-right: 0px; + padding-left: 10px; + padding-right: 10px; + transition: none; + color: @crust; + background: @lavender; +} + +#clock { + background: @lavender; +} +#cpu { + background: @pink; +} +#memory { + background: @mauve; +} +#temperature { + background: @red; +} +#workspaces { + background: @yellow; +} +#pulseaudio { + background: @green; +} +#bluetooth { + background: @teal; +} +#network { + background: @sky; +} +#backlight { + background: @sapphire; +} +#battery { + background: @blue; +} +#battery.charging, +#battery.plugged { + background-color: @blue; +} +#battery.critical:not(.charging) { + background-color: @blue; + animation-name: blink; + animation-duration: 0.5s; + animation-timing-function: linear; + animation-iteration-count: infinite; + animation-direction: alternate; +} +@keyframes blink { +to { + color: @red; +} +} +#tray { + color: @base; +} diff --git a/home/desktop/waybar/vertical.nix b/home/desktop/waybar/vertical.nix new file mode 100644 index 00000000..fde19d31 --- /dev/null +++ b/home/desktop/waybar/vertical.nix @@ -0,0 +1,20 @@ +{...}: let + modules = import ./modules.nix; +in { + imports = [./default.nix]; + programs.waybar.settings = { + vertical = { + layer = "top"; + position = "top"; + spacing = 10; + margin-top = 10; + margin-left = 20; + margin-right = 20; + margin-bottom = 5; + "modules-left" = []; + "modules-center" = ["wlr/workspaces"]; + "modules-right" = []; + "wlr/workspaces" = modules."wlr/workspaces"; + }; + }; +}