From 4705a3b2482ce0733b50702c4f54fe8a5506bca9 Mon Sep 17 00:00:00 2001 From: Nydragon Date: Fri, 17 May 2024 03:24:58 +0900 Subject: [PATCH] waybar: add waybar to config --- home/sway/default.nix | 1 + home/sway/waybar/config.nix | 186 +++++++++++++++++++++++++++++++++++ home/sway/waybar/default.nix | 9 ++ home/sway/waybar/style.nix | 172 ++++++++++++++++++++++++++++++++ 4 files changed, 368 insertions(+) create mode 100644 home/sway/waybar/config.nix create mode 100644 home/sway/waybar/default.nix create mode 100644 home/sway/waybar/style.nix diff --git a/home/sway/default.nix b/home/sway/default.nix index 71d7429..6b70eba 100644 --- a/home/sway/default.nix +++ b/home/sway/default.nix @@ -9,6 +9,7 @@ imports = [ ./swayidle.nix ./swaylock.nix + ./waybar ]; wayland.windowManager.sway = diff --git a/home/sway/waybar/config.nix b/home/sway/waybar/config.nix new file mode 100644 index 0000000..421f618 --- /dev/null +++ b/home/sway/waybar/config.nix @@ -0,0 +1,186 @@ +{ + modules-left = [ + "tray" + "privacy" + "clock" + "sway/mode" + ]; + modules-center = [ "sway/workspaces" ]; + modules-right = [ + "backlight" + "pulseaudio" + "network" + "group/hardware" + "idle_inhibitor" + "custom/notification" + ]; + backlight = { + format = "{}% "; + interval = 1; + on-scroll-down = "brightnessctl s 10%-"; + on-scroll-up = "brightnessctl s +10%"; + tooltip = false; + }; + battery = { + format = "{icon} {capacity}%"; + format-charging = " {capacity}%"; + format-icons = [ + "" + "" + "" + "" + "" + ]; + format-plugged = " {capacity}%"; + states = { + critical = 20; + good = 95; + warning = 30; + }; + }; + clock = { + actions = { + on-click-backward = "tz_down"; + on-click-forward = "tz_up"; + on-click-right = "mode"; + on-scroll-down = "shift_down"; + on-scroll-up = "shift_up"; + }; + calendar = { + format = { + days = "{}"; + months = "{}"; + today = "{}"; + weekdays = "{}"; + weeks = "W{}"; + }; + mode = "year"; + mode-mon-col = 3; + on-click-right = "mode"; + on-scroll = 1; + weeks-pos = "right"; + }; + format = "{:%H:%M}"; + format-alt = "{:%A, %B %d, %Y (%R)}  "; + tooltip-format = "{calendar}"; + }; + cpu = { + format = " {}%"; + interval = 15; + max-length = 10; + }; + "custom/notification" = { + c-on-click-right = "swaync-client -d -sw"; + escape = true; + exec = "swaync-client -swb"; + exec-if = "which swaync-client"; + format = "{icon}"; + format-icons = + let + dot = ""; + in + { + dnd-inhibited-none = ""; + dnd-inhibited-notification = "${dot}"; + dnd-none = ""; + dnd-notification = "${dot}"; + inhibited-none = ""; + inhibited-notification = "${dot}"; + none = ""; + notification = "${dot}"; + }; + on-click = "sh -c 'sleep 0.1s; swaync-client -t -sw; sleep 0.1s'"; + return-type = "json"; + tooltip = false; + }; + "group/hardware" = { + drawer = { + transition-left-to-right = false; + }; + modules = [ + "battery" + "cpu" + "memory" + ]; + orientation = "horizontal"; + }; + idle_inhibitor = { + format = "{icon} "; + format-icons = { + activated = ""; + deactivated = ""; + }; + }; + layer = "bottom"; + memory = { + format = " {}%"; + interval = 30; + max-length = 10; + }; + + network = { + format-wifi = "{essid} ({signalStrength}%) "; + on-click = "alacritty -t nmtui -e nmtui"; + }; + position = "top"; + privacy = { + icon-size = 18; + icon-spacing = 4; + modules = [ + { + tooltip = true; + tooltip-icon-size = 24; + type = "screenshare"; + } + { + tooltip = true; + tooltip-icon-size = 24; + type = "audio-out"; + } + { + tooltip = true; + tooltip-icon-size = 24; + type = "audio-in"; + } + ]; + transition-duration = 250; + }; + pulseaudio = { + format = "{volume}% {icon} {format_source}"; + format-bluetooth = "{volume}% {icon} {format_source}"; + format-bluetooth-muted = " {icon} {format_source}"; + format-icons = { + car = ""; + default = [ + "奄" + "奔" + "墳" + ]; + hands-free = ""; + headphone = ""; + headset = ""; + phone = ""; + portable = ""; + }; + format-muted = "婢 {format_source}"; + format-source = "{volume}% "; + format-source-muted = ""; + on-click = "pavucontrol"; + scroll-step = 1; + tooltip = false; + }; + "sway/mode" = { + format = "{}"; + max-length = 50; + }; + "sway/workspaces" = { + all-outputs = true; + disable-scroll = true; + format = "{name}"; + }; + tray = { + icon-size = 18; + show-passive-items = false; + spacing = 10; + }; +} diff --git a/home/sway/waybar/default.nix b/home/sway/waybar/default.nix new file mode 100644 index 0000000..76437ee --- /dev/null +++ b/home/sway/waybar/default.nix @@ -0,0 +1,9 @@ +{ pkgs, ... }: +{ + programs.waybar = { + enable = true; + settings = { + main = import ./config.nix; + }; + }; +} diff --git a/home/sway/waybar/style.nix b/home/sway/waybar/style.nix new file mode 100644 index 0000000..a5b20b7 --- /dev/null +++ b/home/sway/waybar/style.nix @@ -0,0 +1,172 @@ +'' + * { + font-family: "DejaVuSansMNerdFont-Regular"; + border: none; + opacity: 50; + border-radius: 10px; + font-size: 13px; } + + window#waybar { + background: transparent; } + + window#waybar.hidden { + opacity: 0.2; } + + #window { + padding-left: 10px; + padding-right: 10px; + border-radius: 10px; + transition: none; + color: transparent; + background: transparent; } + + .modules-center { + margin: 3px 0 0 0; } + + .modules-right { + margin: 3px 8px 0 0; } + + .modules-left { + margin: 3px 0 0 8px; } + + #workspaces { + background-color: rgba(13, 214, 250, 0.4); } + #workspaces button { + padding: 1px 5px; } + #workspaces button:hover { + background-color: rgba(159, 255, 255, 0.9); } + #workspaces button.focused { + background-color: rgba(50, 194, 219, 0.7); } + + #network { + margin-left: 4px; + margin-right: 4px; + border-radius: 10px; + padding-left: 10px; + padding-right: 10px; + color: #161320; + background: #bd93f9; } + + #pulseaudio { + margin-left: 4px; + margin-right: 4px; + border-radius: 10px; + padding-left: 10px; + padding-right: 10px; + min-width: 23px; + color: #1a1826; + background: #fae3b0; } + + #backlight { + margin-left: 4px; + margin-right: 4px; + border-radius: 10px; + padding-left: 10px; + padding-right: 10px; + color: #161320; + background: #f8bd96; } + + #clock { + margin-left: 4px; + margin-right: 4px; + border-radius: 10px; + padding-left: 10px; + padding-right: 10px; + color: #161320; + background: #abe9b3; } + + #memory { + margin-left: 4px; + margin-right: 4px; + border-radius: 10px; + padding-left: 10px; + padding-right: 10px; + color: #161320; + background: #ddb6f2; } + + #privacy { + margin-left: 4px; + margin-right: 4px; + border-radius: 10px; + padding-left: 10px; + padding-right: 10px; + color: #161320; + background: #ddb6f2; } + + #cpu { + margin-left: 4px; + margin-right: 4px; + border-radius: 10px; + padding-left: 10px; + padding-right: 10px; + color: #161320; + background: #96cdfb; } + + #tray { + padding-left: 10px; + margin-right: 4px; + padding-right: 10px; + border-radius: 10px; + color: #b5e8e0; + background: #161320; } + + #idle_inhibitor { + margin-left: 4px; + margin-right: 4px; + border-radius: 10px; + padding-left: 10px; + padding-right: 10px; + font-size: 20px; + color: #161320; + background: #f28fad; } + + #group-power { + margin-left: 4px; + margin-right: 4px; + border-radius: 10px; + padding-left: 10px; + padding-right: 10px; + font-size: 20px; + transition: none; + color: #161320; + background: #f28fad; } + + #custom-notification { + margin-left: 4px; + padding-left: 10px; + padding-right: 10px; + border-radius: 10px; + color: #161320; + background: #f2cdcd; + font-family: "NotoSansMono Nerd Font"; } + + #mode { + margin-left: 4px; + margin-right: 4px; + border-radius: 10px; + padding-left: 10px; + padding-right: 10px; + color: #161320; + background: #ddb6f2; } + + @keyframes blink { + to { + background-color: #bf616a; + color: #b5e8e0; } } + + #battery { + margin-left: 4px; + margin-right: 4px; + border-radius: 10px; + padding-left: 10px; + padding-right: 10px; + color: #161320; + background: #b5e8e0; } + #battery .critical:not(.charging) { + animation-name: blink; + animation-duration: 0.5s; + animation-timing-function: linear; + animation-iteration-count: infinite; + animation-direction: alternate; } + +''