修改GNOME 3 “活动”文字为图标


给大家介绍点关于GNOME 3的修饰技巧。如题所述,本次给大家介绍如何修改GNOME 3 “活动”文字为你喜欢的图标。

我们以更换为Fedora图标为例介绍。当然,你可以换成其他的图标,只要你喜欢。

在没有修改GNOME 3默认桌面之前,左上角显示的是文字“活动”,也就是你目前打开的应用列表。如下图添加红色箭头的地方。

这篇文章的目的就是交给兔兔们如何在红色箭头所指地方更换成Fedora logo/或你喜欢的图标(如下图所示):

修改GNOME 3 “活动”文字为图标

方法

打开文件/usr/share/gnome-shell/js/ui/panel.js ,编辑修改java脚本里面的相关项:

/* Button on the left side of the panel. */
        /* Translators: If there is no suitable word for "Activities" in your la
nguage, you can use the word for "Overview". */
        let label = new St.Label({ text: _("Activities") });
        this.button = new St.Button({ name: 'panelActivities',
                                      style_class: 'panel-button',
                                      reactive: true,
                                      can_focus: true });
        this.button.set_child(label);

提示,该段代码在该文件的靠后部分 

然而,我们修改源代码文件可以成功,但是,每次系统更新GNOME Shell后都会覆盖掉我们的修改。

下面是另一种方法:使用扩展替代“活动(Activities)”!

把下面的文件放在路径 ~/.local/share/gnome-shell/extensions/activities@example.com

$ cat activities.json
{
   "shell-version": ["3.0"],
   "uuid": "activities@example.com",
   "name": "activities",
   "description": "Replace Activities text string"
}
 
$ cat extension.js
const St = imports.gi.St;
const Main = imports.ui.main;
const Panel = imports.ui.panel;
const Gettext = imports.gettext.domain('gnome-shell');
const _ = Gettext.gettext;
 
function main() {
 
   hotSpotButton = Main.panel.button;
 
   let logo = new St.Icon({ icon_type: St.IconType.FULLCOLOR,
                                      icon_size: hotSpotButton.height, icon_name: 'fedora-logo-icon' });
   let box = new St.BoxLayout();
   box.add_actor(logo);
 
   hotSpotButton.set_child(box);
}

然后,ALT+F2,输入 “r”(没有引号),重新加载GNOME Shell,你应该看到变化了。

该扩展在Fedora 15上完美运行,icon图标已经可以显示在系统界面了。

修改GNOME 3 “活动”文字为图标 
 
$ cd /usr/share/icons
$ ls
Adwaita    default  gnome    HighContrast         LowContrast
Bluecurve  Fedora   hicolor  HighContrastInverse  oxygen
$ find ./ -name "fedora-logo-icon.*"
./hicolor/32x32/apps/fedora-logo-icon.png
./hicolor/22x22/apps/fedora-logo-icon.png
./hicolor/256x256/apps/fedora-logo-icon.png
./hicolor/16x16/apps/fedora-logo-icon.png
./hicolor/24x24/apps/fedora-logo-icon.png
./hicolor/96x96/apps/fedora-logo-icon.png
./hicolor/36x36/apps/fedora-logo-icon.png
./hicolor/48x48/apps/fedora-logo-icon.png
./Adwaita/fedora-logo-icon.png
$
  • 1
  • 2
  • 下一页

相关内容