1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
{ config, pkgs, lib, ... }:
let
cfg = config.features.gui.desktops.niri.parts.waybar;
aes = config.aesthetics;
in {
options.features.gui.desktops.niri.parts.waybar.enable = lib.mkEnableOption "waybar";
config = lib.mkIf cfg.enable {
programs.waybar = {
enable = true;
settings = {
bar = {
layer = "top";
position = "bottom";
height = 32;
modules-left = [ "battery" "network" "backlight" "pulseaudio" "custom/syncthing" ];
modules-center = [ "niri/workspaces" ];
modules-right = [ "clock#date" "clock#time" ];
"clock#date" = {
format = " {:%A, %B %d}";
};
"clock#time" = {
format = " {:%I:%M}";
};
pulseaudio = {
format = " {volume}%";
format-muted = " {volume}%";
};
network = {
format = "{essid}";
format-wifi = "{icon} {essid}";
format-ethernet = " Ethernet";
format-disconnected = " Disconnected";
format-icons = [ "" "" "" "" "" ];
};
battery = {
format = "{icon} {capacity}%";
format-charging = " {capacity}%";
format-icons = [ "" "" "" "" "" "" "" "" "" "" "" ];
};
backlight = {
format = " {percent}%";
};
"niri/workspaces" = {
format = "{icon}";
format-icons = {
default = "";
active = "";
/*
"1" = "1";
"2" = "2";
"3" = "3";
"4" = "4";
"5" = "5";
"6" = "6";
"7" = "7";
"8" = "8";
"9" = "9";
"10" = "10";
"11" = "11";
"12" = "12";
*/
};
};
"custom/syncthing" = {
exec = lib.getExe (pkgs.writers.writeNuBin "syncthing-waybar-module" /*nu*/ ''
let status = ${lib.getExe pkgs.stc-cli} events | from json | where type == "StateChanged" | reverse | get 0.data.to
let percent = ${lib.getExe pkgs.stc-cli} json_dump | from json | get folders | get syncPercentDone | math avg | into int
let icon = if ($status == "idle") { ""
} else if ($status == "scanning") { ""
} else if ($status == "syncing") { ""
} else { "" }
let percent_string = if ($percent == 100) { "Synced" } else { ($percent | into string) + "%" }
return ($icon + " " + $percent_string)
'');
on-click = "${lib.getExe pkgs.stc-cli} rescan all";
interval = 3;
};
};
};
style = let
border-radius = "4";
padding = "12";
in /*css*/ ''
@define-color background-color #${aes.scheme.base00};
@define-color border-color #${aes.scheme.base0C};
@define-color text-color #${aes.scheme.base05};
* {
font-family: ${aes.font.name};
font-weight: 600;
font-size: ${aes.font.size.medium}px;
}
window#waybar {
background-color: transparent;
}
#clock.time, #clock.date, #custom-syncthing, #backlight, #pulseaudio, #battery, #network {
background-color: @background-color;
color: @text-color;
border-radius: ${border-radius}px;
border-width: 0px;
border-color: @border-color;
padding: 0px ${padding}px;
}
#backlight, #pulseaudio, #battery, #network, #custom-syncthing {
margin: 0px 0px ${padding} ${padding};
}
#clock.date, #clock.time {
margin: 0px ${padding} ${padding} 0px
}
#workspaces {
background-color: @background-color;
color: @background-color;
border-radius: ${border-radius}px;
border-width: 0px;
border-color: @border-color;
padding: 0px 0px;
margin-bottom: ${padding}px;
}
#workspaces button {
font-weight: bold;
padding: 0px 4px;
margin: 4px 4px;
border-radius: ${border-radius}px;
color: @background-color;
background: @text-color;
opacity: 0.5;
transition: all 0.3s cubic-bezier(.25,.1,.25,1);
}
#workspaces button.active {
font-weight: bold;
padding: 0px 4px;
margin: 4px 4px;
border-radius: ${border-radius}px;
color: @background-color;
background: @text-color;
transition: all 0.3s cubic-bezier(.25,.1,.25,1);
opacity: 1.0;
min-width: 40px;
}
#workspaces button:hover {
font-weight: bold;
border-radius: ${border-radius}px;
color: @background-color;
background: @text-color;
opacity: 0.8;
transition: all 0.3s cubic-bezier(.25,.1,.25,1);
}
'';
};
};
}
|