向 GNOME 面板添加自定义文本

Sha*_*mbo 8 applet extension gnome-panel gnome-classic 12.10

我想在 GNOME Classic 的 GNOME 面板中添加一些文本。

我从这个博客中得到了一个建议,但它可以追溯到 2008 年,现在似乎不适用。

在 Ubuntu 12.10 和 GNOME classic 中,缺少/apps/panel/applets/clock_screen0/prefs/custom_formatin选项gconf-editor

那么有什么方法可以在 GNOME 经典中向时钟添加自定义文本?

还有其他小程序/扩展程序允许我们向 GNOME 面板添加文本吗?

use*_*.dz 11

简单的 Gnome 扩展可能值得一试。(我不确定如何命名,在 Ubuntu 14.04 中:Gnome classic 使用相同的 Gnome shell 扩展,旧的经典更名为 Gnome Fallback)


侏儒经典和伴侣

  1. 下载面板小程序生成器
  2. 生成一个新的小程序:

    python panel-applet-generator.py -n mylabel -d "my custom label"
    
    Run Code Online (Sandbox Code Playgroud)
  3. 调整 mylabelApplet.py

    try:
        from gi.repository import Gtk
    except: # Can't use ImportError, as gi.repository isn't quite that nice...
        import gtk as Gtk
    
    def applet_factory(applet, iid, data = None):
        button = Gtk.Button("It works!")
        label = Gtk.Label("It works!")
        applet.add(label)
        applet.show_all()
        return True
    
    Run Code Online (Sandbox Code Playgroud)

    我添加label = Gtk.Label("It works!")和修改applet.add(label)(它是applet.add(button)

  4. 将 mylabel 文件夹压缩为 tar.gz,然后将其重命名为 mylabel_1.0.orig.tar.gz

  5. 构建 Debian 软件包

    cd mylabel/
    debuild -us -uc
    
    Run Code Online (Sandbox Code Playgroud)
  6. 安装包

    sudo dpkg -i ../*.deb
    
    Run Code Online (Sandbox Code Playgroud)
  7. Alt+Right ClickSuper+ Alt+Right Click面板上,然后添加到面板

  8. 寻找 mylabel 小程序,然后添加

在此处输入图片说明

参考:

笔记:


侏儒壳

我已经用 Gnome 3.10 对其进行了测试:

  1. 安装 Gnome 调整工具

    sudo apt-get install gnome-tweak-tool
    
    Run Code Online (Sandbox Code Playgroud)
  2. 创建新扩展:

    gnome-shell-extension-tool --create-extension
    
    Run Code Online (Sandbox Code Playgroud)
  3. 输入请求的信息: name My Label, description Extension shows my custom text, uuidmylabel@yourname或保留默认值mylabel@hostname

    扩展创建于 /home/username/.local/share/gnome-shell/extensions/mylabel@hostname

  4. extension.js是自动打开的。将 Icon 替换为您的自定义标签。如下:

    function init() {
        button = new St.Bin({ style_class: 'panel-button',
                              reactive: true,
                              can_focus: true,
                              x_fill: true,
                              y_fill: false,
                              track_hover: true });
        let icon = new St.Icon({ icon_name: 'system-run-symbolic',
                                 style_class: 'system-status-icon' });
    
        let label = new St.Label({ text: "Hello, world!" });
        button.set_child(label);
        button.connect('button-press-event', _showHello);
    }
    
    Run Code Online (Sandbox Code Playgroud)

    我添加let label = new St.Label({ text: "Hello, world!" });和修改'button.set_child(label);(它是button.set_child(icon);

  5. 保存,使用Alt+重新启动 Gnome-Shell F2r然后输入Enter

  6. 启动 Gnome 调整工具 → 扩展 → 启用My Label扩展。

  7. 再次重启 Gnome-Shell。

    在此处输入图片说明

参考: