From 399d484f6ef3e351f40645f3bb022f41e6fd31ac Mon Sep 17 00:00:00 2001 From: milarin Date: Fri, 19 Jan 2024 13:20:41 +0100 Subject: [PATCH] Execute function implemented --- execute_command.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 execute_command.go diff --git a/execute_command.go b/execute_command.go new file mode 100644 index 0000000..1f3e938 --- /dev/null +++ b/execute_command.go @@ -0,0 +1,21 @@ +package hypr + +import ( + "fmt" + "net" + "os" +) + +func Execute(cmd string) error { + conn, err := net.Dial("unix", os.ExpandEnv("/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock")) + if err != nil { + return err + } + defer conn.Close() + + if _, err := fmt.Fprintln(conn, cmd); err != nil { + return err + } + + return nil +}