I get an error on this script.
line 69 is
this is as seen filling arrays with path to images then adding them all into one array mixing them up along the way then using the last array to pick a random image to set in mrxvt. In FreeBSD I get the error posted, but not in Linux.
So to me that tells me FreeBSD got a size limit on how much shuf can shuffle?
is there a fix or should I reduse the amount of images I am taking in to try and fix this?
or is that message telling me something different?? which puts me in the I'm lost dept.
Code:
$ ranImg
/home/userx/bin/ranImg: line 69: /usr/local/bin/shuf: Argument list too long
Code:
temp4=( $( shuf -e -n "$smallest" "${temp1[@]}" ) )
So to me that tells me FreeBSD got a size limit on how much shuf can shuffle?
is there a fix or should I reduse the amount of images I am taking in to try and fix this?
or is that message telling me something different?? which puts me in the I'm lost dept.
Code:
#!/usr/bin/env bash
#Jun. 11, 2019
#Michael Heras
#to give a random background image to
#mrxvt terminal
#by chaning its resource file
#.mrxvtrc
wd1=$HOME/data/ScreenResizedImages
wd2=$HOME/data/wallpapers
wd3=$HOME/data/wallhaven-papers
SysColors=$HOME/bin/colorsOfASystem
#echo "
#wd1Count=$( find $wd1 -type f | wc -l )
#wd2Count=$( find $wd2 -type f | wc -l )
#wd3Count=$( find $wd3 -type f | wc -l )
#"
#get count of totals in the dir, put in an array
totals=(
$( find $wd3 -type f | wc -l )
$( find $wd1 -type f | wc -l )
$( find $wd2 -type f | wc -l )
)
smallest=${totals[0]}
for((i=0;i<${#totals[@]};i++))
do
#logic for smallest number
if [ ${totals[$i]} -lt $smallest ]; then
smallest=${totals[$i]}
fi
done
#echo $smallest
#logic for greatest number
#elif [ ${nos[$i]} -gt $greatest ]; then
#greatest=${nos[$i]}
##fi
#done
RandomColor()
{
cat "$SysColors" | shuf | shuf > tempColors
mv tempColors "$SysColors"
mapfile -t colors < "$SysColors"
}
MixRandomImages()
{
#Resized Images
mapfile -t temp1 < <(find "$wd1" -type f | shuf )
#Wallpaper Images
mapfile -t temp2 < <(find "$wd2" -type f -name "*.jpg" | shuf )
#wallhaven-papers
mapfile -t temp3 < <(find "$wd3" -type f -name "*.jpg" | shuf )
#takes half of the amount of images in wd2 and adds that
#and temp1 into an array.
#-e, --echo treat each ARG as an input line
#-n, --head-count=COUNT output at most COUNT lines
# temp5=( $( shuf -e -n "$(($(ls "$wd2" | wc -l)/2))" "${temp1[@]}" ) )
#take the lowest amount in all three dir, and give same amount
#of other images into the mix
temp4=( $( shuf -e -n "$smallest" "${temp1[@]}" ) )
temp5=( $( shuf -e -n "$smallest" "${temp2[@]}" ) )
temp6=( $( shuf -e -n "$smallest" "${temp3[@]}" ) )
#all all 3 image arrays into one arrays
ranArray1=( "${temp5[@]}" "${temp4[@]}" "${temp6[@]}" )
#shuffle them up a few times
for i in {1..4}
do
for g in 1
do
sh1=( $(shuf -e "${ranArray1[@]}") )
done
unset ranArray1
ranArray1=( ${sh1[@]} )
unset sh1
done
#shuffle them up once
#ranArray2=( $( shuf -e "${ranArray1[@]}") )
#shuffle them up twice
# ranArray3=( $( shuf -e "${ranArray2[@]}") )
#shuffle array up to get a good mix
ImageArray=( "${ranArray1[@]}" )
#echo ${ImageArray[@]}
}
#write changes to mrxvt terminal config file
UpdateMrxvtConfig()
{
sed -ibak 's|.*mrxvt.background:.*|mrxvt.background: '"$( echo -e ${colors[ $RANDOM % ${#colors[@]} ]})"'|' $HOME/.mrxvtrc
sed -ibak 's|mrxvt.tabBackground:.*|mrxvt.tabBackground: '"$( echo -e ${colors[ $RANDOM % ${#colors[@]} ]})"'|' $HOME/.mrxvtrc
sed -ibak 's|mrxvt.cursorColor: .*|mrxvt.cursorColor: '"$( echo -e ${colors[ $RANDOM % ${#colors[@]} ]})"'|' $HOME/.mrxvtrc
sed -ibak 's|mrxvt.foreground: .*|mrxvt.foreground: '"$( echo -e ${colors[ $RANDOM % ${#colors[@]} ]})"'|' $HOME/.mrxvtrc
sed -ibak 's|.*mrxvt.Pixmap:.*|mrxvt.Pixmap: '"$( echo -e ${ImageArray[ $RANDOM % ${#ImageArray[@]} ]})"';80x80|' $HOME/.mrxvtrc
}
#run functions
RandomColor
MixRandomImages
UpdateMrxvtConfig
#start the terminal.
mrxvt &