diff --git a/plugins/boom b/plugins/boom index 460b9dd6..14f481da 100755 --- a/plugins/boom +++ b/plugins/boom @@ -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 - # start MOC server - mocp -S + 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 diff --git a/plugins/gutenread b/plugins/gutenread index 029cccf3..eb845bf4 100755 --- a/plugins/gutenread +++ b/plugins/gutenread @@ -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 diff --git a/plugins/imgresize b/plugins/imgresize index def55601..d85d4b51 100755 --- a/plugins/imgresize +++ b/plugins/imgresize @@ -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 diff --git a/plugins/mocplay b/plugins/mocplay index 30818b29..6f5a2a08 100755 --- a/plugins/mocplay +++ b/plugins/mocplay @@ -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 diff --git a/plugins/nuke b/plugins/nuke index 81a6d4d1..50840fe6 100755 --- a/plugins/nuke +++ b/plugins/nuke @@ -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