From d0e9385946298c1a59774b22f85670bb96e35af7 Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Fri, 17 May 2024 16:17:00 -0400 Subject: [PATCH] theme/sway: added option to hide gtk titlebars if using pkgs.sway --- homeManagerModules/desktop/sway/default.nix | 8 +++++- homeManagerModules/desktop/theme.nix | 32 +++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/homeManagerModules/desktop/sway/default.nix b/homeManagerModules/desktop/sway/default.nix index 4af6478b..652a1238 100644 --- a/homeManagerModules/desktop/sway/default.nix +++ b/homeManagerModules/desktop/sway/default.nix @@ -55,9 +55,15 @@ }; wayland.windowManager.sway.enable = true; - wayland.windowManager.sway.package = pkgs.swayfx; + wayland.windowManager.sway.package = lib.mkDefault pkgs.swayfx; wayland.windowManager.sway.wrapperFeatures.gtk = true; wayland.windowManager.sway.checkConfig = false; + + alyraffauf.desktop.theme.gtk.hideTitleBar = + if config.wayland.windowManager.sway.package == pkgs.sway + then true + else false; + wayland.windowManager.sway.config = let modifier = "Mod4"; diff --git a/homeManagerModules/desktop/theme.nix b/homeManagerModules/desktop/theme.nix index 9b89e66e..1af215df 100644 --- a/homeManagerModules/desktop/theme.nix +++ b/homeManagerModules/desktop/theme.nix @@ -23,6 +23,11 @@ }; type = lib.types.package; }; + hideTitleBar = lib.mkOption { + description = "Whether to hide GTK3/4 titlebars (useful for some window managers)."; + default = false; + type = lib.types.bool; + }; }; alyraffauf.desktop.theme.iconTheme = { name = lib.mkOption { @@ -180,6 +185,33 @@ gtk3.extraConfig = lib.attrsets.optionalAttrs (config.alyraffauf.desktop.theme.colors.preferDark) {gtk-application-prefer-dark-theme = 1;}; gtk4.extraConfig = lib.attrsets.optionalAttrs (config.alyraffauf.desktop.theme.colors.preferDark) {gtk-application-prefer-dark-theme = 1;}; + + gtk3.extraCss = + if config.alyraffauf.desktop.theme.gtk.hideTitleBar + then '' + /* No (default) title bar on wayland */ + headerbar.default-decoration { + /* You may need to tweak these values depending on your GTK theme */ + margin-bottom: 50px; + margin-top: -100px; + + background: transparent; + padding: 0; + border: 0; + min-height: 0; + font-size: 0; + box-shadow: none; + } + + /* rm -rf window shadows */ + window.csd, /* gtk4? */ + window.csd decoration { /* gtk3 */ + box-shadow: none; + } + '' + else "/* */"; + + gtk4.extraCss = config.gtk.gtk3.extraCss; }; dconf.settings = {