waybar: show different modules for moby v.s. others

This commit is contained in:
Colin 2024-03-01 15:25:42 +00:00
parent c6e956f3d2
commit b6daeddfa2
3 changed files with 29 additions and 15 deletions

View File

@ -30,9 +30,16 @@
workspace_layout = "tabbed";
};
sane.programs.waybar.config.fontSize = 14;
sane.programs.waybar.config.height = 26;
sane.programs.waybar.config.persistWorkspaces = [ "1" "2" "3" "4" "5" ];
sane.programs.waybar.config = {
fontSize = 14;
height = 26;
persistWorkspaces = [ "1" "2" "3" "4" "5" ];
modules.media = false;
modules.network = false;
modules.perf = false;
modules.windowTitle = false;
# TODO: show modem state
};
sane.gui.sxmo = {
nogesture = true;

View File

@ -1,6 +1,10 @@
{ config, lib, pkgs, ... }:
let
cfg = config.sane.programs.waybar;
mkEnableOption' = default: description: lib.mkOption {
type = lib.types.bool;
inherit default description;
};
in
{
sane.programs.waybar = {
@ -35,6 +39,12 @@ in
list of workspaces to always show, e.g. [ "1" "7" ]
'';
};
modules.windowTitle = mkEnableOption' true "display window title in center";
modules.media = mkEnableOption' true "display current track on right";
modules.perf = mkEnableOption' true "display RAM, CPU on right";
modules.network = mkEnableOption' true "display IP traffic on right";
top = mkOption {
type = types.submodule {
# `attrsOf types.anything` (v.s. plain `attrs`) causes merging of the toplevel items.
@ -62,7 +72,7 @@ in
# default waybar
config.top = pkgs.callPackage ./waybar-top.nix { } {
inherit (cfg.config) height persistWorkspaces;
inherit (cfg.config) height modules persistWorkspaces;
};
packageUnwrapped = pkgs.waybar.override {

View File

@ -9,19 +9,16 @@ let
pkgs = [ "jq" "playerctl" ];
};
in
{ height, persistWorkspaces }:
{ height, modules, persistWorkspaces }:
{
inherit height;
modules-left = lib.mkDefault [ "sway/workspaces" ];
modules-center = lib.mkDefault [ "sway/window" ];
modules-right = lib.mkDefault [
"custom/media"
"custom/swaync"
"clock"
"battery"
"memory"
"cpu"
"network"
modules-left = [ "sway/workspaces" ];
modules-center = lib.mkIf modules.windowTitle [ "sway/window" ];
modules-right = lib.flatten [ # XXX can't use lib.mkMerge here without error ??
(lib.optionals modules.media [ "custom/media" ])
[ "custom/swaync" "clock" "battery" ]
(lib.optionals modules.perf [ "memory" "cpu" ])
(lib.optionals modules.network [ "network" ])
];
"sway/window" = {