summary refs log tree commit diff
path: root/url.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-02-08 21:21:21 -0500
committerJune McEnroe <june@causal.agency>2020-02-08 21:21:21 -0500
commit2db17e83a914586fd351437ac5323713f1e66478 (patch)
tree4716c982f38bd57a1f5636c1606e894912b538ff /url.c
parentSet FDs CLOEXEC (diff)
downloadcatgirl-2db17e83a914586fd351437ac5323713f1e66478.tar.gz
catgirl-2db17e83a914586fd351437ac5323713f1e66478.zip
Allow overriding the /open utility
Diffstat (limited to 'url.c')
-rw-r--r--url.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/url.c b/url.c
index 1396765..c9c4d5c 100644
--- a/url.c
+++ b/url.c
@@ -95,7 +95,8 @@ void urlScan(size_t id, const char *nick, const char *mesg) {
 	}
 }
 
-static const char *OpenBins[] = { "open", "xdg-open" };
+const char *urlOpenUtil;
+static const char *OpenUtils[] = { "open", "xdg-open" };
 
 static void urlOpen(const char *url) {
 	pid_t pid = fork();
@@ -105,10 +106,15 @@ static void urlOpen(const char *url) {
 	close(STDIN_FILENO);
 	dup2(procPipe[1], STDOUT_FILENO);
 	dup2(procPipe[1], STDERR_FILENO);
-	for (size_t i = 0; i < ARRAY_LEN(OpenBins); ++i) {
-		execlp(OpenBins[i], OpenBins[i], url, NULL);
+	if (urlOpenUtil) {
+		execlp(urlOpenUtil, urlOpenUtil, url, NULL);
+		warn("%s", urlOpenUtil);
+		_exit(EX_CONFIG);
+	}
+	for (size_t i = 0; i < ARRAY_LEN(OpenUtils); ++i) {
+		execlp(OpenUtils[i], OpenUtils[i], url, NULL);
 		if (errno != ENOENT) {
-			warn("%s", OpenBins[i]);
+			warn("%s", OpenUtils[i]);
 			_exit(EX_CONFIG);
 		}
 	}