diff --git a/TODO.md b/TODO.md index cc5cae1..65c1d41 100644 --- a/TODO.md +++ b/TODO.md @@ -35,7 +35,7 @@ Plans for the future of this dotfiles. - [ ] [vivid](https://github.com/sharkdp/vivid) themes - [ ] waybar: pulseaudio module -> wireplumber module (wait for more features, e.g. scrolling) - [ ] html2text, html2org -- [ ] Build podman container images with ansible-bender +- [ ] Build podman container images with ansible-bender or stacker - [ ] Add `target-determinator` and `aspect-cli` to packages (or containers, with underlying `bazel`) ## Sandboxing diff --git a/roles/config/files/vifm/scripts/preview_graphics b/roles/config/files/vifm/scripts/preview_graphics deleted file mode 100755 index dadb598..0000000 --- a/roles/config/files/vifm/scripts/preview_graphics +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/sh - -# https://github.com/eylles/vifm-sixel-preview/pull/2 -# https://github.com/vifm/vifm/issues/419#issuecomment-485918513 - -# require ImageMagick, chafa, ffmpegthumbnailer - -thumbnail_dir="${XDG_CACHE_HOME:-$HOME/.cache}/vifm/thumbnails" - -[ ! -d "${thumbnail_dir}" ] && mkdir -p "${thumbnail_dir}" - -WIDTH="$2" -HEIGHT="$3" -TMP="${thumbnail_dir}/thumbnail.$(stat -c '%n%i%F%s%Y' -- "$(readlink -f "$1")" | sha256sum | awk '{print $1}')" - -_show_graphics() { - exec chafa --animate off -s "${WIDTH}x${HEIGHT}" "$1" -} - -_preview_video() { - [ ! -f "${TMP}.jpg" ] && ffmpegthumbnailer -i "$1" -o "${TMP}.jpg" -s 0 - _show_graphics "${TMP}.jpg" -} - -_preview_image() { - [ ! -f "${TMP}.jpg" ] && convert -- "$1"'[0]' "${TMP}.jpg" - _show_graphics "${TMP}.jpg" -} - -_preview_font() { - [ ! -f "${TMP}.jpg" ] && ~/.local/libexec/genfontimage "$1" "${TMP}.jpg" - _show_graphics "${TMP}.jpg" -} - -case "$1" in - # First check common extensions - *.png|*.PNG|*.jpg|*.JPG|*.bmp|*.jpeg|*.gif|*.xpm|*.webp|*.WEBP) _show_graphics "$1" ;; - *.avi|*.mp4|*.wmv|*.dat|*.3gp|*.vob|*.ogv|*.mkv|*.mpg|*.mpeg|*.fli|*.flc|*.flv|*.m2v|*.webm|*.mts|*.qt|*.divx|*.asf|*.asx|*.m4v|*.mov) - _preview_video "$1" ;; - # Then fallback to mimetypes - *) - mimetype=$(file --dereference --brief --mime-type -- "$1") - case "$mimetype" in - image/vnd.djvu*) - djvutxt "$1" || exiftool "$1" ;; - image/*) - _preview_image "$1" ;; - application/x-font*|font/*) - _preview_font "$1" ;; - video/*) - _preview_video "$1" ;; - *) - echo '----- File Type Classification -----' && file --dereference --brief -- "$1" ;; - esac ;; -esac diff --git a/roles/config/tasks/vifm.yml b/roles/config/tasks/vifm.yml index 7457640..1e8d481 100644 --- a/roles/config/tasks/vifm.yml +++ b/roles/config/tasks/vifm.yml @@ -5,15 +5,15 @@ state: directory mode: '755' -- name: vifm | Copy config +- name: vifm | Synchronize scripts and colors ansible.posix.synchronize: src: vifm/ dest: '{{ xdg_dir.config_home }}/vifm/' recursive: true delete: true -- name: vifm | Copy preview script +- name: vifm | Copy vifmrc template: - src: vifm/preview_vifm.j2 - dest: '{{ xdg_dir.config_home }}/vifm/scripts/preview_vifm' - mode: '755' + src: vifm/vifmrc.j2 + dest: '{{ xdg_dir.config_home }}/vifm/vifmrc' + mode: '644' diff --git a/roles/config/templates/fish/env.j2 b/roles/config/templates/fish/env.j2 index a300289..0b510bb 100644 --- a/roles/config/templates/fish/env.j2 +++ b/roles/config/templates/fish/env.j2 @@ -159,7 +159,7 @@ set -gx FZF_DEFAULT_OPTS "--multi --layout=reverse --inline-info --cycle --separ --color separator:{{ colors.highlight }},label:{{ colors.white2 }},border:{{ colors.highlight }}" {% endif %} set -gx FZF_DEFAULT_COMMAND "fd --type f --follow --hidden --exclude .git --color never" -set -gx FZF_CTRL_T_OPTS "--no-height --preview '$HOME/.local/libexec/preview {} 2>/dev/null'" +set -gx FZF_CTRL_T_OPTS "--no-height --preview '{{ xdg_dir.libexec_dir }}/preview {} \$FZF_PREVIEW_COLUMNS \$FZF_PREVIEW_LINES 2>/dev/null'" set -gx FZF_CTRL_T_COMMAND "fd . \$dir --follow --hidden --exclude .git --color never" set -gx FZF_ALT_C_OPTS "--preview 'lsd -1FAL --group-dirs first --icon always --color always {} 2>/dev/null'" set -gx FZF_ALT_C_COMMAND "fd --type d --follow --hidden --exclude .git --color never" diff --git a/roles/config/templates/vifm/preview_vifm.j2 b/roles/config/templates/vifm/preview_vifm.j2 deleted file mode 100644 index 4a1b529..0000000 --- a/roles/config/templates/vifm/preview_vifm.j2 +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/sh - -case "$1" in - # First check common extensions - *.wav|*.mp3|*.flac|*.m4a|*.ape|*.ac3|*.oga|*.ogg|*.ogx|*.spx|*.dsf|*.opus|*.dff|*.wma|*.wvc|*.wv) exiftool "$1" ;; - *.pdf) mutool draw -F txt -i -- "$1" 1-10 || pdftotext -l 10 -nopgbrk -q -- "$1" - || exiftool "$1" ;; - *.ps) pstotext "$1" || ps2ascii "$1" ;; - *.epub|*.fb2) pandoc -s -t markdown -- "$1" ;; - *.djvu) djvutxt "$1" || exiftool "$1" ;; - *.html|*.xhtml|*.htm) pandoc -s -t markdown -- "$1" || lynx -dump -- "$1" ;; - *.mkd|*.md|*.markdown) glow -s ~/.config/glow/styles/{{ theme }}.json "$1" || lowdown -t term "$1" || mdcat "$1" ;; - *.ipynb) notedown --from notebook "$1" --to markdown | pandoc -f markdown -t plain ;; - *.torrent) dumptorrent -v "$1" || transmission-show -- "$1" ;; - *.zip|*.war|*.ear|*.oxt|*.tar|*.tgz|*.tar.gz|*.tbz2|*.tar.bz2|*.tar.txz|*.txz|*.rar|*.7z|*.ace|*.rpm|*.deb|*.xbps|*.Z|*.lzo|*.lzma|*.lha|*.cpio|*.jar|*.lz|*.lzh) - bsdtar -tf "$1" ;; - *.iso) isoinfo -l -i "$1" ;; - *.doc) catdoc -- "$1" || pandoc -s -t markdown -- "$1" ;; - *.docx) pandoc -s -t markdown -- "$1" ;; - *.odt|*.ott|*.stw|*.sxc) pandoc -s -t markdown -- "$1" || odt2txt "$1" ;; - *.json|*.jsonc) gojq -C . "$1" || jaq --color always . "$1" || jq . "$1" || python3 -m json.tool -- "$1" ;; - *.[1-8]) man "$1" | col -b ;; - # Then fallback to mimetypes - *) - mimetype=$(file --dereference --brief --mime-type -- "$1") - case "$mimetype" in - inode/directory) - # Don't preview the inode ../ - if [ -z "${1##*/..*}" ]; then - echo "" - else - lsd -1FAL --group-dirs first --icon always --color always "$1" - fi ;; - application/zip|application/x-tar*|application/*-compressed-tar\ - |application/vnd.rar|application/x-7z-compressed|application/x-xz*\ - |application/x-bzip|application/gzip|application/zstd|application/zlib\ - |application/x-lzma|application/x-lzip|application/x-lha|application/x-lhz\ - |application/x-lzop|application/x-lz4|application/x-lrzip) - bsdtar -tf "$1" ;; - application/json) - gojq -C . "$1" || jaq --color always . "$1" || jq . "$1" || python3 -m json.tool -- "$1" || bat --style=plain --color=always "$1" ;; - text/*|application/javascript) - bat --style=plain --color=always "$1" ;; - *) - echo '----- File Type Classification -----' && file --dereference --brief -- "$1" ;; - esac ;; -esac diff --git a/roles/config/files/vifm/vifmrc b/roles/config/templates/vifm/vifmrc.j2 similarity index 93% rename from roles/config/files/vifm/vifmrc rename to roles/config/templates/vifm/vifmrc.j2 index 3615134..4b2c765 100644 --- a/roles/config/files/vifm/vifmrc +++ b/roles/config/templates/vifm/vifmrc.j2 @@ -131,19 +131,16 @@ command! df df -h %m 2> /dev/null command! diff nvim -d %f %F command! gzip tar -cvzf %a %f command! xz bsdtar -cvJf %a %f -command! zstd zstd -zo %a %f command! extract bsdtar -xvf %c command! shred shred -fu %f command! run !! ./%f -command! make !!make %a -command! mkcd :mkdir %a | cd %a command! vgrep nvim "+grep %a" command! reload :write | restart command! exif exiftool -all= -overwrite_original %f " fzf file command! FZFfile : set noquickview - \| let $FZF_RES = term('fzf --prompt "File: " --no-multi --preview "$HOME/.local/libexec/preview {} 2>/dev/null" 2>&0') + \| let $FZF_RES = term('fzf --prompt "File: " --no-multi --preview "{{ xdg_dir.libexec_dir }}/preview {} \$FZF_PREVIEW_COLUMNS \$FZF_PREVIEW_LINES 2>/dev/null" 2>&0') \| if $FZF_RES != '' \| execute 'goto' fnameescape($FZF_RES) \| endif @@ -173,8 +170,8 @@ mark D ~/Downloads mark P ~/Pictures mark V ~/Videos mark U ~/Music -mark f ~/.config -mark l ~/.local/share +mark f {{ xdg_dir.config_home }} +mark l {{ xdg_dir.data_home }} mark e /etc mark u /usr/share mark o /opt @@ -202,27 +199,23 @@ filextype {*.ps,*.eps,*.ps.gz}, filextype {*.mobi,*.pdb} \ ebook-viewer %f, \ FBReader %f, -filextype {*.djvu,*.epub,*.cbr,*.cbz,*.cbt,*.cb7}, +filextype {*.djvu,*.epub,*.cbr,*.cbz,*.cbt,*.cb7} \ zathura %f, " Audio filetype {*.wav,*.mp3,*.flac,*.m4a,*.wma,*.ape,*.ac3,*.og[agx],*.spx,*.opus},