summaryrefslogtreecommitdiff
path: root/lib/astal/io/application.vala
diff options
context:
space:
mode:
authorAylur <[email protected]>2024-10-27 22:12:35 +0000
committerAylur <[email protected]>2024-10-27 22:12:35 +0000
commit439571abec531d9b50d22f647335112645e43d86 (patch)
tree0ada2ff7fc3b2f24ee532b83a2bcaa56e38bb71c /lib/astal/io/application.vala
parent197bffbf05d62aeefceb58011b0f031cd8836ca6 (diff)
cli: better err logs
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);
}
/**