diff --git a/justfile b/justfile index 9cf4dfc..7565c0e 100644 --- a/justfile +++ b/justfile @@ -1,4 +1,4 @@ -allTags := "nvim,xmonad,git" +allTags := "nvim,xmonad,git,scripts" default: just --list diff --git a/roles/scripts/files/compiledoc b/roles/scripts/files/compiledoc new file mode 100644 index 0000000..bd8f453 --- /dev/null +++ b/roles/scripts/files/compiledoc @@ -0,0 +1,33 @@ +#!/usr/bin/env sh +# takes a file and compiles it into a pdf file, if possible +# inspiration from https://github.com/LukeSmithxyz/voidrice/blob/master/.local/bin/compiler + +file=$(readlink -f "$1") +dir=${file%/*} +base="${file%.*}" +ext="${file##*.}" + +cd "$dir" || exit 1 + +compile_tex() { \ + if [ -e "$dir/Tectonic.toml"]; then + tectonic -X build + else + params="" + ( grep -q minted $file) && params="$params -Z shell-escape" + tectonic -X compile "$params" $file + fi +} + +case "$ext" in + md) pandoc -t pdf \ + --pdf-engine tectonic \ + -f gfm \ + -V linkcolor:blue \ + -V geometry:a4paper \ + -V geometry:margin=2cm \ + -V mainfont="Liberation Sans" \ + -V monofont="Liberation Mono" \ + -o "$base".pdf "$file" ;; + tex) textype "$file" ;; +esac diff --git a/roles/scripts/tasks/main.yml b/roles/scripts/tasks/main.yml new file mode 100644 index 0000000..eaffae2 --- /dev/null +++ b/roles/scripts/tasks/main.yml @@ -0,0 +1,25 @@ +--- +- name: Install packages required by scripts + ansible.builtin.package: + name: + - tectonic + - pandoc + - ttf-liberation + state: present + tags: pc + +- name: Create a local bin directory if it doesn't exist + ansible.builtin.file: + path: ~/.local/bin + state: directory + mode: '0755' + tags: pc + +- name: Copy over all scripts + ansible.builtin.copy: + src: "{{ item.src }}" + dest: "{{ item.dest }}" + mode: '0755' + with_items: + - { src: compiledoc, dest: ~/.local/bin/compiledoc } + tags: pc diff --git a/site.yml b/site.yml index f71edb9..22b3f67 100644 --- a/site.yml +++ b/site.yml @@ -3,12 +3,22 @@ connection: local hosts: localhost tasks: - - ansible.builtin.include_role: + - name: Nvim role + ansible.builtin.include_role: name: nvim tags: nvim - - ansible.builtin.include_role: + + - name: Xmonad role + ansible.builtin.include_role: name: xmonad tags: xmonad - - ansible.builtin.include_role: + + - name: Git role + ansible.builtin.include_role: name: git tags: git + + - name: Scripts role + ansible.builtin.include_role: + name: scripts + tags: scripts