Update plugins to support some env vars

This commit is contained in:
Arun Prakash Jana 2020-03-16 06:40:02 +05:30
parent a2c2332fc5
commit b8a973a91a
No known key found for this signature in database
GPG key ID: A75979F35C080412
5 changed files with 35 additions and 24 deletions

View file

@ -6,25 +6,36 @@
# Shell: POSIX compliant
# Author: Arun Prakash Jana
#GUIPLAYER=smplayer
NUMTRACKS=100
GUIPLAYER="${GUIPLAYER}"
NUMTRACKS="${NUMTRACKS:-100}"
if [ ! -z "$GUIPLAYER" ]; then
PLAYER="$GUIPLAYER"
find . -type f \( -iname "*.mp3" -o -iname "*.flac" -o -iname "*.m4a" -o -iname "*.webm" -o -iname "*.wma" \) | shuf | head -n $NUMTRACKS | xargs -d "\n" "$PLAYER" > /dev/null 2>&1 &
find . -type f \( -iname "*.mp3" -o -iname "*.flac" -o -iname "*.m4a" -o -iname "*.webm" -o -iname "*.wma" \) | shuf | head -n "$NUMTRACKS" | xargs -d "\n" "$GUIPLAYER" > /dev/null 2>&1 &
# detach the player
sleep 1
elif which mocp >/dev/null 2>&1; then
cmd=$(pgrep -x mocp 2>/dev/null)
ret=$cmd
if [ -z "$ret" ]; then
# start MOC server
mocp -S
else
# mocp running, check if it's playing
state=$(mocp -i | grep "State:" | cut -d' ' -f2)
if [ "$state" = 'PLAY' ]; then
# add up to 100 random audio files
find . -type f \( -iname "*.mp3" -o -iname "*.flac" -o -iname "*.m4a" -o -iname "*.webm" -o -iname "*.wma" \) | shuf | head -n "$NUMTRACKS" | xargs -d "\n" mocp -a
exit
fi
fi
# clear MOC playlist
mocp -c
# add up to 100 random audio files
find . -type f \( -iname "*.mp3" -o -iname "*.flac" -o -iname "*.m4a" -o -iname "*.webm" -o -iname "*.wma" \) | shuf | head -n $NUMTRACKS | xargs -d "\n" mocp -a
find . -type f \( -iname "*.mp3" -o -iname "*.flac" -o -iname "*.m4a" -o -iname "*.webm" -o -iname "*.wma" \) | shuf | head -n "$NUMTRACKS" | xargs -d "\n" mocp -a
# start playing
mocp -p

View file

@ -18,11 +18,11 @@
# Shell: POSIX compliant
# Author: Arun Prakash Jana
EBOOK_ID=
EBOOK_ID="${EBOOK_ID}"
DIR="${XDG_CACHE_HOME:-$HOME/.cache}/nnn/gutenbooks/$EBOOK_ID"
BROWSE_LINK="http://www.gutenberg.org/ebooks/search/?sort_order=downloads"
BROWSER=w3m
READER=
BROWSER="${BROWSER:-w3m}"
READER="${READER}"
if [ -n "$EBOOK_ID" ]; then
if [ ! -e "$DIR" ]; then

View file

@ -5,7 +5,7 @@
#
# Notes:
# 1. Set res if you don't want to be prompted for desktop resolution every time
# 2. minsize is set to 1MB by default, adjust it if you want
# 2. MINSIZE is set to 1MB by default, adjust it if you want
# 3. imgp options used:
# a - adaptive mode
# c - convert PNG to JPG
@ -15,16 +15,16 @@
# Author: Arun Prakash Jana
# set resolution (e.g. 1920x1080)
res=
res="${RESOLUTION}"
# set minimum image size (in bytes) to resize (default: 1MB)
minsize=1048576
MINSIZE="${MINSIZE:-1048576}"
if [ -z "$res" ]; then
printf "desktop resolution (hxv): "
read -r res
fi
if ! [ -z "$res" ] && ! [ -z "$minsize" ]; then
imgp -ackx "$res" -s "$minsize"
if ! [ -z "$res" ] && ! [ -z "$MINSIZE" ]; then
imgp -ackx "$res" -s "$MINSIZE"
fi

View file

@ -16,11 +16,11 @@ selection=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection
cmd=$(pgrep -x mocp 2>/dev/null)
ret=$cmd
SHUFFLE=0
SHUFFLE="${SHUFFLE:-0}"
mocp_add ()
{
if [ $SHUFFLE = 1 ]; then
if [ "$SHUFFLE" = 1 ]; then
if [ "$resp" = "y" ]; then
arr=$(tr '\0' '\n' < "$selection")
elif [ -n "$1" ]; then

View file

@ -66,7 +66,7 @@
# #############################################################################
# set to 1 to enable GUI apps
GUI=0
GUI="${GUI:-0}"
set -euf -o noclobber -o noglob -o nounset
IFS="$(printf '%b_' '\n')"; IFS="${IFS%_}" # protect trailing \n
@ -82,7 +82,7 @@ if ! [ -z "$ext" ]; then
fi
handle_pdf() {
if [ $GUI -ne 0 ] && which zathura >/dev/null 2>&1; then
if [ "$GUI" -ne 0 ] && which zathura >/dev/null 2>&1; then
zathura "${FPATH}" >/dev/null 2>&1 &
exit 0
elif which pdftotext >/dev/null 2>&1; then
@ -115,10 +115,10 @@ handle_audio() {
}
handle_video() {
if [ $GUI -ne 0 ] && which smplayer >/dev/null 2>&1; then
if [ "$GUI" -ne 0 ] && which smplayer >/dev/null 2>&1; then
smplayer "${FPATH}" >/dev/null 2>&1 &
exit 0
elif [ $GUI -ne 0 ] && which mpv >/dev/null 2>&1; then
elif [ "$GUI" -ne 0 ] && which mpv >/dev/null 2>&1; then
mpv "${FPATH}" >/dev/null 2>&1 &
exit 0
elif which ffmpegthumbnailer >/dev/null 2>&1; then
@ -285,7 +285,7 @@ handle_multimedia() {
## Image
image/*)
if [ $GUI -ne 0 ] && which sxiv >/dev/null 2>&1; then
if [ "$GUI" -ne 0 ] && which sxiv >/dev/null 2>&1; then
sxiv_load_dir "${FPATH}" >/dev/null 2>&1 &
exit 0
elif which viu >/dev/null 2>&1; then
@ -450,7 +450,7 @@ handle_mime() {
}
handle_fallback() {
if [ $GUI -ne 0 ]; then
if [ "$GUI" -ne 0 ]; then
xdg-open "${FPATH}" >/dev/null 2>&1 &
exit 0
fi