diff options
author | Drew DeVault <sir@cmpwn.com> | 2019-07-19 14:34:13 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2019-07-19 14:34:13 -0400 |
commit | 66a9052f0fa8d2caf0d82435241b10e9ba8665b2 (patch) | |
tree | b4b350794eb5850806be0936a9146007c4777383 /lib | |
parent | 7a489cb0011a34a68d3e77d0174076857cc37902 (diff) |
Forward mailto links to server via ./aerc <mailto>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/socket.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/socket.go b/lib/socket.go index c256579..78e86c4 100644 --- a/lib/socket.go +++ b/lib/socket.go @@ -2,6 +2,7 @@ package lib import ( "bufio" + "errors" "fmt" "log" "net" @@ -80,3 +81,19 @@ func (as *AercServer) handleClient(conn net.Conn) { } as.logger.Printf("Closed Unix connection %d", clientId) } + +func ConnectAndExec(msg string) error { + sockpath := path.Join(xdg.RuntimeDir(), "aerc.sock") + conn, err := net.Dial("unix", sockpath) + if err != nil { + return err + } + conn.Write([]byte(msg + "\n")) + scanner := bufio.NewScanner(conn) + if !scanner.Scan() { + return errors.New("No response from server") + } + result := scanner.Text() + fmt.Println(result) + return nil +} |