blob: 9f3194c0ac74b2e76ee949ba69161dec51965f85 [file] [log] [blame]
Samuel Shuertdab963e2024-03-23 19:54:28 -04001/*
2This file is modified from https://github.com/Andrey0189/hyprland-rice/blob/main/config/waybar/config
3As such you can access it under the following license terms:
4
5MIT License
6
7Copyright (c) 2024 Andrew
8
9Permission is hereby granted, free of charge, to any person obtaining a copy
10of this software and associated documentation files (the "Software"), to deal
11in the Software without restriction, including without limitation the rights
12to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13copies of the Software, and to permit persons to whom the Software is
14furnished to do so, subject to the following conditions:
15
16The above copyright notice and this permission notice shall be included in all
17copies or substantial portions of the Software.
18
19THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25SOFTWARE.
26*/
27{ config, lib, pkgs, ... }: {
28 options.chimera.waybar = {
29 enable = lib.mkEnableOption "Enable Waybar";
30 modules = {
31 laptop.enable = lib.mkEnableOption "Enable all laptop modules by default";
32 backlight = {
33 enable = lib.mkOption {
34 type = lib.types.bool;
35 default = config.chimera.waybar.modules.laptop.enable;
36 description = "Enable reading and modifying backlight using light";
37 };
38 };
39 battery = {
40 states = {
41 full = lib.mkOption {
42 type = lib.types.int;
43 default = 98;
44 description = "The power above which your battery will be considered full";
45 };
46 warning = lib.mkOption {
47 type = lib.types.int;
48 default = 30;
49 description = "The power below which your battery will be considered at 'low' levels";
50 };
51 critical = lib.mkOption {
52 type = lib.types.int;
53 default = 15;
54 description = "The power below which your battery will be considered critically low";
55 };
56 };
57 enable = lib.mkOption {
58 type = lib.types.bool;
59 default = config.chimera.waybar.modules.laptop.enable;
60 description = "Enable battery module";
61 };
62 };
63 temperature = {
64 enable = lib.mkOption {
65 type = lib.types.bool;
66 default = config.chimera.waybar.modules.temperature.hwmonPath != null;
67 description = "Enable temperature module";
68 };
69 hwmonPath = lib.mkOption {
70 type = lib.types.nullOr lib.types.str;
71 description = "System CPU hardware temperature path";
72 example = "/sys/class/hwmon/hwmon1/temp1_input";
73 default = null;
74 };
75 };
76 };
77 };
78
79 config = {
80 programs.waybar = lib.mkIf config.chimera.waybar.enable {
81 enable = true;
82 settings = [
83 {
84 layer = "top";
85 position = "top";
86 margin = "9 13 -10 18";
87 modules-left = [ "hyprland/workspaces" "keyboard-state" ];
88 modules-center = ["clock"];
89 modules-right = ["pulseaudio" "custom/mem" "cpu"]
90 ++ (if config.chimera.waybar.modules.temperature.enable then [ "temperature" ] else [])
91 ++ (if config.chimera.waybar.modules.battery.enable then [ "backlight" ] else [])
92 ++ (if config.chimera.waybar.modules.battery.enable then [ "battery" ] else [])
93 ++ [ "tray" ];
94
95 "hyprland/workspaces" = {
96 "disable-scroll" = true;
97 };
98 clock = {
99 "tooltip-format" = "<big>{:%Y %B}</big>\n<tt><small>{calendar}</small></tt>";
100 "format" = "{:%a, %d %b, %I:%M %p}";
101 };
102 pulseaudio = {
103 "scroll-step" = 1;
104 "reverse-scrolling" = 1;
105 "format" = "{volume}% {icon} {format_source}";
106 "format-bluetooth" = "{volume}% {icon} {format_source}";
107 "format-bluetooth-muted" = " {icon} {format_source}";
108 "format-muted" = " {format_source}";
109 "format-source" = "{volume}% ";
110 "format-source-muted" = "";
111 "format-icons" = {
112 "headphone" = "";
113 "hands-free" = "";
114 "headset" = "";
115 "phone" = "";
116 "portable" = "";
117 "car" = "";
118 "default" = ["" "" ""];
119 };
120 "on-click" = "${pkgs.pavucontrol}/bin/pavucontrol";
121 "min-length" = 13;
122 };
123 "custom/mem" = {
124 "format" = "{} ɤ";
125 "interval" = 5;
126 "exec" = "free -h | awk '/Mem:/{printf $3}'";
127 "tooltip" = false;
128 };
129 cpu = {
130 "interval" = 2;
131 "format" = "{usage}% ";
132 "min-length" = 6;
133 };
134 temperature = {
135 "thermal-zone" = 2;
136 "hwmon-path" = config.chimera.waybar.modules.temperature.hwmonPath;
137 "critical-threshold" = 80;
138 "format-critical" = "{temperatureC}°C {icon}";
139 "format" = "{temperatureC}°C {icon}";
140 "format-icons" = ["" "" "" "" ""];
141 "tooltip" = false;
142 "interval" = 2;
143 };
144 backlight = lib.mkIf config.chimera.waybar.modules.backlight.enable {
145 "format" = "{percent}% {icon}";
146 "format-icons" = [""];
147 "min-length" = 7;
148 };
149 battery = lib.mkIf config.chimera.waybar.modules.battery.enable {
150 "states" = config.chimera.waybar.modules.battery.states;
151 "format" = "{capacity}% {icon}";
152 "format-charging" = "{capacity}% ";
153 "format-plugged" = "{capacity}% ";
154 "format-alt" = "{time} {icon}";
155 "format-icons" = ["" "" "" "" "" "" "" "" "" ""];
156 "on-update" = "$HOME/.config/waybar/scripts/check_battery.sh";
157 };
158 tray = {
159 "icon-size" = 16;
160 "spacing" = 0;
161 };
162 }
163 ];
164 style = ''
165 @define-color background #${config.chimera.theme.colors.Crust.hex};
166 @define-color active #${config.chimera.theme.colors.Accent.hex};
167 @define-color hover #${config.chimera.theme.colors.Surface2.hex};
168 @define-color text #${config.chimera.theme.colors.Text.hex};
169 @define-color altText #${config.chimera.theme.colors.Base.hex};
170 @define-color critical #${config.chimera.theme.colors.Red.hex};
171 @define-color warning #${config.chimera.theme.colors.Yellow.hex};
172 @define-color charging #${config.chimera.theme.colors.Green.hex};
173 '' + builtins.readFile ./main.css;
174 };
175 };
176}