summaryrefslogtreecommitdiff
path: root/.config/vifm/scripts
diff options
context:
space:
mode:
authorVito Graffagnino <vito@graffagnino.xyz>2020-09-08 18:10:49 +0100
committerVito Graffagnino <vito@graffagnino.xyz>2020-09-08 18:10:49 +0100
commit3b0142cedcde39e4c2097ecd916a870a3ced5ec6 (patch)
tree2116c49a845dfc0945778f2aa3e2118d72be428b /.config/vifm/scripts
parent8cc927e930d5b6aafe3e9862a61e81705479a1b4 (diff)
Added the relevent parts of the .config directory. Alss add ssh config
Diffstat (limited to '.config/vifm/scripts')
-rwxr-xr-x.config/vifm/scripts/README-vifm-imagepreview.sh6
-rwxr-xr-x.config/vifm/scripts/vifm-imagepreview.sh50
-rwxr-xr-x.config/vifm/scripts/vifmimg64
-rwxr-xr-x.config/vifm/scripts/vifmrun14
4 files changed, 134 insertions, 0 deletions
diff --git a/.config/vifm/scripts/README-vifm-imagepreview.sh b/.config/vifm/scripts/README-vifm-imagepreview.sh
new file mode 100755
index 0000000..7694952
--- /dev/null
+++ b/.config/vifm/scripts/README-vifm-imagepreview.sh
@@ -0,0 +1,6 @@
+This directory is dedicated for user-supplied scripts/executables.
+vifm modifies its PATH environment variable to let user run those
+scripts without specifying full path. All subdirectories are added
+as well. File in a subdirectory overrules file with the same name
+in parent directories. Restart might be needed to recognize files
+in newly created or renamed subdirectories. \ No newline at end of file
diff --git a/.config/vifm/scripts/vifm-imagepreview.sh b/.config/vifm/scripts/vifm-imagepreview.sh
new file mode 100755
index 0000000..fbe0431
--- /dev/null
+++ b/.config/vifm/scripts/vifm-imagepreview.sh
@@ -0,0 +1,50 @@
+#!/bin/bash -
+#===============================================================================
+#
+# FILE: vifm-imagepreview.sh
+#
+# USAGE: ./vifm-imagepreview.sh
+#
+# DESCRIPTION: Image previewer for vifm.
+# Based on script by z3bra -- 2014-01-21
+# This is called by vifm by adding the following line to vimfrc file:
+#
+# fileviewer *.bmp,*.jpg,*.jpeg,*.png,*.gif,*.xpm vifm-imagepreviewer.sh %px %py %pw %ph %c
+#
+# OPTIONS: ---
+# REQUIREMENTS: ---
+# BUGS: ---
+# NOTES: ---
+# AUTHOR: Vito G. Graffagnino (), v.graffagnino@btinternet.com
+# ORGANIZATION:
+# CREATED: 04/05/17 11:19:39
+# REVISION: ---
+#===============================================================================
+set -o nounset # Treat unset variables as an error
+W3MIMGDISPLAY="/usr/lib64/w3m/w3mimgdisplay"
+FONTH=15 # Size of one terminal row
+FONTW=7 # Size of one terminal column
+X=$1
+Y=$2
+COLUMNS=$3
+LINES=$4
+FILENAME=$5
+read width height <<< `echo "5;$FILENAME" | $W3MIMGDISPLAY`
+if [ -z "$width" -o -z "$height" ]; then
+ echo 'Error: Failed to obtain image size.'
+ exit 1
+fi
+x=$((FONTW * X))
+y=$((FONTH * Y))
+max_width=$((FONTW * COLUMNS))
+max_height=$((FONTH * LINES))
+if [ "$width" -gt "$max_width" ]; then
+ height=$((height * max_width / width))
+ width=$max_width
+fi
+if [ "$height" -gt "$max_height" ]; then
+ width=$((width * max_height / height))
+ height=$max_height
+fi
+w3m_command="0;1;$x;$y;$width;$height;;;;;$FILENAME\n4;\n3;"
+echo -e "$w3m_command" | $W3MIMGDISPLAY
diff --git a/.config/vifm/scripts/vifmimg b/.config/vifm/scripts/vifmimg
new file mode 100755
index 0000000..98e15c8
--- /dev/null
+++ b/.config/vifm/scripts/vifmimg
@@ -0,0 +1,64 @@
+#!/usr/bin/env bash
+readonly ID_PREVIEW="preview"
+
+#PLAY_GIF="yes"
+# By enabling this option the GIF will be animated, by leaving it commented like it
+# is now will make the gif preview behave the same was a video preview.
+
+#AUTO_REMOVE="yes"
+# By enabling this option the script will remove the preview file after it is drawn
+# and by doing so the preview will always be up-to-date with the file.
+# This however, requires more CPU and therefore affects the overall performance.
+
+if [ -e "$FIFO_UEBERZUG" ]; then
+ if [[ "$1" == "draw" ]]; then
+ declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW"
+ [x]="$2" [y]="$3" [width]="$4" [height]="$5" \
+ [path]="$PWD/$6") \
+ > "$FIFO_UEBERZUG"
+ elif [[ "$1" == "videopreview" ]]; then
+ [[ ! -d "/tmp$PWD/$6/" ]] && mkdir -p "/tmp$PWD/$6/"
+ [[ ! -f "/tmp$PWD/$6.png" ]] && ffmpegthumbnailer -i "$PWD/$6" -o "/tmp$PWD/$6.png" -s 0 -q 10
+ declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW"
+ [x]="$2" [y]="$3" [width]="$4" [height]="$5" \
+ [path]="/tmp$PWD/$6.png") \
+ > "$FIFO_UEBERZUG"
+ elif [[ "$1" == "gifpreview" ]]; then
+ [[ ! -d "/tmp$PWD/$6/" ]] && mkdir -p "/tmp$PWD/$6/" && convert -coalesce "$PWD/$6" "/tmp$PWD/$6/$6.png"
+ if [[ ! -z "$PLAY_GIF" ]]; then
+ for frame in $(ls -1 /tmp$PWD/$6/$6*.png | sort -V); do
+ declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW"
+ [x]="$2" [y]="$3" [width]="$4" [height]="$5" \
+ [path]="$frame") \
+ > "$FIFO_UEBERZUG"
+ # Sleep between frames to make the animation smooth.
+ sleep .07
+ done
+ else
+ declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW"
+ [x]="$2" [y]="$3" [width]="$4" [height]="$5" \
+ [path]="/tmp$PWD/$6/$6-0.png") \
+ > "$FIFO_UEBERZUG"
+ fi
+ elif [[ "$1" == "epubpreview" ]]; then
+ [[ ! -d "/tmp$PWD/$6/" ]] && mkdir -p "/tmp$PWD/$6/"
+ [[ ! -f "/tmp$PWD/$6.png" ]] && epub-thumbnailer "$6" "/tmp$PWD/$6.png" 512
+ declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW"
+ [x]="$2" [y]="$3" [width]="$4" [height]="$5" \
+ [path]="/tmp$PWD/$6.png") \
+ > "$FIFO_UEBERZUG"
+ elif [[ "$1" == "pdfpreview" ]]; then
+ [[ ! -d "/tmp$PWD/$6/" ]] && mkdir -p "/tmp$PWD/$6/"
+ [[ ! -f "/tmp$PWD/$6.png" ]] && pdftoppm -png -singlefile "$6" "/tmp$PWD/$6"
+ declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW"
+ [x]="$2" [y]="$3" [width]="$4" [height]="$5" \
+ [path]="/tmp$PWD/$6.png") \
+ > "$FIFO_UEBERZUG"
+ elif [[ "$1" == "clear" ]]; then
+ declare -p -A cmd=([action]=remove [identifier]="$ID_PREVIEW") \
+ > "$FIFO_UEBERZUG"
+ [[ ! -z $AUTO_REMOVE ]] && [[ -f "/tmp$PWD/$6.png" ]] && rm -f "/tmp$PWD/$6.png"
+ [[ ! -z $AUTO_REMOVE ]] && [[ -d "/tmp$PWD/$6/" ]] && rm -rf "/tmp$PWD/$6/"
+
+ fi
+fi
diff --git a/.config/vifm/scripts/vifmrun b/.config/vifm/scripts/vifmrun
new file mode 100755
index 0000000..cc27b25
--- /dev/null
+++ b/.config/vifm/scripts/vifmrun
@@ -0,0 +1,14 @@
+#!/usr/bin/env bash
+export FIFO_UEBERZUG="/tmp/vifm-ueberzug-${PPID}"
+
+function cleanup {
+ rm "$FIFO_UEBERZUG" 2>/dev/null
+ pkill -P $$ 2>/dev/null
+}
+rm "$FIFO_UEBERZUG" 2>/dev/null
+mkfifo "$FIFO_UEBERZUG" 2>/dev/null
+trap cleanup EXIT 2>/dev/null
+tail --follow "$FIFO_UEBERZUG" | ueberzug layer --silent --parser bash &
+
+vifm
+cleanup