「GNOME-SHELL」- 扩展 | Extension

认识

官网:https://extensions.gnome.org/about/
文档:https://gjs.guide/extensions/

GNOME Shell extensions are small pieces of code written by third party developers that modify the way GNOME works. (If you are familiar with Chrome Extensions or Firefox Addons, GNOME Shell extensions are similar to them.) You can find and install GNOME Shell extensions using this website. 简而言之,GNOME Shell Extension,其为 GNOME Shell 的插件,其通过扩展 GNOME Shell 桌面功能。

组成

https://gjs.guide/extensions/

性质

Extensions may make small changes, like moving your clock to the right-hand side of the screen, or make big changes, like arranging the windows in the Activities Overview in a different way.

提供插件运行日志

Where Ubuntu Gnome Looking Glass / extensions logs are stored? – Ask Ubuntu

Write log(‘[EXTENSION_LOG]’, <yourLoggedValue>); in your code.

Open terminal and type journalctl -f | grep ‘\[EXTENSION\_LOG\]’ for realtime monitoring. Then restart shell with alt+f2 – r – enter

When runtime reach line with your log(), you will see someting like this:

13:49:50 notebook gnome-session[2646]: Gjs-Message: JS LOG: [EXTENSION_LOG], 123

It’s a simplest logging method i’ve find.

Label [EXTENSION_LOG] need to separate your code logs from other gnome-session log messages, like start of extensions, or finding their locally, etc.

所以,针对插件的日志能够,通过过滤 journalctl -f 输出得到。

构建

How to install Gnome Shell Extensions on Ubuntu 18.04 Bionic Beaver Linux
Projects/GnomeShellIntegrationForChrome/Installation – GNOME Wiki!

获得插件

开发插件的方法

  • ……

使用已有的插件

安装插件

通过 gnome-shell-extension-manager 管理

Ubuntu 24.04 LTS

# apt-cache search gnome-shell-extension
gnome-shell-extension-appindicator - AppIndicator, KStatusNotifierItem and tray support for GNOME Shell
gnome-shell-extension-desktop-icons-ng - desktop icon support for GNOME Shell
gnome-shell-extension-ubuntu-dock - Ubuntu Dock for GNOME Shell
gnome-shell-extension-ubuntu-tiling-assistant - extension which adds a Windows-like snap assist to GNOME Shell
gnome-shell-extension-alphabetical-grid - Alphabetical App Grid GNOME Extension
gnome-shell-extension-apps-menu - Category based app menu for GNOME Shell
gnome-shell-extension-auto-move-windows - GNOME Shell extension to move apps to specific workspaces
gnome-shell-extension-drive-menu - Removable drive status menu for GNOME Shell
gnome-shell-extension-gpaste - GPaste extension for GNOME Shell
gnome-shell-extension-gsconnect - KDE Connect implementation for GNOME Shell
gnome-shell-extension-gsconnect-browsers - Browser support of KDE Connect implementation for GNOME Shell
gnome-shell-extension-launch-new-instance - GNOME Shell extension to launch new instances of apps
gnome-shell-extension-light-style - GNOME Shell extension to switch the Shell to light style
gnome-shell-extension-manager - Utility for managing GNOME Shell Extensions
gnome-shell-extension-native-window-placement - GNOME Shell extension to arrange windows in a more compact way
gnome-shell-extension-places-menu - Places menu for GNOME Shell
gnome-shell-extension-prefs - tool to enable / disable GNOME Shell extensions
gnome-shell-extension-screenshot-window-sizer - GNOME Shell extension to resize windows for GNOME Software screenshots
gnome-shell-extension-status-icons - GNOME Shell extension to show some status icons in the top bar
gnome-shell-extension-system-monitor - Display system information in GNOME Shell status bar
gnome-shell-extension-user-theme - GNOME Shell extension to load alternative GNOME Shell themes
gnome-shell-extension-window-list - GNOME Shell extension to display a window list
gnome-shell-extension-windows-navigator - GNOME Shell extension to allow keyboard selection in overlay mode
gnome-shell-extension-workspace-indicator - Workspace indicator for GNOME Shell
gnome-shell-extensions - Extensions to extend functionality of GNOME Shell
gnome-shell-extensions-common - common files for official GNOME Shell extensions

gnome-shell-extension-appindicator
gnome-shell-extension-desktop-icons-ng
gnome-shell-extension-ubuntu-dock | https://github.com/micheleg/dash-to-dock/
gnome-shell-extension-ubuntu-tiling-assistant

通过 APT 安装(推荐)

针对在仓库中已存在的扩展,通常其已经过官网测试,能与当前发行版桌面环境良好运行,所以我们优先从仓库中安装。如果仓库没有该扩展,我们会再考虑其他方式安装。

在发行版的仓库中,一般都包含某些 GNOME 扩展:

apt-cache search gnome-shell-extension | grep gnome-shell-extension

# 比如,安装系统托盘插件(某些发行版中可能没有,或者包名不同)
apt-get install -y gnome-shell-extension-top-icons-plus

安装目录:/usr/share/gnome-shell/extensions

Ubuntu 21.04 提供的 GNOME Shell Extension

