如何在 Gnome 3.20 上的标准 GTK 应用程序和带有标题栏/CSD 的应用程序中更改标题栏高度

joe*_*lom 41 window-manager nautilus gnome3 mutter

在 Gnome 3.18 中,可以通过~/.config/gtk-3.0/gtk.css根据Reduce title bar height in gnome 3 / gtk+ 3更改 css 来更改所有窗口的标题栏高度

.header-bar.default-decoration {
        padding-top: 0px;
        padding-bottom: 0px;
    }

.header-bar.default-decoration .button.titlebutton {
    padding-top: 0px;
    padding-bottom: 0px;
}

/* No line below the title bar */
.ssd .titlebar {
    border-width: 0;
    box-shadow: none;
}
Run Code Online (Sandbox Code Playgroud)

在 Gnome 3.20 中,这似乎不再适用于带有标题栏/CSD(标题栏中的 gnome 特定按钮)的窗口,例如 Nautilus(文件)、设置、照片、联系人等。调整仍然降低了标题栏的高度对于其他应用程序,例如 gnome-terminal 和 gVim。如何降低 gnome 程序(例如 Gnome 3.20 中的 Nautilus)中标题栏的高度?


更新

我也尝试过这个 reddit thread 中的建议。我两个都试过window.ssd.ssd只有,没有骰子。 这有效,请参阅我发布的答案以获取更多详细信息

window.ssd headerbar.titlebar {
    padding-top: 1px;
    padding-bottom: 1px;
    min-height: 0;
}

window.ssd headerbar.titlebar button.titlebutton {
    padding-top: 1px;
    padding-bottom: 1px;
    min-height: 0;
}
Run Code Online (Sandbox Code Playgroud)

/* shrink headebars */
headerbar {
    min-height: 38px;
    padding-left: 2px; /* same as childrens vertical margins for nicer proportions */
    padding-right: 2px;
}

headerbar entry,
headerbar spinbutton,
headerbar button,
headerbar separator {
    margin-top: 2px; /* same as headerbar side padding for nicer proportions */
    margin-bottom: 2px;
}

/* shrink ssd titlebars */
.default-decoration {
    min-height: 0; /* let the entry and button drive the titlebar size */ 
    padding: 2px
}

.default-decoration .titlebutton {
    min-height: 26px; /* tweak these two props to reduce button size */
    min-width: 26px;
}
Run Code Online (Sandbox Code Playgroud)

Fra*_*sco 26

  1. 创建一个文件 ~/.config/gtk-3.0/gtk.css ( 添加下面的 CSS )
  2. 然后你需要重新加载 gnome-shell:ALT + F2并输入r

我能够使用以下 CSS 减少 Gnome 3.20 上的应用程序标题栏:

headerbar entry,
headerbar spinbutton,
headerbar button,
headerbar separator {
    margin-top: 0px; /* same as headerbar side padding for nicer proportions */
    margin-bottom: 0px;
}

headerbar {
    min-height: 24px;
    padding-left: 2px; /* same as childrens vertical margins for nicer proportions */
    padding-right: 2px;
    margin: 0px; /* same as headerbar side padding for nicer proportions */
    padding: 0px;
  }
Run Code Online (Sandbox Code Playgroud)

  • `alt+f2` 和 `r` 提示非常棒;谢谢你! (7认同)
  • 请注意,Alt+F2 不适用于 Wayland 会话 (2认同)

joe*_*lom 16

注意:如果您使用的是 PopOS,则顶部栏菜单中有一个“删除窗口标题”选项,该选项也控制平铺。这是我目前自己使用的,它非常适合仅删除多余的非 CSD 标题栏。

标题栏/CSD

实际上,我通过 reddit 找到并发布在上面的一段代码,即

headerbar entry,
headerbar spinbutton,
headerbar button,
headerbar separator {
    margin-top: 2px; /* same as headerbar side padding for nicer proportions */
    margin-bottom: 2px;
}
Run Code Online (Sandbox Code Playgroud)

确实修改了标题栏/CSD。不过效果不是立竿见影的。即使您重新加载 gnome,您也可能需要关闭所有窗口,稍等片刻,或者注销并重新登录以查看效果。

修改以下内容时,我仍然没有在标题栏中看到任何区别。

headerbar {
    min-height: 38px;
    padding-left: 2px; /* same as children's vertical margins for nicer proportions */
    padding-right: 2px;
}
Run Code Online (Sandbox Code Playgroud)

标准标题栏

正常窗口标题栏的两个部分按预期工作。

.default-decoration {
    min-height: 0; /* let the entry and button drive the titlebar size */
    padding: 2px
}

.default-decoration .titlebutton {
    min-height: 26px; /* tweak these two props to reduce button size */
    min-width: 26px;
}
Run Code Online (Sandbox Code Playgroud)

标题栏边框

如果您正在运行默认的 adwaita 主题,您可以使用以下内容删除标题栏边框。来自https://bbs.archlinux.org/viewtopic.php?id=211102

window.ssd headerbar.titlebar {
  border: none;
  background-image: linear-gradient(to bottom,
  shade(@theme_bg_color, 1.05),
  shade(@theme_bg_color, 0.99));
  box-shadow: inset 0 1px shade(@theme_bg_color, 1.4);
}
Run Code Online (Sandbox Code Playgroud)


小智 5

使用以下内容更新您的~/.config/gtk-3.0/gtk.css

/* shrink headerbars (don't forget semicolons after each property) */
headerbar {
    min-height: 0px;
    padding-left: 2px; /* same as childrens vertical margins for nicer proportions */
    padding-right: 2px;
    background-color: #2d2d2d;
}

headerbar entry,
headerbar spinbutton,
headerbar button,
headerbar separator {
    margin-top: 0px; /* same as headerbar side padding for nicer proportions */
    margin-bottom: 0px;
}

/* shrink ssd titlebars */
.default-decoration {
    min-height: 0; /* let the entry and button drive the titlebar size */
    padding: 0px;
    background-color: #2d2d2d;
}

.default-decoration .titlebutton {
    min-height: 0px; /* tweak these two props to reduce button size */
    min-width: 0px;
}

window.ssd headerbar.titlebar {
    padding-top: 3px;
    padding-bottom: 3px;
    min-height: 0;
}

window.ssd headerbar.titlebar button.titlebutton {
    padding-top: 3px;
    padding-bottom:3px;
    min-height: 0;
}
Run Code Online (Sandbox Code Playgroud)

  • 对于 22.10 下的 Nautilus 等 gtk4 应用程序来说,这相当于什么?我尝试在`~/.config/gtk-4.0`下放置一个类似的文件,但它不起作用。 (2认同)