(T)im's N(ix) Flake, Multi-Host Configurations for all of my machines! 74k1.sh/
nixos nix
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat(waybar): add wifi-{1,2,3,4} strength

74k1 b0d6197e 57a75057

+330 -303
+307 -284
modules/home-manager/wayland/waybar/default.nix
··· 147 147 }; 148 148 149 149 "custom/net" = { 150 - exec = lib.getExe (pkgs.writeScriptBin "wb-net" (builtins.readFile ./scripts/wb-net.sh)); 150 + exec = lib.getExe ( 151 + pkgs.writeShellApplication { 152 + name = "wb-net"; 153 + runtimeInputs = [ 154 + pkgs.networkmanager 155 + ]; 156 + text = builtins.readFile ./scripts/wb-net.sh; 157 + } 158 + ); 151 159 return-type = "json"; 152 160 format = "{icon}"; 153 161 format-icons = { 154 162 lan = ""; 155 - wifi = ""; 163 + wifi-1 = ""; 164 + wifi-2 = ""; 165 + wifi-3 = ""; 166 + wifi-4 = ""; 156 167 none = ""; 157 168 }; 158 169 }; ··· 172 183 ]; 173 184 on-click = "pavucontrol"; 174 185 on-click-right = lib.getExe ( 175 - pkgs.writeShellApplication { 186 + pkgs.writeShellApplication { 176 187 name = "wb-select-output"; 177 188 runtimeInputs = [ 178 189 pkgs.fuzzel ··· 192 203 runtimeInputs = [ 193 204 pkgs.swaynotificationcenter 194 205 ]; 195 - text = /* sh */ '' 196 - #!/usr/bin/env bash 206 + text = 207 + /* 208 + sh 209 + */ 210 + '' 211 + #!/usr/bin/env bash 197 212 198 - while :; do 199 - # number of unread notifications 200 - unread=''$(swaync-client -c) 213 + while :; do 214 + # number of unread notifications 215 + unread=''$(swaync-client -c) 201 216 202 - # dnd on? (swaync-client -D returns "true" or "false") 203 - if [[ ''$(swaync-client -D) == "true" ]]; then 204 - alt="dnd" 205 - else 206 - if (( unread == 0 )); then 207 - alt="none" 217 + # dnd on? (swaync-client -D returns "true" or "false") 218 + if [[ ''$(swaync-client -D) == "true" ]]; then 219 + alt="dnd" 208 220 else 209 - alt="some" 221 + if (( unread == 0 )); then 222 + alt="none" 223 + else 224 + alt="some" 225 + fi 210 226 fi 211 - fi 212 227 213 - # build tooltip 214 - if (( unread == 0 )); then 215 - tooltip="no notifications" 216 - elif (( unread == 1 )); then 217 - tooltip="1 notification" 218 - else 219 - tooltip="''${unread} notifications" 220 - fi 228 + # build tooltip 229 + if (( unread == 0 )); then 230 + tooltip="no notifications" 231 + elif (( unread == 1 )); then 232 + tooltip="1 notification" 233 + else 234 + tooltip="''${unread} notifications" 235 + fi 221 236 222 - printf '{"alt": "%s", "tooltip": "%s"}\n' "''$alt" "''$tooltip" 237 + printf '{"alt": "%s", "tooltip": "%s"}\n' "''$alt" "''$tooltip" 223 238 224 - sleep 0.5 225 - done 226 - ''; 239 + sleep 0.5 240 + done 241 + ''; 227 242 } 228 243 ); 229 244 return-type = "json"; ··· 293 308 enable = true; 294 309 systemd.enable = true; 295 310 settings = { 296 - smallBar = { 297 - height = 32; 298 - spacing = 8; 299 - position = "top"; 300 - layer = "top"; 301 - margin-left = 8; 302 - margin-right = 8; 303 - margin-top = 8; 311 + smallBar = 312 + { 313 + height = 32; 314 + spacing = 8; 315 + position = "top"; 316 + layer = "top"; 317 + margin-left = 8; 318 + margin-right = 8; 319 + margin-top = 8; 304 320 305 - output = [ 306 - "DP-7" 307 - ]; 321 + output = [ 322 + "DP-7" 323 + ]; 308 324 309 - modules-left = [ 310 - "group/power" 311 - ]; 325 + modules-left = [ 326 + "group/power" 327 + ]; 312 328 313 - modules-center = [ 314 - "clock" 315 - ]; 316 - 317 - modules-right = [ 318 - "battery" 319 - ]; 320 - } // modules; 329 + modules-center = [ 330 + "clock" 331 + ]; 321 332 322 - mainBar = { 323 - height = 32; 324 - spacing = 8; 325 - position = "top"; 326 - layer = "top"; 327 - margin-left = 8; 328 - margin-right = 8; 329 - margin-top = 8; 333 + modules-right = [ 334 + "battery" 335 + ]; 336 + } 337 + // modules; 330 338 331 - output = [ 332 - "DP-6" 333 - "eDP-1" 334 - ]; 339 + mainBar = 340 + { 341 + height = 32; 342 + spacing = 8; 343 + position = "top"; 344 + layer = "top"; 345 + margin-left = 8; 346 + margin-right = 8; 347 + margin-top = 8; 335 348 336 - modules-left = [ 337 - "group/power" 338 - "cpu" 339 - "custom/mem" 340 - ]; 349 + output = [ 350 + "DP-6" 351 + "eDP-1" 352 + ]; 341 353 342 - modules-center = [ 343 - "clock" 344 - ]; 345 - 346 - modules-right = [ 347 - "group/interactibles" 348 - "custom/net" 349 - "custom/swaync" 350 - "wireplumber" 351 - "power-profiles-daemon" 352 - "battery" 353 - ]; 354 + modules-left = [ 355 + "group/power" 356 + "cpu" 357 + "custom/mem" 358 + ]; 359 + 360 + modules-center = [ 361 + "clock" 362 + ]; 354 363 355 - } // modules; 364 + modules-right = [ 365 + "group/interactibles" 366 + "custom/net" 367 + "custom/swaync" 368 + "wireplumber" 369 + "power-profiles-daemon" 370 + "battery" 371 + ]; 372 + } 373 + // modules; 356 374 }; 357 - style = lib.mkForce /* css */ '' 358 - /* @define-color fg0 #EBE9F1; */ 359 - @define-color fg0 #938FA8; 360 - @define-color bg0 #07060B; 361 - /* @define-color bg1 #1C1B28; */ 362 - @define-color bg1 #07060B; 363 - @define-color bg2 #323246; 364 - @define-color bg3 #4C4B69; 365 - @define-color accent #816BFF; 366 - @define-color cyan #4CCEFE; 367 - @define-color green #50E074; 368 - @define-color red #FF5487; 369 - @define-color yellow #FFE375; 375 + style = 376 + lib.mkForce 377 + /* 378 + css 379 + */ 380 + '' 381 + /* @define-color fg0 #EBE9F1; */ 382 + @define-color fg0 #938FA8; 383 + @define-color bg0 #07060B; 384 + /* @define-color bg1 #1C1B28; */ 385 + @define-color bg1 #07060B; 386 + @define-color bg2 #323246; 387 + @define-color bg3 #4C4B69; 388 + @define-color accent #816BFF; 389 + @define-color cyan #4CCEFE; 390 + @define-color green #50E074; 391 + @define-color red #FF5487; 392 + @define-color yellow #FFE375; 370 393 371 - * { 372 - border: none; 373 - border-radius: 0px; 374 - font-family: "PP Supply Mono", "JetBrainsMono NF Regular", "JetBrains Mono"; 375 - font-size: 16px; 376 - min-height: 32px; 377 - } 394 + * { 395 + border: none; 396 + border-radius: 0px; 397 + font-family: "PP Supply Mono", "JetBrainsMono NF Regular", "JetBrains Mono"; 398 + font-size: 16px; 399 + min-height: 32px; 400 + } 378 401 379 - #custom-power-icon, 380 - #custom-power-lock, 381 - #custom-power-logout, 382 - #custom-power-off, 383 - #custom-power-reboot, 384 - #custom-net, 385 - #custom-swaync, 386 - #custom-tray-btn, 387 - #power-profiles-daemon { 388 - font-family: "PP Supply Mono", "Material Symbols Sharp"; 389 - font-weight: 600; 390 - } 402 + #custom-power-icon, 403 + #custom-power-lock, 404 + #custom-power-logout, 405 + #custom-power-off, 406 + #custom-power-reboot, 407 + #custom-net, 408 + #custom-swaync, 409 + #custom-tray-btn, 410 + #power-profiles-daemon { 411 + font-family: "PP Supply Mono", "Material Symbols Sharp"; 412 + font-weight: 600; 413 + } 414 + 415 + window#waybar { 416 + background-color: @bg0; 417 + color: @fg0; 418 + transition-property: background-color; 419 + } 420 + 421 + window#waybar.hidden { 422 + opacity: 0.2; 423 + } 424 + 425 + #clock, 426 + #battery, 427 + #cpu, 428 + #memory, 429 + #disk, 430 + #temperature, 431 + #backlight, 432 + #network, 433 + #pulseaudio, 434 + #mpris, 435 + #wireplumber, 436 + #tags, 437 + #taskbar, 438 + #tray, 439 + #mode, 440 + #idle_inhibitor, 441 + #custom-tray-btn, 442 + #custom-mem, 443 + #custom-swaync, 444 + #custom-power-icon, 445 + #custom-power-lock, 446 + #custom-power-logout, 447 + #custom-power-off, 448 + #custom-power-reboot, 449 + #mpd { 450 + padding: 0 8px; 451 + background-color: @bg1; 452 + color: @fg0; 453 + } 454 + 455 + #clock { 456 + background-color: @bg1; 457 + color: @fg0; 458 + } 459 + 460 + #battery { 461 + background-color: @bg1; 462 + color: @fg0; 463 + } 464 + 465 + #battery.charging, #battery.plugged { 466 + color: @green; 467 + background-color: @bg1; 468 + /* border: 1px solid #FFFFFF; */ 469 + } 470 + 471 + @keyframes blink { 472 + to { 473 + background-color: @bg1; 474 + color: @fg0; 475 + } 476 + } 391 477 392 - window#waybar { 393 - background-color: @bg0; 394 - color: @fg0; 395 - transition-property: background-color; 396 - } 478 + #battery.critical:not(.charging) { 479 + background-color: @bg1; 480 + color: @red; 481 + animation-name: blink; 482 + animation-duration: 0.5s; 483 + animation-timing-function: linear; 484 + animation-iteration-count: infinite; 485 + animation-direction: alternate; 486 + } 397 487 398 - window#waybar.hidden { 399 - opacity: 0.2; 400 - } 488 + label:focus { 489 + background-color: @bg0; 490 + } 401 491 402 - #clock, 403 - #battery, 404 - #cpu, 405 - #memory, 406 - #disk, 407 - #temperature, 408 - #backlight, 409 - #network, 410 - #pulseaudio, 411 - #mpris, 412 - #wireplumber, 413 - #tags, 414 - #taskbar, 415 - #tray, 416 - #mode, 417 - #idle_inhibitor, 418 - #custom-tray-btn, 419 - #custom-mem, 420 - #custom-swaync, 421 - #custom-power-icon, 422 - #custom-power-lock, 423 - #custom-power-logout, 424 - #custom-power-off, 425 - #custom-power-reboot, 426 - #mpd { 427 - padding: 0 8px; 492 + #cpu { 428 493 background-color: @bg1; 429 494 color: @fg0; 430 - } 495 + } 431 496 432 - #clock { 497 + #memory { 433 498 background-color: @bg1; 434 499 color: @fg0; 435 - } 500 + } 436 501 437 - #battery { 502 + #disk { 438 503 background-color: @bg1; 439 504 color: @fg0; 440 - } 505 + } 441 506 442 - #battery.charging, #battery.plugged { 443 - color: @green; 507 + #backlight { 444 508 background-color: @bg1; 445 - /* border: 1px solid #FFFFFF; */ 446 - } 509 + color: @fg0; 510 + } 447 511 448 - @keyframes blink { 449 - to { 450 - background-color: @bg1; 451 - color: @fg0; 452 - } 453 - } 512 + #network { 513 + background-color: @bg1; 514 + color: @fg0; 515 + } 454 516 455 - #battery.critical:not(.charging) { 456 - background-color: @bg1; 457 - color: @red; 458 - animation-name: blink; 459 - animation-duration: 0.5s; 460 - animation-timing-function: linear; 461 - animation-iteration-count: infinite; 462 - animation-direction: alternate; 463 - } 517 + #network.disconnected { 518 + background-color: @bg1; 519 + color: @red; 520 + } 464 521 465 - label:focus { 466 - background-color: @bg0; 467 - } 522 + #pulseaudio { 523 + background-color: @bg1; 524 + color: @fg0; 525 + } 468 526 469 - #cpu { 470 - background-color: @bg1; 471 - color: @fg0; 472 - } 527 + #pulseaudio.muted { 528 + background-color: @bg1; 529 + color: @red; 530 + } 473 531 474 - #memory { 475 - background-color: @bg1; 476 - color: @fg0; 477 - } 532 + #mpris { 533 + background-color: @bg1; 534 + color: @fg0; 535 + } 478 536 479 - #disk { 480 - background-color: @bg1; 481 - color: @fg0; 482 - } 537 + #mpris.spotify { 538 + background-color: @bg1; 539 + color: @fg0; 540 + } 483 541 484 - #backlight { 485 - background-color: @bg1; 486 - color: @fg0; 487 - } 542 + #mpris.vlc { 543 + background-color: @bg1; 544 + color: @fg0; 545 + } 488 546 489 - #network { 490 - background-color: @bg1; 491 - color: @fg0; 492 - } 547 + #mpris.brave { 548 + background-color: @bg1; 549 + color: @fg0; 550 + } 493 551 494 - #network.disconnected { 495 - background-color: @bg1; 496 - color: @red; 497 - } 552 + #custom-power{ 553 + background-color: @bg1; 554 + color: @fg0; 555 + } 498 556 499 - #pulseaudio { 500 - background-color: @bg1; 501 - color: @fg0; 502 - } 557 + #tags{ 558 + background-color: @bg1; 559 + color: @fg0; 560 + } 503 561 504 - #pulseaudio.muted { 505 - background-color: @bg1; 506 - color: @red; 507 - } 562 + #tags button.occupied { 563 + background-color: @bg1; 564 + color: @fg0; 565 + } 508 566 509 - #mpris { 510 - background-color: @bg1; 511 - color: @fg0; 512 - } 567 + #tags button.focused { 568 + background-color: @bg2; 569 + color: @fg0; 570 + } 513 571 514 - #mpris.spotify { 515 - background-color: @bg1; 516 - color: @fg0; 517 - } 572 + #tags button.urgent{ 573 + background-color: @bg1; 574 + color: @red; 575 + } 518 576 519 - #mpris.vlc { 520 - background-color: @bg1; 521 - color: @fg0; 522 - } 523 577 524 - #mpris.brave { 525 - background-color: @bg1; 526 - color: @fg0; 527 - } 578 + #temperature { 579 + background-color: @bg1; 580 + color: @fg0; 581 + } 528 582 529 - #custom-power{ 530 - background-color: @bg1; 531 - color: @fg0; 532 - } 583 + #temperature.critical { 584 + background-color: @bg1; 585 + color: @red; 586 + } 533 587 534 - #tags{ 535 - background-color: @bg1; 536 - color: @fg0; 537 - } 588 + #tray { 589 + background-color: @bg1; 590 + color: @fg0; 591 + } 538 592 539 - #tags button.occupied { 540 - background-color: @bg1; 541 - color: @fg0; 542 - } 593 + #tray > .passive { 594 + -gtk-icon-effect: dim; 595 + background-color: @bg0; 596 + color: @fg0; 597 + } 543 598 544 - #tags button.focused { 545 - background-color: @bg2; 546 - color: @fg0; 547 - } 599 + #tray > .needs-attention { 600 + -gtk-icon-effect: highlight; 601 + background-color: @bg2; 602 + color: @fg0; 603 + } 548 604 549 - #tags button.urgent{ 550 - background-color: @bg1; 551 - color: @red; 552 - } 605 + #language { 606 + background-color: @bg1; 607 + color: @fg0; 608 + min-width: 16px; 609 + } 553 610 554 - 555 - #temperature { 556 - background-color: @bg1; 557 - color: @fg0; 558 - } 611 + #keyboard-state { 612 + background-color: @bg1; 613 + color: @fg0; 614 + min-width: 16px; 615 + } 559 616 560 - #temperature.critical { 561 - background-color: @bg1; 562 - color: @red; 563 - } 564 - 565 - #tray { 566 - background-color: @bg1; 567 - color: @fg0; 568 - } 569 - 570 - #tray > .passive { 571 - -gtk-icon-effect: dim; 572 - background-color: @bg0; 573 - color: @fg0; 574 - } 575 - 576 - #tray > .needs-attention { 577 - -gtk-icon-effect: highlight; 578 - background-color: @bg2; 579 - color: @fg0; 580 - } 581 - 582 - #language { 583 - background-color: @bg1; 584 - color: @fg0; 585 - min-width: 16px; 586 - } 587 - 588 - #keyboard-state { 589 - background-color: @bg1; 590 - color: @fg0; 591 - min-width: 16px; 592 - } 593 - 594 - #keyboard-state > label.locked { 595 - background: rgba(0, 0, 0, 0.2); 596 - } 597 - ''; 617 + #keyboard-state > label.locked { 618 + background: rgba(0, 0, 0, 0.2); 619 + } 620 + ''; 598 621 }; 599 622 }
+23 -19
modules/home-manager/wayland/waybar/scripts/wb-net.sh
··· 1 1 #!/usr/bin/env bash 2 - 3 2 while :; do 4 - alt="none" 5 - tooltip="" 3 + alt="none" 4 + tooltip="" 6 5 7 - if=$(ip route | awk '$1=="default"{if (!found) {print $5; found=1}}') 8 - case $if in 9 - en*|eth*) 10 - alt="lan" 11 - tooltip=$if 12 - ;; 13 - wl*) 14 - alt="wifi" 15 - tooltip=$if 16 - ;; 17 - *) 18 - alt="none" 19 - ;; 20 - esac 6 + IFS=: read -r ifname iftype _ _ \ 7 + < <(nmcli -t dev status | awk -F: '$3=="connected"{print; exit}') 21 8 22 - printf '{"alt": "%s", "tooltip": "%s"}\n' "$alt" "$tooltip" 23 - sleep 2 9 + case "$iftype" in 10 + ethernet) 11 + alt="lan" 12 + tooltip="$ifname" 13 + ;; 14 + wifi) 15 + s=$(nmcli -t -f SIGNAL --mode tabular dev wifi list --rescan no ifname "$ifname" 2>/dev/null | head -n1) 16 + s=${s:-0} 17 + if (( s >= 90 )); then alt="wifi-4" 18 + elif (( s >= 51 )); then alt="wifi-3" 19 + elif (( s >= 11 )); then alt="wifi-2" 20 + else alt="wifi-1" 21 + fi 22 + tooltip="$ifname ${s}%" 23 + ;; 24 + esac 25 + 26 + printf '{"alt":"%s","tooltip":"%s"}\n' "$alt" "$tooltip" 27 + sleep 2 24 28 done