gnome-shell-extension-tilix-dropdown – launch tilix in quake-mode from gnome-shell


gnome-shell-extension-tilix-shortcut – Adds easy to use configurable keyboard shortcut for tilix

Tilix 与 Tmux、Screen 类似,都是终端分屏工具,但是 Tilix 图形化的分屏工具。该插件与 Tilix 配合使用,但是我们启用该插件时遇到错误;

gnome-shell-extension-hijra – Hijri Islamic Calendar GNOME shell extension

伊斯兰日历,依赖与 hijra-applet 软件;

通过网页插件安装(推荐)

火狐浏览器有个名为 GNOME Shell integration 的插件,该插件已经与 GNOME Shell 进行整合,最终的结果便是简化插件安装:
1)浏览器访问 GNOME Shell Extensions 站点;
2)找到插件,点击“安装”按钮(在界面中显示为“黑色的开关按钮”);
3)提示用户是否要安装插件,在同意后,插件将被安装到系统中;

该方法需要进行以下几步准备工作:
1)在主机中,安装 chrome-gnome-shell 应用:apt-get install chrome-gnome-shell
2)在浏览器中,安装 GNOME Shell integration 扩展;
3)可以在 https://extensions.gnome.org 直接向本地安装插件,还能查看本地已经安装的插件;

# 07/17/2019 在谷歌浏览器中,安装 GNOME Shell integration 扩展;

# 02/10/2021 浏览器插件 GNOME Shell integration 可以在 Firfox 及 Chrome 中正常使用,但是无法在 Chromium 中使用。在 Chromium 中,访问 GNOME Shell Extensions 站点,页面将显示如下错误信息:

Although GNOME Shell integration extension is running, native host connector is not detected. Refer documentation for instructions about installing connector.

通过源码安装(手动安装)

下载源码包,按照手册说明进行安装。每种插件的安装方法并不相同,这里不再展开介绍;

通过解压安装(手动安装)

参考 How to install Gnome Shell Extensions from ZIP file using command line on Ubuntu 18.04 Bionic Beaver Linux 文章;

下载 ZIP 包,手动安装。针对手动安装,我们推荐该方式,其比源码更加容易。

将扩展安装到:
1)/usr/share/gnome-shell/extensions/ 中,其为系统级别,对所有用户可见。
2)$HOME/.local/share/gnome-shell/extensions/ 中。我们更倾向于安装到该处中,以在系统迁移时,能够方便保留插件;

针对该方式,大致操作步骤如下:
首先,执行gnome-shell --version命令查看 GNOME Shell 版本;
然后,访问官方的扩展中心,https://extensions.gnome.org,你需要选择对本机 GNOME Shell 版本对应的 ZIP 包;
获取 UUID 值,用于创建目录:unzip -c foo.shellextension.zip metadata.json | grep uuid | cut -d \" -f4
创建目录:mkdir -pv "/usr/share/gnome-shell/extensions/<UUID>",将<UUID>替换成上一步骤中输出的 UUID 值;
解压扩展:unzip -x foo.shellextension.zip -C $HOME/.local/share/gnome-shell/extensions/<UUID>
启用扩展:gnome-shell-extension-tool -e "<UUID>"
重新启动:Alt+F2 => r => Enter,(或,执行 gnome-shell –replace 命令,推荐前者)

应用

下面的链接是其他人整理的推荐扩展:
Top 20 GNOME Extensions You Should Be Using Right Now

启用系统托盘图标:System Tray

修改通知消息的显示位置:4 Solutions to Scenarios:Notification

修改 Topbar 的样式:Activities Configurator by nls1729

Hide Activities Button by zeten30

插件功能:隐藏左上角的 Activities 按钮
插件地址:https://extensions.gnome.org/extension/118/no-topleft-hot-corner

按下 Super 键,就可以显示 Activities 界面,所以顶栏的 Activities 按钮显得没有什么用处;

No Topleft Hot Corner by azuri

插件功能:在 GNOME 3 中,当鼠标悬浮到桌面左上角时,会立即切换到面板。该插件会禁用该功能(Hot Corner)
插件地址:https://extensions.gnome.org/extension/118/no-topleft-hot-corner

对于我们来说,这个功能并不方便,所以可以禁用它;

Hibernate Status Button

插件功能:休眠按钮
下载地址:https://extensions.gnome.org/extension/755/hibernate-status-button/

Workspace Switcher

插件功能:高级的 Workspace 指示器
下载地址:https://github.com/Tomha/gnome-shell-extension-workspace-switcher

在 GNOME 3 中,有个 Workspace Indicator 插件,可以显示当前所处的 Workspace,但是只能显示数组,不能显示 Worspace 的名字。而 Workspace Switcher 更高级,可以显示 Workspce 的名称,还有一些其他更加高级的设置;

Screenshot Window Sizer by hughsie

插件功能:调整窗口大小
下载地址:https://extensions.gnome.org/extension/736/screenshot-window-sizer/
项目仓库:https://github.com/hughsie/gnome-shell-extension-screenshot-window-sizer

安装插件后,可以使用 Ctrl + Alt + s 快捷键,快速调整窗口大小(与截图功能并没有直接的关系);

改进

插件管理工具

Extension Manager by Matthew Jakeman