From 3c2347fabae61ee03a1a469758cba5e86d0c40dc Mon Sep 17 00:00:00 2001 From: Colin Date: Sat, 15 Jun 2024 03:49:01 +0000 Subject: [PATCH] nwg-panel: fixup the formatting especially, make it fit on moby --- TODO.md | 2 +- hosts/by-name/desko/default.nix | 5 +++ hosts/common/programs/nwg-panel/config | 9 ++--- hosts/common/programs/nwg-panel/default.nix | 41 +++++++++++++++++++-- hosts/common/programs/nwg-panel/style.css | 6 +-- 5 files changed, 49 insertions(+), 14 deletions(-) diff --git a/TODO.md b/TODO.md index 36da51b6..9a0fbbb2 100644 --- a/TODO.md +++ b/TODO.md @@ -91,7 +91,7 @@ - replace starship prompt with something more efficient - watch `forkstat`: it does way too much - cleanup waybar/nwg-panel so that it's not invoking playerctl every 2 seconds - - nwg-panel: alerts on battery = 0 on desko even though there's no battery + - nwg-panel: swaync icon is stuck as the refresh icon - nwg-panel: doesn't appear on all desktops - nwg-panel: doesn't know that virtual-desktop 10/TV exists - install apps: diff --git a/hosts/by-name/desko/default.nix b/hosts/by-name/desko/default.nix index 8ff31efc..d6628f63 100644 --- a/hosts/by-name/desko/default.nix +++ b/hosts/by-name/desko/default.nix @@ -35,6 +35,11 @@ sane.programs."gnome.geary".config.autostart = true; sane.programs.signal-desktop.config.autostart = true; + sane.programs.nwg-panel.config = { + battery = false; + brightness = false; + }; + sane.image.extraBootFiles = [ pkgs.bootpart-uefi-x86_64 ]; # needed to use libimobiledevice/ifuse, for iphone sync diff --git a/hosts/common/programs/nwg-panel/config b/hosts/common/programs/nwg-panel/config index db149c6a..04f31a3d 100644 --- a/hosts/common/programs/nwg-panel/config +++ b/hosts/common/programs/nwg-panel/config @@ -7,7 +7,7 @@ "controls": "right", "width": "auto", "height": @height@, - "homogeneous": true, + "homogeneous": false, "margin-top": 0, "margin-bottom": 0, "padding-horizontal": 0, @@ -26,11 +26,7 @@ "playerctl" ], "controls-settings": { - "components": [ - "brightness", - "volume", - "battery" - ], + "components": @components@, "commands": { "battery": "" }, @@ -41,6 +37,7 @@ "leave-closes": false, "click-closes": false, "css-name": "controls-window", + "window-width": 400, "custom-items": [], "menu": { "name": "Exit", diff --git a/hosts/common/programs/nwg-panel/default.nix b/hosts/common/programs/nwg-panel/default.nix index d51d4094..75295c29 100644 --- a/hosts/common/programs/nwg-panel/default.nix +++ b/hosts/common/programs/nwg-panel/default.nix @@ -18,6 +18,13 @@ in default = {}; type = types.submodule { options = { + clockFontSize = mkOption { + type = types.int; + # what looks good: + # - 15px on moby + # - 24px on lappy + default = lib.min 24 (cfg.config.fontSize - 1); + }; fontSize = mkOption { type = types.int; default = 16; @@ -29,6 +36,8 @@ in height of the top bar in px. ''; }; + battery = mkEnableOption' true "display battery status"; + brightness = mkEnableOption' true "display backlight level and slider"; mediaTitle = mkEnableOption' true "display title of current song/media"; mediaPrevNext = mkEnableOption' true "display prev/next button in media"; windowIcon = mkEnableOption' true "display icon of active window"; @@ -60,6 +69,15 @@ in patches = (base.patches or []) ++ lib.optionals (!cfg.config.mediaPrevNext) [ ./playerctl-no-prev-next.diff ]; + + # disable the drop-down chevron by the controls. + # it's precious space on moby, doesn't do much to help on lappy either. + postPatch = (base.postPatch or "") + '' + substituteInPlace nwg_panel/modules/controls.py --replace-fail \ + 'box.pack_start(self.pan_image, False, False, 4)' \ + '# box.pack_start(self.pan_image, False, False, 4)' + ''; + # XXX(2024/06/13) the bluetooth stuff doesn't cross compile, so disable it propagatedBuildInputs = lib.filter (p: p.pname != "pybluez") base.propagatedBuildInputs; @@ -70,20 +88,35 @@ in # fs.".config/nwg-panel/style.css".symlink.target = ./style.css; fs.".config/nwg-panel/config".symlink.target = pkgs.substituteAll { src = ./config; - inherit (cfg.config) height windowIcon windowTitle workspaceHideEmpty; - playerctlChars = if cfg.config.mediaTitle then 30 else 0; + inherit (cfg.config) height; + windowIcon = builtins.toJSON cfg.config.windowIcon; + windowTitle = builtins.toJSON cfg.config.windowTitle; + workspaceHideEmpty = builtins.toJSON cfg.config.workspaceHideEmpty; + components = builtins.toJSON ( + # order matters, mostly for the drop-down. + # default for most tools (e.g. swaync) is brightness control above volume. + lib.optionals cfg.config.brightness [ + "brightness" + ] ++ [ + "volume" + ] ++ lib.optionals cfg.config.battery [ + "battery" + ] + ); + playerctlChars = if cfg.config.mediaTitle then 60 else 0; workspaceNumbers = builtins.toJSON cfg.config.workspaceNumbers; }; fs.".config/nwg-panel/style.css".symlink.target = pkgs.substituteAll { src = ./style.css; - inherit (cfg.config) fontSize; + inherit (cfg.config) clockFontSize fontSize; }; services.nwg-panel = { description = "nwg-panel status/topbar for wayland"; partOf = [ "graphical-session" ]; - command = "nwg-panel"; + # to debug styling, run with GTK_DEBUG=interactive + command = "env G_MESSAGES_DEBUG=all nwg-panel"; }; }; } diff --git a/hosts/common/programs/nwg-panel/style.css b/hosts/common/programs/nwg-panel/style.css index da253097..c5c57edc 100644 --- a/hosts/common/programs/nwg-panel/style.css +++ b/hosts/common/programs/nwg-panel/style.css @@ -145,10 +145,10 @@ scale slider { min-width: 25px; } -/*#clock { +#clock { font-family: monospace; - font-size: 16px -}*/ + font-size: @clockFontSize@px; +} /* UNUSED IN MY CURRENT CONFIG: COPIED FROM SAMPLE CONFIG */