summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorS. Gilles <sgilles@math.umd.edu>2019-06-03 08:34:12 -0400
committerOri Bernstein <ori@eigenstate.org>2019-08-20 19:52:51 -0700
commit2dd6a5ce18f42e11a0a4a730cf19066e25863ab8 (patch)
treed0bf59fb8b04f6f114a489874ac3cb36f31b7a71
parent4212e61603d2a270ab839bd00c9a47a5ee241913 (diff)
downloadlibxmyrb-2dd6a5ce18f42e11a0a4a730cf19066e25863ab8.tar.gz
Read $HOME from environment
-rw-r--r--display.myr13
1 files changed, 9 insertions, 4 deletions
diff --git a/display.myr b/display.myr
index 12a2b71..70d99d4 100644
--- a/display.myr
+++ b/display.myr
@@ -99,9 +99,15 @@ const parsedpy = {buf, dpy
}
const mkdisplay = {fd, host, dpynum, scrnum
- var islocal, dpy, auth
+ var islocal, dpy, auth, xauthpath
- auth = parsemagic("/home/ori/.Xauthority")
+ match std.getenv("HOME")
+ | `std.Some h: xauthpath = std.fmt("{}/.Xauthority", h)
+ | `std.None: -> `std.Err `Eparse
+ ;;
+
+ auth = parsemagic(xauthpath)
+ std.slfree(xauthpath)
if host.len == 0
islocal = true
;;
@@ -121,7 +127,6 @@ const mkdisplay = {fd, host, dpynum, scrnum
.host = std.sldup(host),
])
-
match handshake(dpy)
| `std.Ok s:
dpy.setup = (s : void#)
@@ -198,7 +203,7 @@ const handshake = {dpy
buf = std.slalloc(8)
match std.readall(dpy.fd, buf[:6])
| `std.Ok 6: /* ok */
- | `std.Ok _: std.put("here\n"); -> `std.Err `Eproto
+ | `std.Ok _: -> `std.Err `Eproto
| `std.Err _: -> `std.Err `Econn
;;
/* If it's an error, return a failure error. */