Ok due to two reasons I installed this JWM - one I was already looking for something else to use for a desktop - just for a change - and two: someone in here put me up it it because they did it, so I tried it, and its nice. But,
I use a script to change desktop images (random images) it works, then when I used it in this jwm it works but how this is working it not good.
when one sets jwm up to show a different image on each desktop. it will call to change the image when one changes the desktop so that right image will show when it is suppose to.
The advantages of the tags options one is command, to execute a command instead of an image, therefore scripts too can be used within this option of separate images for each desktop.
my script has within it a means to check PIDS count if more than then kill the extra ones so process will not get over ran and have more than one of these scripts running at a time, therefore keeping the changing of the image on the background to just whatever it is set up to time change in the script.
in other words change time is set to 1 minute that script controls that, but if another run of same script is ran then it changes too.
now two scripts are changing the image at accordance to their start time.
hence kill the extra pids to prevent changing the image more often than 1 minute.
Within my script when executed the function to check PID count and kill PIDS if more than will be called every time the script is called to execute.
The JWM : when ever one changes to the desktop then whatever is within the tags will be called to execute upon change.
So logically when ever I change my desktop to the desktop that executes the script. then upon that script execution it is SUPPOSE to be calling that function that checks PID count.
But something is awry .. it does execute my script every time I change to that desk top, I can tell just by how I got it set up to work.
to set a given image upon execute to take up lag time waiting for a minute to pass before cycle starts to set random images.
then then next thing that is suppose be happening in that script is that function call. which is not being done for some strange reasons.
script is this:
it is not that complicated. Is is only three functions.
Code:
#!/bin/bash
WALLPAPERS=/media/data/wallpaper
## set an image to background immediately
mhsetroot -fs /home/userx/Dropbox/wallpaperbackups/mixed/C186.jpg
KillPid(){
#get App name
appname=$0
appname=${appname#*/}
#find pids to kill to prevent over running process with same script
if [[ $(pgrep -u $USER $appname | wc -l) -ge 2 ]] && [[ $( pgrep -u $USER sleep | wc -l) -ge 1 ]] ; then
{
#get PID for script
echo "$appname had pids : $(pgrep -u $USER $appname)"
echo;echo;echo
PID2KILL="$(pgrep -u $USER $appname)"
echo "before cut PID: $PID2KILL"
PID2KILL=${PID2KILL#* }
echo "PIDS : $PID2KILL"
echo;echo;echo
#get PID for sleep
SPID2KILL="$(pgrep -u $USER sleep)"
echo "before cut SPID: $SPID2KILL"
SPID2KILL=${SPID2KILL#* }
echo "SPIDS : $SPID2KILL"
#kill the extra PIDs
kill $SPID2KILL
kill $PID2KILL
echo "SPID is: $(pgrep -u $USER sleep)"
}
else
{
echo "running pid is : $(pgrep -u $USER $appname)"
}
fi
}
#added function call here to try and force it to check
# right after image set in above lines
KillPid
#get a color
color() {
echo \#$(head -n 1 /dev/urandom | od -t x1 -N 9 | awk '{print $2 $3 $4}')
}
ImgNum1()
{
#shuffel between High - Low range
ImgsizeNum1=$(($RANDOM % 200 + 200 | bc ))
ImgsizeNum2=$(($RANDOM % 200 + 300 | bc ))
ImageDimentions="$ImgsizeNum1"x"$ImgsizeNum2"
echo $ImageDimentions
}
startChanging()
{
while true
do
SetSubDir=$(shuf -i 1-$((($(find "$WALLPAPERS" -type d | wc -l)-1))) -n 1)
WALLPAPERS="$WALLPAPERS/$SetSubDir"
#ImgNum1 #gets ImageDimentions
setShow=$(shuf -i 1-4 -n 1)
case "$setShow" in
1)
Imageis="-fill"
;;
2)
ImgNum1
Imageis="-dtile $ImageDimentions"
#Imageis="-dtile 300x300"
;;
3)
Imageis="-fimgv"
;;
4)
Imageis="-dcenter $((RANDOM % 100 + 500 | bc ))"x"$((RANDOM % 300 + 800 | bc ))"
;;
esac
gradientAngle=$((gradientAngle+=10))
[[ $gradientAngle -gt '160' ]] && gradientAngle=1
find "$WALLPAPERS" -type f \( -name '*.jpg' -o -name '*.png' -o -name "*.bmp" \) -print0 | shuf -n 1-$(find "$WALLPAPERS" -type f | wc -l) -z | xargs -0 \
mhsetroot -add $(color) -add $(color) -gradient $gradientAngle $Imageis
#find "$WALLPAPERS" -type f \( -name '*.jpg' -o -name '*.png' -o -name "*.bmp" \) -print0 | shuf -n 1-$(find "$WALLPAPERS" -type f | wc -l) -z | xargs -0 \
#mhsetroot -addd $(color) 3 -addd $(color2) 5 -addd $(color) 3 -addd $(tint) 8 -gradient "$(setGradient)" $setI $ImageDimentions
#mhsetroot -solid $(echo \#$(head -n 1 /dev/urandom | od -t x1 -N 9 | awk '{print $2 $3 $4}'))
sleep 1m
done >&2>>/dev/null >> changebgimage.log &
KillPid
}
startChanging
Instead of KillPid() working it just keeps piling up
Code:
userx%slackwhere ⚡ ~ ⚡> ps aux | grep changebgimage
userx 10367 1.2 0.3 2554220 65008 ? Sl 10:44 0:01 kwrite file:///home/userx/changebgimage
userx 10703 0.0 0.0 12072 2412 ? S 10:45 0:00 /bin/bash /home/userx/changebgimage
userx 10718 0.0 0.0 12072 2592 ? S 10:45 0:00 /bin/bash /home/userx/changebgimage
userx 10779 0.0 0.0 12072 2512 ? S 10:45 0:00 /bin/bash /home/userx/changebgimage
userx 10810 0.0 0.0 11668 2104 pts/1 S+ 10:45 0:00 grep changebgimage
userx%slackwhere ⚡ ~ ⚡> ps aux | grep changebgimage
userx 10367 1.2 0.4 2554748 65648 ? Sl 10:44 0:02 kwrite file:///home/userx/changebgimage
userx 10703 0.0 0.0 12072 2416 ? S 10:45 0:00 /bin/bash /home/userx/changebgimage
userx 10718 0.0 0.0 12072 2592 ? S 10:45 0:00 /bin/bash /home/userx/changebgimage
userx 10779 0.0 0.0 12072 2512 ? S 10:45 0:00 /bin/bash /home/userx/changebgimage
userx 10908 0.0 0.0 12072 2464 ? S 10:47 0:00 /bin/bash /home/userx/changebgimage
userx 10983 0.0 0.0 12072 2396 ? S 10:47 0:00 /bin/bash /home/userx/changebgimage
userx 11015 0.0 0.0 11668 2224 pts/1 S+ 10:47 0:00 grep changebgimage
userx%slackwhere ⚡ ~ ⚡>
Of course this works when I run it in a command line.
Code:
userx%slackwhere ⚡ ~ ⚡> pkill changebgimage
userx%slackwhere ⚡ ~ ⚡> ps aux | grep changebgimage
userx 10367 0.2 0.4 2555340 71284 ? Sl 10:44 0:03 kwrite file:///home/userx/changebgimage
userx 13853 0.0 0.0 11668 2104 pts/1 S+ 11:09 0:00 grep changebgimage
userx%slackwhere ⚡ ~ ⚡> ./changebgimage
changebgimage had pids : 13854
before cut PID: 13854
PIDS : 13854
Terminated
userx%slackwhere ⚡ ~ ⚡>
userx%slackwhere ⚡ ~ ⚡> ./changebgimage
changebgimage had pids : 13864
before cut PID: 13864
PIDS : 13864
Terminated
userx%slackwhere ⚡ ~ ⚡> ps aux | grep changebgimage
userx 10367 0.2 0.4 2555340 71284 ? Sl 10:44 0:03 kwrite file:///home/userx/changebgimage
userx 13883 0.0 0.0 11668 2140 pts/1 S+ 11:10 0:00 grep changebgimage
userx%slackwhere ⚡ ~ ⚡>
the only reason we do not see one instance of the script running now is only because I added the call right after I defined it. as noted above in the code.
If I remove that extra call it works in the command line, as well if I just use it to be called in an "autostart" method in this WM as well as any other Desktop or Window Manager.
Code:
userx%slackwhere ⚡ ~ ⚡> ./changebgimage
running pid is : 13891
13893
13895
13898
userx%slackwhere ⚡ ~ ⚡> ps aux | grep changebgimage
userx 10367 0.2 0.4 2555340 71476 ? Sl 10:44 0:03 kwrite file:///home/userx/changebgimage
userx 13893 0.0 0.0 12064 2512 pts/1 S 11:12 0:00 /bin/bash ./changebgimage
userx 13926 0.0 0.0 11668 2104 pts/1 S+ 11:12 0:00 grep changebgimage
userx%slackwhere ⚡ ~ ⚡> ./changebgimage
changebgimage had pids : 13893
13927
13929
13931
13934
before cut PID: 13893
13927
13929
13931
13934
PIDS : 13893
13927
13929
13931
13934
Terminated
userx%slackwhere ⚡ ~ ⚡> ps aux | grep changebgimage
userx 10367 0.2 0.4 2555340 71476 ? Sl 10:44 0:03 kwrite file:///home/userx/changebgimage
userx 13929 0.0 0.0 12064 2516 pts/1 S 11:12 0:00 /bin/bash ./changebgimage
userx 13963 0.0 0.0 11668 2144 pts/1 S+ 11:12 0:00 grep changebgimage
userx%slackwhere ⚡ ~ ⚡>
I do hope I have not boggled the minds of anyone with this.