From 8c0490c981e98763cbbfc81b6b34d0af2b1cdd13 Mon Sep 17 00:00:00 2001 From: TiynGER Date: Tue, 31 Mar 2020 20:32:16 +0200 Subject: [PATCH] bin structure and vifm preview --- .config/vifm/vifmrc | 5 +- .local/bin/etc/sshmenu | 5 + .local/bin/{tools => etc}/textemp | 0 .local/bin/suckless/suckclean | 4 + .local/bin/suckless/suckdiff | 4 + .local/bin/suckless/suckmerge | 4 + .local/bin/tools/dwm/dmenumount | 59 ++++++++ .local/bin/tools/dwm/dmenuumount | 41 ++++++ .local/bin/tools/{ => dwm}/lmc | 0 .local/bin/tools/dwm/startpagesearch | 20 +++ .local/bin/tools/{ => dwm}/togglemonitor | 0 .local/bin/tools/{ => dwm}/toggletouchpad | 0 .local/bin/tools/{ => nvim}/compiler | 0 .local/bin/{etc => tools/nvim}/opout | 0 .local/bin/tools/{ => nvim}/texclear | 0 .local/bin/{ => tools}/statusbar/battery | 0 .local/bin/{ => tools}/statusbar/clock | 0 .local/bin/{ => tools}/statusbar/cpu | 0 .local/bin/{ => tools}/statusbar/disk | 0 .local/bin/{ => tools}/statusbar/dwmbar | 0 .local/bin/{ => tools}/statusbar/internet | 0 .local/bin/{ => tools}/statusbar/memory | 0 .local/bin/{ => tools}/statusbar/refbar | 0 .local/bin/{ => tools}/statusbar/volume | 0 .local/bin/tools/vifm/vifmimg | 165 ++++++++++++++++++++++ .local/bin/{ => tools}/vifm/vifmrun | 15 +- .local/bin/vifm/vifmimg | 53 ------- 27 files changed, 316 insertions(+), 59 deletions(-) create mode 100755 .local/bin/etc/sshmenu rename .local/bin/{tools => etc}/textemp (100%) create mode 100755 .local/bin/tools/dwm/dmenumount create mode 100755 .local/bin/tools/dwm/dmenuumount rename .local/bin/tools/{ => dwm}/lmc (100%) create mode 100755 .local/bin/tools/dwm/startpagesearch rename .local/bin/tools/{ => dwm}/togglemonitor (100%) rename .local/bin/tools/{ => dwm}/toggletouchpad (100%) rename .local/bin/tools/{ => nvim}/compiler (100%) rename .local/bin/{etc => tools/nvim}/opout (100%) rename .local/bin/tools/{ => nvim}/texclear (100%) rename .local/bin/{ => tools}/statusbar/battery (100%) rename .local/bin/{ => tools}/statusbar/clock (100%) rename .local/bin/{ => tools}/statusbar/cpu (100%) rename .local/bin/{ => tools}/statusbar/disk (100%) rename .local/bin/{ => tools}/statusbar/dwmbar (100%) rename .local/bin/{ => tools}/statusbar/internet (100%) rename .local/bin/{ => tools}/statusbar/memory (100%) rename .local/bin/{ => tools}/statusbar/refbar (100%) rename .local/bin/{ => tools}/statusbar/volume (100%) create mode 100755 .local/bin/tools/vifm/vifmimg rename .local/bin/{ => tools}/vifm/vifmrun (59%) delete mode 100755 .local/bin/vifm/vifmimg diff --git a/.config/vifm/vifmrc b/.config/vifm/vifmrc index 11d9140..af479bf 100644 --- a/.config/vifm/vifmrc +++ b/.config/vifm/vifmrc @@ -211,7 +211,10 @@ filextype *.avi,*.mp4,*.wmv,*.dat,*.3gp,*.ogv,*.mkv,*.mpg,*.mpeg,*.vob, fileviewer *.avi,*.mp4,*.wmv,*.dat,*.3gp,*.ogv,*.mkv,*.mpg,*.mpeg,*.vob, \*.fl[icv],*.m2v,*.mov,*.webm,*.ts,*.mts,*.m4v,*.r[am],*.qt,*.divx, \*.as[fx] - \ ffprobe -pretty %c 2>&1 + \ vifmimg videopreview %px %py %pw %ph %c + \ %pc + \ vifmimg clear + "\ ffprobe -pretty %c 2>&1 " Web filextype *.html,*.htm diff --git a/.local/bin/etc/sshmenu b/.local/bin/etc/sshmenu new file mode 100755 index 0000000..ee73d30 --- /dev/null +++ b/.local/bin/etc/sshmenu @@ -0,0 +1,5 @@ +#!/bin/sh + +ssh_host=$(cat ~/.ssh/config | grep "Host " | sed "s/Host\ //g" | dmenu) + +[[ -z ssh_host ]] || st -e ssh -t $ssh_host diff --git a/.local/bin/tools/textemp b/.local/bin/etc/textemp similarity index 100% rename from .local/bin/tools/textemp rename to .local/bin/etc/textemp diff --git a/.local/bin/suckless/suckclean b/.local/bin/suckless/suckclean index 5fd3b4a..33f9bd2 100755 --- a/.local/bin/suckless/suckclean +++ b/.local/bin/suckless/suckclean @@ -1,2 +1,6 @@ #!/bin/zsh + +# for cleaning up the master branch of a git directory according to my suckless patch structure +# e.g. see dwm/st/etc + make clean && rm -f config.h && git reset --hard origin/base diff --git a/.local/bin/suckless/suckdiff b/.local/bin/suckless/suckdiff index b20bbe3..3952da4 100755 --- a/.local/bin/suckless/suckdiff +++ b/.local/bin/suckless/suckdiff @@ -1,4 +1,8 @@ #!/usr/bin/zsh + +# for showing the diffs to the master branch of a git directory according to my suckless patch structure +# e.g. see dwm/st/etc + git checkout master && dotfiles="/home/tiynger/.config/dotfiles/suckless" project=$(basename $(pwd)) diff --git a/.local/bin/suckless/suckmerge b/.local/bin/suckless/suckmerge index e4641eb..103cb5f 100755 --- a/.local/bin/suckless/suckmerge +++ b/.local/bin/suckless/suckmerge @@ -1,4 +1,8 @@ #!/bin/zsh + +# for merging all branches into the master branch of a git directory according to my suckless patch structure +# e.g. see dwm/st/etc + suckdiff && git reset --hard origin/base && for branch in $(git for-each-ref --format='%(refname)' refs/heads/ | cut -d'/' -f3); do diff --git a/.local/bin/tools/dwm/dmenumount b/.local/bin/tools/dwm/dmenumount new file mode 100755 index 0000000..0de5f0f --- /dev/null +++ b/.local/bin/tools/dwm/dmenumount @@ -0,0 +1,59 @@ +#!/bin/sh +# Gives a dmenu prompt to mount unmounted drives. +# If they're in /etc/fstab, they'll be mounted automatically. +# Otherwise, you'll be prompted to give a mountpoint from already existsing directories. +# If you input a novel directory, it will prompt you to create that directory. + +getmount() { \ + [ -z "$chosen" ] && exit 1 + mp="$(find $1 2>/dev/null | dmenu -i -p "Type in mount point.")" + [ "$mp" = "" ] && exit 1 + if [ ! -d "$mp" ]; then + mkdiryn=$(printf "No\\nYes" | dmenu -i -p "$mp does not exist. Create it?") + [ "$mkdiryn" = "Yes" ] && (mkdir -p "$mp" || sudo -A mkdir -p "$mp") + fi + } + +mountusb() { \ + chosen="$(echo "$usbdrives" | dmenu -i -p "Mount which drive?" | awk '{print $1}')" + sudo -A mount "$chosen" 2>/dev/null && notify-send "💻 USB mounting" "$chosen mounted." && exit 0 + alreadymounted=$(lsblk -nrpo "name,type,mountpoint" | awk '$2=="part"&&$3!~/\/boot|\/home$|SWAP/&&length($3)>1{printf "-not \\( -path *%s -prune \\) \\ \n",$3}') + getmount "/mnt /media /mount /home -maxdepth 5 -type d $alreadymounted" + partitiontype="$(lsblk -no "fstype" "$chosen")" + case "$partitiontype" in + "vfat") sudo -A mount -t vfat "$chosen" "$mp" -o rw,umask=0000;; + *) sudo -A mount "$chosen" "$mp"; user="$(whoami)"; ug="$(groups | awk '{print $1}')"; sudo -A chown "$user":"$ug" "$mp";; + esac + notify-send "💻 USB mounting" "$chosen mounted to $mp." + } + +mountandroid() { \ + chosen=$(echo "$anddrives" | dmenu -i -p "Which Android device?" | cut -d : -f 1) + getmount "$HOME -maxdepth 3 -type d" + simple-mtpfs --device "$chosen" "$mp" + notify-send "🤖 Android Mounting" "Android device mounted to $mp." + } + +asktype() { \ + case $(printf "USB\\nAndroid" | dmenu -i -p "Mount a USB drive or Android device?") in + USB) mountusb ;; + Android) mountandroid ;; + esac + } + +anddrives=$(simple-mtpfs -l 2>/dev/null) +usbdrives="$(lsblk -rpo "name,type,size,mountpoint" | awk '$2=="part"&&$4==""{printf "%s (%s)\n",$1,$3}')" + +if [ -z "$usbdrives" ]; then + [ -z "$anddrives" ] && echo "No USB drive or Android device detected" && exit + echo "Android device(s) detected." + mountandroid +else + if [ -z "$anddrives" ]; then + echo "USB drive(s) detected." + mountusb + else + echo "Mountable USB drive(s) and Android device(s) detected." + asktype + fi +fi diff --git a/.local/bin/tools/dwm/dmenuumount b/.local/bin/tools/dwm/dmenuumount new file mode 100755 index 0000000..dee53e7 --- /dev/null +++ b/.local/bin/tools/dwm/dmenuumount @@ -0,0 +1,41 @@ +#!/bin/sh +# A dmenu prompt to unmount drives. +# Provides you with mounted partitions, select one to unmount. +# Drives mounted at /, /boot and /home will not be options to unmount. + +unmountusb() { + [ -z "$drives" ] && exit + chosen=$(echo "$drives" | dmenu -i -p "Unmount which drive?" | awk '{print $1}') + [ -z "$chosen" ] && exit + sudo -A umount "$chosen" && notify-send "💻 USB unmounting" "$chosen unmounted." + } + +unmountandroid() { \ + chosen=$(awk '/simple-mtpfs/ {print $2}' /etc/mtab | dmenu -i -p "Unmount which device?") + [ -z "$chosen" ] && exit + sudo -A umount -l "$chosen" && notify-send "🤖 Android unmounting" "$chosen unmounted." + } + +asktype() { \ + case "$(printf "USB\\nAndroid" | dmenu -i -p "Unmount a USB drive or Android device?")" in + USB) unmountusb ;; + Android) unmountandroid ;; + esac + } + +drives=$(lsblk -nrpo "name,type,size,mountpoint" | awk '$2=="part"&&$4!~/\/boot|\/home$|SWAP/&&length($4)>1{printf "%s (%s)\n",$4,$3}') + +if ! grep simple-mtpfs /etc/mtab; then + [ -z "$drives" ] && echo "No drives to unmount." && exit + echo "Unmountable USB drive detected." + unmountusb +else + if [ -z "$drives" ] + then + echo "Unmountable Android device detected." + unmountandroid + else + echo "Unmountable USB drive(s) and Android device(s) detected." + asktype + fi +fi diff --git a/.local/bin/tools/lmc b/.local/bin/tools/dwm/lmc similarity index 100% rename from .local/bin/tools/lmc rename to .local/bin/tools/dwm/lmc diff --git a/.local/bin/tools/dwm/startpagesearch b/.local/bin/tools/dwm/startpagesearch new file mode 100755 index 0000000..3498d18 --- /dev/null +++ b/.local/bin/tools/dwm/startpagesearch @@ -0,0 +1,20 @@ +#!/bin/sh +# Gives a dmenu prompt to search Startpage. +# Without input, will open Startpage.com. +# URLs will be directly handed to the browser. +# Anything else, it search it. +browser=${RTVBROWSER:-firefox} + +pgrep -x dmenu && exit + +choice=$(echo "Startpage" | dmenu -i -p "Search Startpage:") || exit 1 + +if [ "$choice" = "Startpage" ]; then + $RTV_BROWSER "https://startpage.com" +else + if echo "$choice" | grep "^(http:\/\/|https:\/\/)?[a-zA-Z0-9]+\.[a-zA-Z]+(/)?.*$"; then + $RTV_BROWSER "$choice" + else + $RTV_BROWSER "https://startpage.com/do/search/?q=$choice" + fi +fi diff --git a/.local/bin/tools/togglemonitor b/.local/bin/tools/dwm/togglemonitor similarity index 100% rename from .local/bin/tools/togglemonitor rename to .local/bin/tools/dwm/togglemonitor diff --git a/.local/bin/tools/toggletouchpad b/.local/bin/tools/dwm/toggletouchpad similarity index 100% rename from .local/bin/tools/toggletouchpad rename to .local/bin/tools/dwm/toggletouchpad diff --git a/.local/bin/tools/compiler b/.local/bin/tools/nvim/compiler similarity index 100% rename from .local/bin/tools/compiler rename to .local/bin/tools/nvim/compiler diff --git a/.local/bin/etc/opout b/.local/bin/tools/nvim/opout similarity index 100% rename from .local/bin/etc/opout rename to .local/bin/tools/nvim/opout diff --git a/.local/bin/tools/texclear b/.local/bin/tools/nvim/texclear similarity index 100% rename from .local/bin/tools/texclear rename to .local/bin/tools/nvim/texclear diff --git a/.local/bin/statusbar/battery b/.local/bin/tools/statusbar/battery similarity index 100% rename from .local/bin/statusbar/battery rename to .local/bin/tools/statusbar/battery diff --git a/.local/bin/statusbar/clock b/.local/bin/tools/statusbar/clock similarity index 100% rename from .local/bin/statusbar/clock rename to .local/bin/tools/statusbar/clock diff --git a/.local/bin/statusbar/cpu b/.local/bin/tools/statusbar/cpu similarity index 100% rename from .local/bin/statusbar/cpu rename to .local/bin/tools/statusbar/cpu diff --git a/.local/bin/statusbar/disk b/.local/bin/tools/statusbar/disk similarity index 100% rename from .local/bin/statusbar/disk rename to .local/bin/tools/statusbar/disk diff --git a/.local/bin/statusbar/dwmbar b/.local/bin/tools/statusbar/dwmbar similarity index 100% rename from .local/bin/statusbar/dwmbar rename to .local/bin/tools/statusbar/dwmbar diff --git a/.local/bin/statusbar/internet b/.local/bin/tools/statusbar/internet similarity index 100% rename from .local/bin/statusbar/internet rename to .local/bin/tools/statusbar/internet diff --git a/.local/bin/statusbar/memory b/.local/bin/tools/statusbar/memory similarity index 100% rename from .local/bin/statusbar/memory rename to .local/bin/tools/statusbar/memory diff --git a/.local/bin/statusbar/refbar b/.local/bin/tools/statusbar/refbar similarity index 100% rename from .local/bin/statusbar/refbar rename to .local/bin/tools/statusbar/refbar diff --git a/.local/bin/statusbar/volume b/.local/bin/tools/statusbar/volume similarity index 100% rename from .local/bin/statusbar/volume rename to .local/bin/tools/statusbar/volume diff --git a/.local/bin/tools/vifm/vifmimg b/.local/bin/tools/vifm/vifmimg new file mode 100755 index 0000000..40b7844 --- /dev/null +++ b/.local/bin/tools/vifm/vifmimg @@ -0,0 +1,165 @@ +#!/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 previews behave the same way as video previews. + +#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. + +# The messy code below is for moving pages in pdf files in the vifm file preview by +# utilizing the < and > keys which will be bound to `vifmimg inc` or `vifmimg dec`. +PDF_PAGE_CONFIG="$HOME/.config/vifm/vifmimgpdfpage" +PDF_FILE_CONFIG="$HOME/.config/vifm/vifmimgpdffile" +PDF_PAGE=1 +PDF_FILE="" +# Initialize the variables and required files +[[ -f "$PDF_PAGE_CONFIG" ]] && PDF_PAGE=$(cat $PDF_PAGE_CONFIG) || touch $PDF_PAGE_CONFIG +[[ -f "$PDF_FILE_CONFIG" ]] && PDF_FILE=$(cat $PDF_FILE_CONFIG) || touch $PDF_FILE_CONFIG + + +# Create temporary working directory if the directory structure doesn't exist +if [[ ! -d "/tmp$PWD/" ]]; then + mkdir -p "/tmp$PWD/" +fi + +function inc() { + VAL="$(cat $PDF_PAGE_CONFIG)" + echo "$(expr $VAL + 1)" > $PDF_PAGE_CONFIG +} + +function dec() { + VAL="$(cat $PDF_PAGE_CONFIG)" + echo "$(expr $VAL - 1)" > $PDF_PAGE_CONFIG + if [[ $VAL -le 0 ]]; then + echo 0 > $PDF_PAGE_CONFIG + fi +} + +function previewclear() { + declare -p -A cmd=([action]=remove [identifier]="$ID_PREVIEW") \ + > "$FIFO_UEBERZUG" +} + +function fileclean() { + if [[ -f "/tmp$PWD/$6.png" ]]; then + rm -f "/tmp$PWD/$6.png" + elif [[ -d "/tmp$PWD/$6/" ]]; then + rm -rf "/tmp$PWD/$6/" + fi +} + +function preview() { + declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW" + [x]="$2" [y]="$3" [width]="$4" [height]="$5" \ + [path]="$PWD/$6") \ + > "$FIFO_UEBERZUG" +} + +function previewvideo() { + if [[ ! -f "/tmp$PWD/$6.png" ]]; then + ffmpegthumbnailer -i "$PWD/$6" -o "/tmp$PWD/$6.png" -s 0 -q 10 + fi + declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW" + [x]="$2" [y]="$3" [width]="$4" [height]="$5" \ + [path]="/tmp$PWD/$6.png") \ + > "$FIFO_UEBERZUG" +} + +function previewepub() { + if [[ ! -f "/tmp$PWD/$6.png" ]]; then + epub-thumbnailer "$6" "/tmp$PWD/$6.png" 1024 + fi + declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW" + [x]="$2" [y]="$3" [width]="$4" [height]="$5" \ + [path]="/tmp$PWD/$6.png") \ + > "$FIFO_UEBERZUG" +} + +function previewaudio() { + if [[ ! -f "/tmp${PWD}/$6.png" ]]; then + ffmpeg -i "$6" "/tmp${PWD}/$6.png" -y &> /dev/null + fi + declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW" + [x]="$2" [y]="$3" [width]="$4" [height]="$5" \ + [path]="/tmp${PWD}/$6.png") \ + > "$FIFO_UEBERZUG" +} + +function previewgif() { + if [[ ! -d "/tmp$PWD/$6/" ]]; then + mkdir -p "/tmp$PWD/$6/" + convert -coalesce "$PWD/$6" "/tmp$PWD/$6/$6.png" + fi + 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 +} + +function previewpdf() { + if [[ ! "$6" == "$PDF_FILE" ]]; then + PDF_PAGE=1 + echo 1 > $PDF_PAGE_CONFIG + rm -f "/tmp$PWD/$6.png" + fi + + if [[ ! "$PDF_PAGE" == "1" ]] && [[ -f "/tmp$PWD/$6.png" ]]; then + rm -f "/tmp$PWD/$6.png" + fi + + if [[ ! -f "/tmp$PWD/$6.png" ]]; then + pdftoppm -png -f $PDF_PAGE -singlefile "$6" "/tmp$PWD/$6" + fi + echo "$6" > $PDF_FILE_CONFIG + + declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW" + [x]="$2" [y]="$3" [width]="$4" [height]="$5" \ + [path]="/tmp$PWD/$6.png") \ + > "$FIFO_UEBERZUG" +} + + +function previewmagick() { + if [[ ! -f "/tmp$PWD/$6.png" ]]; then + convert -thumbnail $(identify -format "%wx%h" "$6") "$PWD/$6" "/tmp$PWD/$6.png" + fi + declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW" + [x]="$2" [y]="$3" [width]="$4" [height]="$5" \ + [path]="/tmp$PWD/$6.png") \ + > "$FIFO_UEBERZUG" +} + + + +function main() { + case "$1" in + "inc") inc "$@" ;; + "dec") dec "$@" ;; + "clear") previewclear "$@" ;; + "clean") fileclean "$@" ;; + "draw") preview "$@" ;; + "videopreview") previewvideo "$@" ;; + "epubpreview") previewepub "$@" ;; + "gifpreview") previewgif "$@" ;; + "pdfpreview") previewpdf "$@" ;; + "magickpreview") previewmagick "$@" ;; + "audiopreview") previewaudio "$@" ;; + "*") echo "Unknown command: '$@'" ;; + esac +} +main "$@" diff --git a/.local/bin/vifm/vifmrun b/.local/bin/tools/vifm/vifmrun similarity index 59% rename from .local/bin/vifm/vifmrun rename to .local/bin/tools/vifm/vifmrun index 9eda32a..edd580a 100755 --- a/.local/bin/vifm/vifmrun +++ b/.local/bin/tools/vifm/vifmrun @@ -1,15 +1,20 @@ #!/usr/bin/env bash export FIFO_UEBERZUG="/tmp/vifm-ueberzug-${PPID}" +if [ ! -f "/usr/bin/ueberzug" ]; then + vifm + exit +fi + function cleanup { rm "$FIFO_UEBERZUG" 2>/dev/null pkill -P $$ 2>/dev/null } - +pkill -P $$ 2>/dev/null rm "$FIFO_UEBERZUG" 2>/dev/null -mkfifo "$FIFO_UEBERZUG" -trap cleanup EXIT -tail --follow "$FIFO_UEBERZUG" | ueberzug layer --silent --parser bash & +mkfifo "$FIFO_UEBERZUG" >/dev/null +trap cleanup EXIT 2>/dev/null +tail --follow "$FIFO_UEBERZUG" | ueberzug layer --silent --parser bash 2>&1 >/dev/null & -vifm +vifm "$@" cleanup diff --git a/.local/bin/vifm/vifmimg b/.local/bin/vifm/vifmimg deleted file mode 100755 index e5d8763..0000000 --- a/.local/bin/vifm/vifmimg +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env bash -readonly ID_PREVIEW="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 - echo -e "Loading preview..\nFile: $6" - [[ ! -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 - echo -e "Loading preview..\nFile: $6" - [[ ! -d "/tmp${PWD}/$6/" ]] && mkdir -p "/tmp${PWD}/$6/" && convert -coalesce "${PWD}/$6" "/tmp${PWD}/$6/$6.png" - 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 - - elif [[ "$1" == "pdfpreview" ]]; then - echo -e "Loading preview..\nFile: $6" - [[ ! -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