From 733d86c75966377e5c3cb8bab525f45ef9daba9c Mon Sep 17 00:00:00 2001 From: Evie Litherland-Smith Date: Mon, 10 Jul 2023 16:09:25 +0100 Subject: [PATCH] Move waybar modules into importable nix expressions --- home/desktop/waybar/laptop.nix | 26 +- home/desktop/waybar/main.nix | 26 +- home/desktop/waybar/modules.nix | 232 ------------------ home/desktop/waybar/modules/backlight.nix | 5 + .../waybar/modules/battery.compact.nix | 11 + home/desktop/waybar/modules/battery.nix | 10 + .../waybar/modules/bluetooth.compact.nix | 9 + home/desktop/waybar/modules/bluetooth.nix | 8 + home/desktop/waybar/modules/clock.compact.nix | 19 ++ home/desktop/waybar/modules/clock.nix | 25 ++ home/desktop/waybar/modules/cpu.nix | 4 + .../desktop/waybar/modules/keyboard-state.nix | 9 + home/desktop/waybar/modules/memory.nix | 1 + .../waybar/modules/network.compact.nix | 8 + home/desktop/waybar/modules/network.nix | 8 + .../waybar/modules/pulseaudio.compact.nix | 23 ++ home/desktop/waybar/modules/pulseaudio.nix | 19 ++ home/desktop/waybar/modules/temperature.nix | 5 + home/desktop/waybar/modules/tray.nix | 1 + .../desktop/waybar/modules/wlr_workspaces.nix | 19 ++ home/desktop/waybar/vertical.nix | 10 +- 21 files changed, 212 insertions(+), 266 deletions(-) delete mode 100644 home/desktop/waybar/modules.nix create mode 100644 home/desktop/waybar/modules/backlight.nix create mode 100644 home/desktop/waybar/modules/battery.compact.nix create mode 100644 home/desktop/waybar/modules/battery.nix create mode 100644 home/desktop/waybar/modules/bluetooth.compact.nix create mode 100644 home/desktop/waybar/modules/bluetooth.nix create mode 100644 home/desktop/waybar/modules/clock.compact.nix create mode 100644 home/desktop/waybar/modules/clock.nix create mode 100644 home/desktop/waybar/modules/cpu.nix create mode 100644 home/desktop/waybar/modules/keyboard-state.nix create mode 100644 home/desktop/waybar/modules/memory.nix create mode 100644 home/desktop/waybar/modules/network.compact.nix create mode 100644 home/desktop/waybar/modules/network.nix create mode 100644 home/desktop/waybar/modules/pulseaudio.compact.nix create mode 100644 home/desktop/waybar/modules/pulseaudio.nix create mode 100644 home/desktop/waybar/modules/temperature.nix create mode 100644 home/desktop/waybar/modules/tray.nix create mode 100644 home/desktop/waybar/modules/wlr_workspaces.nix diff --git a/home/desktop/waybar/laptop.nix b/home/desktop/waybar/laptop.nix index b89d95bb..10e1b1d0 100644 --- a/home/desktop/waybar/laptop.nix +++ b/home/desktop/waybar/laptop.nix @@ -1,6 +1,4 @@ -{...}: let - modules = import ./modules.nix; -in { +{...}: { imports = [./default.nix]; programs.waybar.settings.laptop = { layer = "top"; @@ -27,16 +25,16 @@ in { "battery#compact" "tray" ]; - "clock#compact" = modules."clock#compact"; - cpu = modules.cpu; - memory = modules.memory; - temperature = modules.temperature; - "wlr/workspaces" = modules."wlr/workspaces"; - "pulseaudio#compact" = modules."pulseaudio#compact"; - "bluetooth#compact" = modules."bluetooth#compact"; - "network#compact" = modules."network#compact"; - backlight = modules.backlight; - "battery#compact" = modules."battery#compact"; - tray = modules.tray; + "clock#compact" = import ./modules/clock.compact.nix; + cpu = import ./modules/cpu.nix; + memory = import ./modules/memory.nix; + temperature = import ./modules/temperature.nix; + "wlr/workspaces" = import ./modules/wlr_workspaces.nix; + "pulseaudio#compact" = import ./modules/pulseaudio.compact.nix; + "bluetooth#compact" = import ./modules/bluetooth.compact.nix; + "network#compact" = import ./modules/network.compact.nix; + backlight = import ./modules/backlight.nix; + "battery#compact" = import ./modules/battery.compact.nix; + tray = import ./modules/tray.nix; }; } diff --git a/home/desktop/waybar/main.nix b/home/desktop/waybar/main.nix index c65ec2c5..80b70d79 100644 --- a/home/desktop/waybar/main.nix +++ b/home/desktop/waybar/main.nix @@ -1,6 +1,4 @@ -{...}: let - modules = import ./modules.nix; -in { +{...}: { imports = [./default.nix]; programs.waybar.settings.main = { layer = "top"; @@ -26,16 +24,16 @@ in { "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; + clock = import ./modules/clock.nix; + cpu = import ./modules/cpu.nix; + memory = import ./modules/memory.nix; + temperature = import ./modules/temperature.nix; + "wlr/workspaces" = import ./modules/wlr_workspaces.nix; + pulseaudio = import ./modules/pulseaudio.nix; + bluetooth = import ./modules/bluetooth.nix; + network = import ./modules/network.nix; + backlight = import ./modules/backlight.nix; + battery = import ./modules/battery.nix; + tray = import ./modules/tray.nix; }; } diff --git a/home/desktop/waybar/modules.nix b/home/desktop/waybar/modules.nix deleted file mode 100644 index 0ef7e52b..00000000 --- a/home/desktop/waybar/modules.nix +++ /dev/null @@ -1,232 +0,0 @@ -{ - 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 󰅐 }"; - format-alt = "{:%A %Y-%m-%d 󰃭 }"; - 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 = "{}"; - }; - }; - }; - cpu = { - format = "{usage}% 󰻠"; - tooltip = false; - }; - memory.format = "{}% 󰍛"; - temperature = { - critical-threshold = 80; - format = "{temperatureC}°C {icon}"; - format-icons = [ - "󱃃" - "󰔏" - "󱃂" - ]; - }; - backlight = { - format = "{icon}"; - tooltip-format = "{percent}%"; - format-icons = [ - "" - "" - "" - "" - "" - "" - "" - "" - "" - ]; - }; - battery = { - states = { - warning = 30; - critical = 15; - }; - format = "{time} {capacity}% {icon}"; - format-charging = "{time} {capacity}% 󰂄"; - format-plugged = "{capacity}% 󰚥"; - format-icons = [ - "󱃍" - "󰁺" - "󰁻" - "󰁼" - "󰁽" - "󰁾" - "󰁿" - "󰂀" - "󰂁" - "󰂂" - "󰁹" - ]; - }; - "battery#compact" = { - states = { - warning = 30; - critical = 15; - }; - format = "{icon}"; - format-charging = "󰂄"; - format-plugged = "󰚥"; - tooltip-format = "{time} {capacity}%"; - format-icons = [ - "󱃍" - "󰁺" - "󰁻" - "󰁼" - "󰁽" - "󰁾" - "󰁿" - "󰂀" - "󰂁" - "󰂂" - "󰁹" - ]; - }; - network = { - format-wifi = "{essid} ({signalStrength}%) 󰖩"; - format-ethernet = "Connected 󰈁"; - tooltip-format = "{ifname}"; - format-linked = "{ifname} (No IP) 󰈁"; - format-disconnected = "Disconnected 󰈂"; - 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"; - }; - "bluetooth#compact" = { - format = "󰂯"; - format-disabled = "󰂲"; - format-off = "󰂲"; - format-on = "󰂯"; - format-connected = "󰂱"; - tooltip-format = "{status} | {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 = false; - format = "{icon}"; - format-icons = { - "1" = "󰟀"; - "2" = "󰅴"; - "3" = "󰈹"; - "4" = "󰝰"; - "5" = "󰭹"; - "6" = ""; - "7" = "󰓓"; - "8" = "󰣙"; - urgent = ""; - default = "󰣘"; - }; - sort-by-number = true; - }; -} diff --git a/home/desktop/waybar/modules/backlight.nix b/home/desktop/waybar/modules/backlight.nix new file mode 100644 index 00000000..9749fb13 --- /dev/null +++ b/home/desktop/waybar/modules/backlight.nix @@ -0,0 +1,5 @@ +{ + format = "{icon}"; + tooltip-format = "{percent}%"; + format-icons = ["" "" "" "" "" "" "" "" ""]; +} diff --git a/home/desktop/waybar/modules/battery.compact.nix b/home/desktop/waybar/modules/battery.compact.nix new file mode 100644 index 00000000..d3a8a067 --- /dev/null +++ b/home/desktop/waybar/modules/battery.compact.nix @@ -0,0 +1,11 @@ +{ + states = { + warning = 30; + critical = 15; + }; + format = "{icon}"; + format-charging = "󰂄"; + format-plugged = "󰚥"; + tooltip-format = "{time} {capacity}%"; + format-icons = ["󱃍" "󰁺" "󰁻" "󰁼" "󰁽" "󰁾" "󰁿" "󰂀" "󰂁" "󰂂" "󰁹"]; +} diff --git a/home/desktop/waybar/modules/battery.nix b/home/desktop/waybar/modules/battery.nix new file mode 100644 index 00000000..93e5ceed --- /dev/null +++ b/home/desktop/waybar/modules/battery.nix @@ -0,0 +1,10 @@ +{ + states = { + warning = 30; + critical = 15; + }; + format = "{time} {capacity}% {icon}"; + format-charging = "{time} {capacity}% 󰂄"; + format-plugged = "{capacity}% 󰚥"; + format-icons = ["󱃍" "󰁺" "󰁻" "󰁼" "󰁽" "󰁾" "󰁿" "󰂀" "󰂁" "󰂂" "󰁹"]; +} diff --git a/home/desktop/waybar/modules/bluetooth.compact.nix b/home/desktop/waybar/modules/bluetooth.compact.nix new file mode 100644 index 00000000..96d62dac --- /dev/null +++ b/home/desktop/waybar/modules/bluetooth.compact.nix @@ -0,0 +1,9 @@ +{ + format = "󰂯"; + format-disabled = "󰂲"; + format-off = "󰂲"; + format-on = "󰂯"; + format-connected = "󰂱"; + tooltip-format = "{status} | {device_alias}"; + on-click = "blueman-manager"; +} diff --git a/home/desktop/waybar/modules/bluetooth.nix b/home/desktop/waybar/modules/bluetooth.nix new file mode 100644 index 00000000..3690b969 --- /dev/null +++ b/home/desktop/waybar/modules/bluetooth.nix @@ -0,0 +1,8 @@ +{ + format = "󰂯 {status}"; + format-disabled = "󰂲 {status}"; + format-off = "󰂲 {status}"; + format-on = "󰂯 {status}"; + format-connected = "󰂱 {device_alias}"; + on-click = "blueman-manager"; +} diff --git a/home/desktop/waybar/modules/clock.compact.nix b/home/desktop/waybar/modules/clock.compact.nix new file mode 100644 index 00000000..934724a8 --- /dev/null +++ b/home/desktop/waybar/modules/clock.compact.nix @@ -0,0 +1,19 @@ +{ + format = "{:%R 󰅐 }"; + format-alt = "{:%A %Y-%m-%d 󰃭 }"; + 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 = "{}"; + }; + }; +} diff --git a/home/desktop/waybar/modules/clock.nix b/home/desktop/waybar/modules/clock.nix new file mode 100644 index 00000000..daae1ce5 --- /dev/null +++ b/home/desktop/waybar/modules/clock.nix @@ -0,0 +1,25 @@ +{ + 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"; + }; +} diff --git a/home/desktop/waybar/modules/cpu.nix b/home/desktop/waybar/modules/cpu.nix new file mode 100644 index 00000000..bf9d916d --- /dev/null +++ b/home/desktop/waybar/modules/cpu.nix @@ -0,0 +1,4 @@ +{ + format = "{usage}% 󰻠"; + tooltip = false; +} diff --git a/home/desktop/waybar/modules/keyboard-state.nix b/home/desktop/waybar/modules/keyboard-state.nix new file mode 100644 index 00000000..e3e329f4 --- /dev/null +++ b/home/desktop/waybar/modules/keyboard-state.nix @@ -0,0 +1,9 @@ +{ + numlock = true; + capslock = true; + format = "{name} {icon}"; + format-icons = { + locked = ""; + unlocked = ""; + }; +} diff --git a/home/desktop/waybar/modules/memory.nix b/home/desktop/waybar/modules/memory.nix new file mode 100644 index 00000000..724d71fe --- /dev/null +++ b/home/desktop/waybar/modules/memory.nix @@ -0,0 +1 @@ +{format = "{}% 󰍛";} diff --git a/home/desktop/waybar/modules/network.compact.nix b/home/desktop/waybar/modules/network.compact.nix new file mode 100644 index 00000000..7a33953c --- /dev/null +++ b/home/desktop/waybar/modules/network.compact.nix @@ -0,0 +1,8 @@ +{ + format-wifi = "({signalStrength}%) 󰖩"; + format-ethernet = "󰈁"; + tooltip-format = "{essid}"; + format-linked = "(No IP) 󰈁"; + format-disconnected = "󰈂"; + on-click = "nm-connection-editor"; +} diff --git a/home/desktop/waybar/modules/network.nix b/home/desktop/waybar/modules/network.nix new file mode 100644 index 00000000..89cdfdef --- /dev/null +++ b/home/desktop/waybar/modules/network.nix @@ -0,0 +1,8 @@ +{ + format-wifi = "{essid} ({signalStrength}%) 󰖩"; + format-ethernet = "Connected 󰈁"; + tooltip-format = "{ifname}"; + format-linked = "{ifname} (No IP) 󰈁"; + format-disconnected = "Disconnected 󰈂"; + on-click = "nm-connection-editor"; +} diff --git a/home/desktop/waybar/modules/pulseaudio.compact.nix b/home/desktop/waybar/modules/pulseaudio.compact.nix new file mode 100644 index 00000000..7d6e4700 --- /dev/null +++ b/home/desktop/waybar/modules/pulseaudio.compact.nix @@ -0,0 +1,23 @@ +{ + 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"; +} diff --git a/home/desktop/waybar/modules/pulseaudio.nix b/home/desktop/waybar/modules/pulseaudio.nix new file mode 100644 index 00000000..99241c4c --- /dev/null +++ b/home/desktop/waybar/modules/pulseaudio.nix @@ -0,0 +1,19 @@ +{ + 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"; +} diff --git a/home/desktop/waybar/modules/temperature.nix b/home/desktop/waybar/modules/temperature.nix new file mode 100644 index 00000000..11f2b92c --- /dev/null +++ b/home/desktop/waybar/modules/temperature.nix @@ -0,0 +1,5 @@ +{ + critical-threshold = 80; + format = "{temperatureC}°C {icon}"; + format-icons = ["󱃃" "󰔏" "󱃂"]; +} diff --git a/home/desktop/waybar/modules/tray.nix b/home/desktop/waybar/modules/tray.nix new file mode 100644 index 00000000..3f2e6687 --- /dev/null +++ b/home/desktop/waybar/modules/tray.nix @@ -0,0 +1 @@ +{spacing = 10;} diff --git a/home/desktop/waybar/modules/wlr_workspaces.nix b/home/desktop/waybar/modules/wlr_workspaces.nix new file mode 100644 index 00000000..ebc54aba --- /dev/null +++ b/home/desktop/waybar/modules/wlr_workspaces.nix @@ -0,0 +1,19 @@ +{ + on-click = "activate"; + disable-scroll = true; + all-outputs = false; + format = "{icon}"; + format-icons = { + "1" = "󰟀"; + "2" = "󰅴"; + "3" = "󰈹"; + "4" = "󰝰"; + "5" = "󰭹"; + "6" = ""; + "7" = "󰓓"; + "8" = "󰣙"; + urgent = ""; + default = "󰣘"; + }; + sort-by-number = true; +} diff --git a/home/desktop/waybar/vertical.nix b/home/desktop/waybar/vertical.nix index 650c1c3e..7fd33658 100644 --- a/home/desktop/waybar/vertical.nix +++ b/home/desktop/waybar/vertical.nix @@ -1,6 +1,4 @@ -{...}: let - modules = import ./modules.nix; -in { +{...}: { imports = [./default.nix]; programs.waybar.settings = { vertical = { @@ -14,9 +12,9 @@ in { "modules-left" = ["wlr/workspaces"]; "modules-center" = ["clock#compact"]; "modules-right" = ["tray"]; - "wlr/workspaces" = modules."wlr/workspaces"; - "clock#compact" = modules."clock#compact"; - tray = modules.tray; + "wlr/workspaces" = import ./modules/wlr_workspaces.nix; + "clock#compact" = import ./modules/clock.compact.nix; + tray = import ./modules/tray.nix; }; }; }