summary refs log tree commit diff
path: root/www
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2025-06-01 22:34:07 -0400
committerJune McEnroe <june@causal.agency>2025-06-01 22:34:07 -0400
commit849b32bf42eb8a3f600fed555c48c29dd7b9c694 (patch)
treec4defa058e7d0ae9866e388a64b55e89a1516af2 /www
parentRemove something (diff)
downloadsrc-849b32bf42eb8a3f600fed555c48c29dd7b9c694.tar.gz
src-849b32bf42eb8a3f600fed555c48c29dd7b9c694.zip
Add mastodon posting script
Diffstat (limited to 'www')
-rw-r--r--www/photo.causal.agency/.gitignore5
-rw-r--r--www/photo.causal.agency/mastodon.sh54
2 files changed, 58 insertions, 1 deletions
diff --git a/www/photo.causal.agency/.gitignore b/www/photo.causal.agency/.gitignore
index 4e55d718..e6e1a830 100644
--- a/www/photo.causal.agency/.gitignore
+++ b/www/photo.causal.agency/.gitignore
@@ -1,3 +1,6 @@
-*.JPG
 *.jpg
+*.JPG
+app.json
+posted.txt
 static/
+token.json
diff --git a/www/photo.causal.agency/mastodon.sh b/www/photo.causal.agency/mastodon.sh
new file mode 100644
index 00000000..1eaa1114
--- /dev/null
+++ b/www/photo.causal.agency/mastodon.sh
@@ -0,0 +1,54 @@
+#!/bin/sh
+set -eu
+
+Instance=https://tilde.zone
+Root=${1:-static}
+
+if ! test -f app.json; then
+	echo 'No app.json!' >&2
+	exit 1
+fi
+chmod 600 app.json
+
+if ! test -f token.json; then
+	client_id=$(jq -r .client_id app.json)
+	client_secret=$(jq -r .client_secret app.json)
+	echo "Please open ${Instance}/oauth/authorize?client_id=${client_id}&scope=write&redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=code"
+	printf 'Enter code: '
+	read -r code
+	curl -Ss -X POST \
+		-F 'grant_type=authorization_code' \
+		-F "client_id=${client_id}" \
+		-F "client_secret=${client_secret}" \
+		-F 'redirect_uri=urn:ietf:wg:oauth:2.0:oob' \
+		-F "code=${code}" \
+		${Instance}/oauth/token >token.json
+fi
+chmod 600 token.json
+
+access_token=$(jq -r .access_token token.json)
+
+if ! test -f posted.txt; then
+	touch posted.txt
+fi
+
+photo=$(
+	find ${Root} -type f -path '*/0*/*.jpg' |
+	sort | comm -13 posted.txt - | head -n 1
+)
+preview=${Root}/preview/${photo##*/}
+
+media_id=$(
+	curl -Ss -X POST \
+		-H "Authorization: Bearer ${access_token}" \
+		-F "file=@${preview}" \
+		${Instance}/api/v2/media |
+	jq -r .id
+)
+
+curl -Ss -X POST \
+	-H "Authorization: Bearer ${access_token}" \
+	-F "media_ids[]=${media_id}" \
+	${Instance}/api/v1/statuses >/dev/null
+
+echo ${photo} >>posted.txt
controlJune McEnroe Weirdly the Fn key doesn't change how the F row registers... I wonder if I can do something about that. 2021-02-07Set X key repeat rateJune McEnroe 2021-02-07Bump font size to 12June McEnroe 11 is what I use on macOS, but I feel like my eyes are working harder here. 2021-02-07Fully configure and rebind cwmJune McEnroe This is sort of a mix of trying to emulate macOS somewhat for my muscle memory and just rebinding some of the cwm defaults to use 4- rather than M-. 2021-02-07Add BintiJune McEnroe 2021-02-07Finish configuring xtermJune McEnroe 2021-02-06Enable tapping, reverse scroll, set scaling in wsconsctlJune McEnroe 2021-02-06Set root window to black on purple snowJune McEnroe 2021-02-06Add xmodmap configurationJune McEnroe 2021-02-06Add initial OpenBSD X configurationJune McEnroe cwm still needs a lot more rebinding, and I need to actually look at its other options. xterm definitely still needs some configuration, but I at least managed to get it to use a decent looking font. Very happy that OpenBSD includes Luxi Mono, which is what my usual font, Go Mono, is based on anyway. Still missing is xmodmap and such. 2021-02-06Add xterm output to schemeJune McEnroe