mirror of
https://github.com/zoriya/astal.git
synced 2026-06-01 01:38:08 +00:00
feat: optiona exit code on App.quit
This commit is contained in:
@@ -59,6 +59,11 @@ class AstalJS extends Astal.Application {
|
||||
super.apply_css(style, reset)
|
||||
}
|
||||
|
||||
quit(code?: number): void {
|
||||
super.quit()
|
||||
exit(code ?? 0)
|
||||
}
|
||||
|
||||
start({ requestHandler, css, hold, main, client, ...cfg }: Config = {}) {
|
||||
client ??= () => {
|
||||
print(`Astal instance "${this.instanceName}" already running`)
|
||||
|
||||
@@ -16,6 +16,11 @@ function AstalLua:do_request(msg, conn)
|
||||
end
|
||||
end
|
||||
|
||||
function AstalLua:quit(code)
|
||||
Astal.Application.quit(self)
|
||||
os.exit(code)
|
||||
end
|
||||
|
||||
local app = AstalLua()
|
||||
|
||||
---@class StartConfig
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
local App = require("astal.application")
|
||||
|
||||
App:start({
|
||||
instance_name = "test",
|
||||
main = function()
|
||||
App:quit(1)
|
||||
end,
|
||||
})
|
||||
+8
-7
@@ -192,11 +192,11 @@ public class Application : Gtk.Application {
|
||||
}
|
||||
}
|
||||
|
||||
construct {
|
||||
public new void quit() throws DBusError, IOError {
|
||||
if (instance_name == null)
|
||||
instance_name = "astal";
|
||||
|
||||
shutdown.connect(() => {
|
||||
if (service != null) {
|
||||
if (FileUtils.test(socket_path, GLib.FileTest.EXISTS)){
|
||||
try {
|
||||
File.new_for_path(socket_path).delete(null);
|
||||
@@ -204,17 +204,18 @@ public class Application : Gtk.Application {
|
||||
warning(err.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
base.quit();
|
||||
}
|
||||
|
||||
construct {
|
||||
shutdown.connect(() => { try { quit(); } catch(Error err) {} });
|
||||
Unix.signal_add(1, () => { try { quit(); } catch(Error err) {} }, Priority.HIGH);
|
||||
Unix.signal_add(2, () => { try { quit(); } catch(Error err) {} }, Priority.HIGH);
|
||||
Unix.signal_add(15, () => { try { quit(); } catch(Error err) {} }, Priority.HIGH);
|
||||
}
|
||||
|
||||
public new void quit() throws DBusError, IOError {
|
||||
base.quit();
|
||||
}
|
||||
|
||||
public static List<string> get_instances() {
|
||||
var list = new List<string>();
|
||||
var prefix = "io.Astal.";
|
||||
|
||||
Reference in New Issue
Block a user