summary refs log tree commit diff
path: root/bin
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-02-09 17:36:40 -0500
committerJune McEnroe <june@causal.agency>2021-02-09 17:36:40 -0500
commit409615246069bc311ec58570b0ebb951aca85068 (patch)
tree00dee90206b082eafa95a867225aef7d55f9de7f /bin
parentAdd macOS-like copy and paste to xterm (diff)
downloadsrc-409615246069bc311ec58570b0ebb951aca85068.tar.gz
src-409615246069bc311ec58570b0ebb951aca85068.zip
Use flags for pbd client behaviour
Diffstat (limited to 'bin')
-rw-r--r--bin/.gitignore3
-rw-r--r--bin/Makefile13
-rw-r--r--bin/man1/pbd.141
-rw-r--r--bin/pbd.c19
4 files changed, 35 insertions, 41 deletions
diff --git a/bin/.gitignore b/bin/.gitignore
index a52982b3..0bf030a8 100644
--- a/bin/.gitignore
+++ b/bin/.gitignore
@@ -18,11 +18,8 @@ htmltags
 modem
 mtags
 nudge
-open
 order
-pbcopy
 pbd
-pbpaste
 pngo
 psf2png
 psfed
diff --git a/bin/Makefile b/bin/Makefile
index 7fc0ad0c..11e73078 100644
--- a/bin/Makefile
+++ b/bin/Makefile
@@ -43,10 +43,6 @@ BINS += up
 BINS += when
 BINS += xx
 
-LINKS += open
-LINKS += pbcopy
-LINKS += pbpaste
-
 BINS_BSD += ever
 BINS_LINUX += bri
 BINS_LINUX += fbatt
@@ -57,7 +53,7 @@ BINS_TLS += relay
 BINS_ALL = ${BINS} ${BINS_BSD} ${BINS_LINUX} ${BINS_TLS}
 MANS_ALL = ${BINS_ALL:%=man1/%.1}
 
-any: meta ${BINS} ${LINKS}
+any: meta ${BINS}
 
 bsd: meta ${BINS_BSD}
 
@@ -90,9 +86,6 @@ hilex: ${OBJS.hilex}
 
 ${OBJS.hilex}: hilex.h
 
-open pbcopy pbpaste: pbd
-	ln -f pbd $@
-
 fbatt.o fbclock.o: scheme.h
 
 psf2png.o scheme.o: png.h
@@ -103,7 +96,7 @@ scheme.h: scheme
 tags: *.[chly]
 	ctags -w *.[chly]
 
-IGNORE = *.o *.html ${BINS_ALL} ${LINKS} scheme.h tags htmltags
+IGNORE = *.o *.html ${BINS_ALL} scheme.h tags htmltags
 
 .gitignore: Makefile
 	echo config.mk '${IGNORE}' | tr ' ' '\n' | sort > .gitignore
@@ -119,12 +112,10 @@ link:
 	install -d ${PREFIX}/bin ${MANDIR}/man1
 	ln -fs ${BINS_ALL:%=${PWD}/%} ${PREFIX}/bin
 	ln -fs ${MANS_ALL:%=${PWD}/%} ${MANDIR}/man1
-	ln -fs ${LINKS:%=${PWD}/%} ${PREFIX}/bin
 
 unlink:
 	rm -f ${BINS_ALL:%=${PREFIX}/bin/%}
 	rm -f ${MANS_ALL:%=${MANDIR}/%}
-	rm -f ${LINKS:%=${PREFIX}/bin/%}
 
 HTMLS = index.html ${BINS_ALL:=.html} png.html
 WEBROOT = /usr/local/www/causal.agency
diff --git a/bin/man1/pbd.1 b/bin/man1/pbd.1
index bbc7b785..f0665891 100644
--- a/bin/man1/pbd.1
+++ b/bin/man1/pbd.1
@@ -1,20 +1,13 @@
-.Dd September 7, 2018
+.Dd February  9, 2021
 .Dt PBD 1
 .Os
 .
 .Sh NAME
-.Nm pbd ,
-.Nm pbcopy ,
-.Nm pbpaste ,
-.Nm open
+.Nm pbd
 .Nd macOS pasteboard daemon
 .
 .Sh SYNOPSIS
-.Nm
-.Nm pbcopy
-.Nm pbpaste
-.Nm open
-.Ar
+.Nm Op Fl s | c | p | o Ar url
 .
 .Sh DESCRIPTION
 .Nm
@@ -30,12 +23,7 @@ sent over TCP port 7062.
 .Pp
 The socket can be forwarded through
 .Xr ssh 1
-and the stub implementations of
-.Nm pbcopy ,
-.Nm pbpaste
-and
-.Nm open
-can be used remotely
+and the flags can be used remotely
 to access the local pasteboard
 and open URLs.
 .
@@ -44,11 +32,30 @@ Forwarding can be configured with:
 .Pp
 .Dl RemoteForward 7062 127.0.0.1:7062
 .
+.Pp
+The arguments are as follows:
+.Bl -tag -width Ds
+.It Fl c
+Behave as
+.Xr pbcopy 1 .
+.It Fl o Ar url
+Behave as
+.Xr open 1 .
+.It Fl p
+Behave as
+.Xr pbpaste 1 .
+.It Fl s
+Run the server.
+This is the default.
+.El
+.Pp
+ACAB.
+.
 .Sh EXAMPLES
 .Bd -literal -offset indent
 pbd &
 ssh -R 7062:127.0.0.1:7062 tux.local
-pbpaste
+pbd -p
 .Ed
 .
 .Sh SEE ALSO
diff --git a/bin/pbd.c b/bin/pbd.c
index 2ba333fd..2fd401ae 100644
--- a/bin/pbd.c
+++ b/bin/pbd.c
@@ -138,15 +138,14 @@ static int open1(const char *url) {
 }
 
 int main(int argc, char *argv[]) {
-	(void)argc;
-	if (strchr(argv[0], '/')) {
-		argv[0] = strrchr(argv[0], '/') + 1;
-	}
-	switch (argv[0][0] && argv[0][1] ? argv[0][2] : 0) {
-		case 'd': return pbd();
-		case 'c': return pbcopy();
-		case 'p': return pbpaste();
-		case 'e': return open1(argv[1]);
-		default:  return EX_USAGE;
+	for (int opt; 0 < (opt = getopt(argc, argv, "co:ps"));) {
+		switch (opt) {
+			case 'c': return pbcopy();
+			case 'o': return open1(optarg);
+			case 'p': return pbpaste();
+			case 's': return pbd();
+			default:  return EX_USAGE;
+		}
 	}
+	return pbd();
 }