給大家介紹點關於GNOME 3的修飾技巧。如題所述,本次給大家介紹如何修改GNOME 3 “活動”文字為你喜歡的圖標。
我們以更換為Fedora圖標為例介紹。當然,你可以換成其他的圖標,只要你喜歡。
在沒有修改GNOME 3默認桌面之前,左上角顯示的是文字“活動”,也就是你目前打開的應用列表。如下圖添加紅色箭頭的地方。
這篇文章的目的就是交給兔兔們如何在紅色箭頭所指地方更換成Fedora logo/或你喜歡的圖標(如下圖所示):
打開文件/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/[email protected]
$ cat activities.json { "shell-version": ["3.0"], "uuid": "[email protected]", "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圖標已經可以顯示在系統界面了。
$ 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 $