释放gnome-shell.css的方法

系统字体配置、中文显示和输入法问题
回复
ReverseOnce
帖子: 106
注册时间: 2015-08-29 21:05

释放gnome-shell.css的方法

#1

帖子 ReverseOnce » 2015-09-19 21:33

gnome-shell的字体设置分成几部分,通过gnome-tweak-tool和dconf-editor两个工具,大多数字体的自定义都能实现。这两个工具不能调整系统字体,也就是dash、topbar及其子应用的字体,这两处的字体是由gnome-shell.css决定的。从gnome 3.12起,gnome-shell.css文件,连同系统默认图标,被集成编译为gnome-shell-theme.gresource文件,这是个二进制文件,无法直接编辑,只有先从gnome-shell-theme.gresource中释放出gnome-shell.css,才能重新设定系统字体。如何将需要的文件释放出来?诀窍是使用shell脚本。
打开终端,新建一个目录:

代码: 全选

mkdir ~/gnomecss
将以下代码复制到文本编辑器,并保存,名称随意,为清晰起见,这里就采用默认路径,即/home/用户名,保存为shellcss.sh。fedora的解释器与debian的不同,fedora的解释器是sh,debian的是bash,所以,对于fedora,需将第一行的bash改为sh。

代码: 全选

#!/bin/bash
workdir=~/gnomecss
gst=/usr/share/gnome-shell/gnome-shell-theme.gresource
mkdir ~/gnomecss/theme
for r in $(gresource list $gst); do
gresource extract $gst $r >$workdir${r/#\/org\/gnome\/shell/}
done
然后赋予shellcss.sh文件可执行权限:

代码: 全选

chmod +x shellcss.sh
紧接着运行:

代码: 全选

./shellcss.sh
该命令会在gnomecss目录下创建theme文件夹,并将包括gnome-shell.css等在内的所有文件释放到该文件夹。关闭当前终端,打开nautilus,浏览到~/gnomecss/theme,将下面的代码复制到文本编辑器,并与theme文件夹中的文件进行核对,文件与代码中列出的名称必须一一对应,删除代码中多余的文件名,添加未列出的文件名,就绪以后,将文件命名为gnome-shell-theme.gresource.xml,保存在theme文件夹。

代码: 全选

<?xml version="1.0" encoding="UTF-8"?>
<gresources>
  <gresource prefix="/org/gnome/shell/theme">
    <file>calendar-arrow-left.svg</file>
    <file>calendar-arrow-right.svg</file>
    <file>calendar-today.svg</file>
    <file>checkbox-focused.svg</file>
    <file>checkbox-off-focused.svg</file>
    <file>checkbox-off.svg</file>
    <file>checkbox.svg</file>
    <file>close-window.svg</file>
    <file>close.svg</file>
    <file>corner-ripple-ltr.png</file>
    <file>corner-ripple-rtl.png</file>
    <file>dash-placeholder.svg</file>
    <file>filter-selected-ltr.svg</file>
    <file>filter-selected-rtl.svg</file>
    <file>gnome-shell.css</file>
    <file>gnome-shell-high-contrast.css</file>
    <file>logged-in-indicator.svg</file>
    <file>more-results.svg</file>
    <file>no-events.svg</file>
    <file>no-notifications.svg</file>
    <file>noise-texture.png</file>
    <file>page-indicator-active.svg</file>
    <file>page-indicator-inactive.svg</file>
    <file>page-indicator-checked.svg</file>
    <file>page-indicator-hover.svg</file>
    <file>process-working.svg</file>
    <file>running-indicator.svg</file>
    <file>source-button-border.svg</file>
    <file>summary-counter.svg</file>
    <file>toggle-off-us.svg</file>
    <file>toggle-off-intl.svg</file>
    <file>toggle-on-us.svg</file>
    <file>toggle-on-intl.svg</file>
    <file>ws-switch-arrow-up.png</file>
    <file>ws-switch-arrow-down.png</file>
  </gresource>
</gresources>
在nautilus中双击gnome-shell.css文件,弹出文本编辑器后,找到字体设置的描述进行更改,并保存。

代码: 全选

/* GLOBALS */
stage {
  font-family: Cantarell, Sans-Serif;
  font-size: 11pt;
  color: #eeeeec; }
在theme文件夹空白处单击鼠标右键,在弹出的右键菜单中选择“打开终端“,输入下面的命令,将修改好的文件打包为新的gnome-shell-theme.gresource文件。

代码: 全选

glib-compile-resources gnome-shell-theme.gresource.xml
备份系统自带的gnome-shell-theme.gresource文件,之后用新生成的替换系统自带的:

代码: 全选

sudo cp /usr/share/gnome-shell/gnome-shell-theme.gresource /usr/share/gnome-shell/gnome-shell-theme.gresource.save
sudo cp gnome-shell-theme.gresource /usr/share/gnome-shell/gnome-shell-theme.gresource
cd ..
mv theme /path/to/save
cd ..
rm shellcss.sh
rm -r gnomecss
最后按alt+f2,输入r回车,重新启动窗口管理器,这下应该能看到变更的效果了。
头像
lhw828
帖子: 2797
注册时间: 2007-03-15 16:58
来自: 湖北武汉
联系:

Re: 释放gnome-shell.css的方法

#2

帖子 lhw828 » 2015-10-12 22:45

学习了 :em11
回复