summaryrefslogtreecommitdiff
path: root/lib/astal/io/application.vala
diff options
context:
space:
mode:
authorAylur <[email protected]>2024-11-02 23:53:41 +0100
committerAylur <[email protected]>2024-11-02 23:57:22 +0100
commitcdaf8905ac3d566284719a29af6e4eddc10bb857 (patch)
tree6bd3ffc4848cae29dede4c489c8b5f5a17d0e085 /lib/astal/io/application.vala
parent031321b3f418369a6c4ce578ba2673b7631117c1 (diff)
parentd47b470f68a8e5f2d19f32fbfb1de95752ba8eb8 (diff)
Merge branch 'main' into feat/gtk4
Diffstat (limited to 'lib/astal/io/application.vala')
-rw-r--r--lib/astal/io/application.vala69
1 files changed, 26 insertions, 43 deletions
diff --git a/lib/astal/io/application.vala b/lib/astal/io/application.vala
index c7bd311..09b61b5 100644
--- a/lib/astal/io/application.vala
+++ b/lib/astal/io/application.vala
@@ -103,75 +103,58 @@ public static List<string> get_instances() {
* Quit an an Astal instances.
* It is the equivalent of `astal --quit -i instance`.
*/
-public static void quit_instance(string instance) {
- try {
- IApplication proxy = Bus.get_proxy_sync(
- BusType.SESSION,
- "io.Astal." + instance,
- "/io/Astal/Application"
- );
+public static void quit_instance(string instance) throws Error {
+ IApplication proxy = Bus.get_proxy_sync(
+ BusType.SESSION,
+ "io.Astal." + instance,
+ "/io/Astal/Application"
+ );
- proxy.quit();
- } catch (Error err) {
- critical(err.message);
- }
+ proxy.quit();
}
/**
* Open the Gtk debug tool of an an Astal instances.
* It is the equivalent of `astal --inspector -i instance`.
*/
-public static void open_inspector(string instance) {
- try {
- IApplication proxy = Bus.get_proxy_sync(
- BusType.SESSION,
- "io.Astal." + instance,
- "/io/Astal/Application"
- );
+public static void open_inspector(string instance) throws Error {
+ IApplication proxy = Bus.get_proxy_sync(
+ BusType.SESSION,
+ "io.Astal." + instance,
+ "/io/Astal/Application"
+ );
- proxy.inspector();
- } catch (Error err) {
- critical(err.message);
- }
+ proxy.inspector();
}
/**
* Toggle a Window of an Astal instances.
* It is the equivalent of `astal -i instance --toggle window`.
*/
-public static void toggle_window_by_name(string instance, string window) {
- try {
- IApplication proxy = Bus.get_proxy_sync(
- BusType.SESSION,
- "io.Astal." + instance,
- "/io/Astal/Application"
- );
+public static void toggle_window_by_name(string instance, string window) throws Error {
+ IApplication proxy = Bus.get_proxy_sync(
+ BusType.SESSION,
+ "io.Astal." + instance,
+ "/io/Astal/Application"
+ );
- proxy.toggle_window(window);
- } catch (Error err) {
- critical(err.message);
- }
+ proxy.toggle_window(window);
}
/**
* Send a message to an Astal instances.
* It is the equivalent of `astal -i instance content of the message`.
*/
-public static string send_message(string instance, string msg) {
+public static string send_message(string instance, string msg) throws Error {
var rundir = Environment.get_user_runtime_dir();
var socket_path = @"$rundir/astal/$instance.sock";
var client = new SocketClient();
- try {
- var conn = client.connect(new UnixSocketAddress(socket_path), null);
- conn.output_stream.write(msg.concat("\x04").data);
+ var conn = client.connect(new UnixSocketAddress(socket_path), null);
+ conn.output_stream.write(msg.concat("\x04").data);
- var stream = new DataInputStream(conn.input_stream);
- return stream.read_upto("\x04", -1, null, null);
- } catch (Error err) {
- printerr(err.message);
- return "";
- }
+ var stream = new DataInputStream(conn.input_stream);
+ return stream.read_upto("\x04", -1, null, null);
}
/**