From 763bb52070a32ec6cb3d74b97de728ec03825543 Mon Sep 17 00:00:00 2001 From: Sam Hadow Date: Thu, 20 Feb 2025 14:39:53 +0100 Subject: [PATCH] more scripts --- convert_md_to_pdf.sh | 10 ++++++++++ get_matrix_access_token.sh | 14 ++++++++++++++ listings-setup.tex | 24 ++++++++++++++++++++++++ webptogif.sh | 2 ++ 4 files changed, 50 insertions(+) create mode 100644 convert_md_to_pdf.sh create mode 100755 get_matrix_access_token.sh create mode 100644 listings-setup.tex create mode 100755 webptogif.sh diff --git a/convert_md_to_pdf.sh b/convert_md_to_pdf.sh new file mode 100644 index 0000000..01eef6d --- /dev/null +++ b/convert_md_to_pdf.sh @@ -0,0 +1,10 @@ +pandoc infile.md \ + --include-in-header listings-setup.tex \ + -V linkcolor:blue \ + -V geometry:a4paper \ + -V geometry:margin=2cm \ + -V mainfont="Overpass" \ + -V monofont="Hack" \ + --listings \ + --pdf-engine=xelatex \ + -o outfile.pdf diff --git a/get_matrix_access_token.sh b/get_matrix_access_token.sh new file mode 100755 index 0000000..0d7ca41 --- /dev/null +++ b/get_matrix_access_token.sh @@ -0,0 +1,14 @@ +#!/bin/bash +if [ $# -ne 3 ]; then + echo "Usage: $0 " + exit 1 +fi + +access_token=$(curl -s -XPOST -d '{"type":"m.login.password", "user":"'"$1"'", "password":"'"$2"'"}' "https://$3/_matrix/client/r0/login" | jq -r '.access_token') + +if [ -z "$access_token" ]; then + echo "Failed to retrieve access token. Please check your username and password." + exit 1 +fi + +echo "$access_token" diff --git a/listings-setup.tex b/listings-setup.tex new file mode 100644 index 0000000..51bb31d --- /dev/null +++ b/listings-setup.tex @@ -0,0 +1,24 @@ +\usepackage{xpatch,realboxes} +\usepackage{xcolor} +\definecolor{Light}{HTML}{F4F4F4} + +\lstset{ + basicstyle=\ttfamily, + extendedchars=true + numbers=left, + numberstyle=\tiny\ttfamily, + backgroundcolor=\color[RGB]{248,197,196}, + showstringspaces=false, + tabsize=2, + columns=fixed, + frame=trbl, + frameround=tttt, + framesep=7pt, + breaklines=true, postbreak=\raisebox{0ex}[0ex][0ex]{\ensuremath{\color{red}\hookrightarrow\space}} +} + + +\makeatletter +\xpretocmd\lstinline{\Colorbox{Light}\bgroup\appto\lst@DeInit{\egroup}}{}{} +\makeatother + diff --git a/webptogif.sh b/webptogif.sh new file mode 100755 index 0000000..11a77bc --- /dev/null +++ b/webptogif.sh @@ -0,0 +1,2 @@ +#!/bin/bash +convert -delay 10 -dispose none $1 -coalesce -loop 0 -layers optimize ${1%".webp"}.gif