sped up wv significantly

This commit is contained in:
Alexander Bocken 2021-01-02 10:54:22 +01:00
parent 04e37d98fb
commit 7bc2aeb23d
Signed by: Alexander
GPG Key ID: 1D237BE83F9B05E8
2 changed files with 16 additions and 19 deletions

View File

@ -6,29 +6,31 @@ shell="$(ps aux | grep $( ppid ) | head -n1 | awk '{print $11}' )"
document_dirs="$HOME/bks/* $HOME/eth/* $HOME/dox/*"
#force launch dmenu via cmd
if [ "$1" = "launchdmenu" ]; then
file="$( du -a $document_dirs | awk '{for(i=2; i<NF; i++){printf("%s ", $i)}printf("%s\n", $NF)}'| dmenu -l 10 -p 'open what file?')"
file="$( find $document_dirs -type f | sed "s|$HOME|~|"| dmenu -l 10 -p 'open what file?')"
#/bin/sh means it's probably from dmenu_run (it's ugly but works)
elif [ ! "$shell" = "/bin/sh" ]; then
currentdir="$(pwd)"
file="$( du -a $document_dirs | awk '{for(i=2; i<NF; i++){printf("%s ", $i)}printf("%s\n", $NF)}' | fzf -e --query="$*")"
file="$( find $document_dirs -type f | sed "s|$HOME|~|" | fzf -e --query="$*")"
path="$(printf '%s%s' "$HOME" "${file//\~/}")"
[ -z "$file" ] && exit
cd "$( dirname "$file" )" || exit
if rifle -l "$file" | head -n1 | grep -q 'EDITOR';then
rifle "$file"
cd "$( dirname "$path" )" || exit
if rifle -l "$path" | head -n1 | grep -q 'EDITOR';then
rifle "$path"
else
rifle "$file" & disown
rifle "$path" & disown
fi
cd "$currentdir" || exit
exit
#launch dmenu as it's probably in dmenu_run
else
file="$( du -a $document_dirs | awk '{for(i=2; i<NF; i++){printf("%s ", $i)}printf("%s\n", $NF)}'| dmenu -l 10 -p 'open what file?' -it "$*" )"
file="$( find $document_dirs -type f | sed "s|$HOME|~|" | dmenu -l 10 -p 'open what file?' -it "$*" )"
fi
#process selection if it's from dmenu
[ -z "$file" ] && exit
cd "$( dirname "$file" )" || exit
if rifle -l "$file" | head -n1 | grep -q 'EDITOR';then
st rifle "$file"
path="$(printf '%s%s' "$HOME" "${file//\~/}")"
cd "$( dirname "$path" )" || exit
if rifle -l "$path" | head -n1 | grep -q 'EDITOR';then
st rifle "$path"
else
rifle "$file"
rifle "$path"
fi

View File

@ -1,11 +1,6 @@
#!/bin/sh
alldata="/tmp/allfiles$$"
videos="/tmp/videos$$"
du -a ~/vids/* --time | awk '!($1="")' | sort -bgr | awk '!($1="")' | awk '!($1="")' | sed 's/^ //' > $alldata
touch $videos
while read -r line; do
[ -f "$line" ] && echo "$line" >> $videos
done <$alldata
dmenu -i -l 30 -p "Choose a video to watch:" <"$videos" | sed 's/^/\"/' | sed 's/$/\"/' | xargs -r rifle
rm "$alldata"
du -a ~/vids/* --time | awk '!($1="")' | sort -bgr -k1 | awk '!($1="")' | awk '!($1="")' | sed 's/^ //' | grep -v "$(find ~/vids/* -type d | sed 's/$/\$/; s/\[/\\[/g; s/\]/\\]/g')" | sed "s|$HOME|\~|" > $videos
path="$(dmenu -i -l 30 -p "Choose a video to watch:" <"$videos" | sed "s|\~|$HOME|")"
[ -n "$path" ] && rifle "$path"
rm "$videos"