我的目标是当用户按下Gnome顶部栏中的按钮时启动一个新的GtkApplication。
顶部栏中的按钮可以通过gnome-shell-extension来完成,但是我很难打开GtkApplication。

因此,现在下面的代码应该只启动GtkApplication。

将代码放入~/.local/share/gnome-shell/extensions/test@test/extension.js后启用此扩展名始终会导致SIGSEGV信号为gnome-shell

const Lang = imports.lang;
const Gtk = imports.gi.Gtk;
const TestApp = new Lang.Class({
    Name: 'TestApp',
    Extends: Gtk.Application,
    _init: function() {
        this.parent({ application_id: 'testapp.apptesttt' });
    },
    vfunc_activate: function() {
        //this.window.present();
    },
});
function init() {
}
let _app;
function enable() {
    _app = new TestApp();
    _app.register(null);
}
function disable() {
    _app.quit();
}

最佳答案

我参加聚会可能有点晚了,但是如果有人在这里结束:

答案很可能在imports.misc.util之内:

const Util = imports.misc.util;
Util.spawn()

10-05 20:47
查看更多