DWM background image script w/feh

I am able to run this from the command line but in my .xinitrc the following error occurs:

Arithmetric error: " % 5 + 1 "

Code:
# randomly selects a background wallpaper every 30 min

find /usr/local/wallpaper/ \( -name "*.jpg" -o -name "*.png" \) > /usr/local/wallpaper/wallpaper.list &

while true
do

	feh --bg-scale $(sed -n $(( $RANDOM %$(wc -l < /usr/local/wallpaper/wallpaper.list) ))p /usr/local/wallpaper/wallpaper.list)  
	sleep 1800
	
done &
 

Attachments

  • xinit.txt
    1.1 KB · Views: 345
First, what is your interactive shell?

(I don't know if .xinitrc runs with users shell or with /bin/sh, probably with /bin/sh, and thats the source of the problem).

Second - you better save it as a script somewhere in $HOME/bin and run it once-per-time with cron, but not with 'sleep' in your .xinitrc. Don't forget to put DISPLAY into the script.
 
I just installed 8.1-stable on a test platform (Dell e1705 Core Duo 2). I chsh to the zsh on root. Sorry my coding background is 1 college class of Java. I will look up cron and see if I can get this to work.
 
I chsh to the zsh on root
BAD idea. VERY BAD idea. use toor for root with non-default shell.
Code:
/usr/local/bin/zsh:
        libpcre.so.0 => /usr/local/lib/libpcre.so.0 (0x2810c000)
        libiconv.so.3 => /usr/local/lib/libiconv.so.3 (0x28144000)
        libncursesw.so.8 => /lib/libncursesw.so.8 (0x2823d000)
        libm.so.5 => /lib/libm.so.5 (0x2828a000)
        libc.so.7 => /lib/libc.so.7 (0x282a3000)

If your system got screwed up, you will not be able to login there as root.

And working fulltime with Xorg and company under root is even worse than that, unless you want your system screwed up as fast as possible.
 
captobvious said:
I am able to run this from the command line but in my .xinitrc the following error occurs:

Arithmetric error: " % 5 + 1 "

Don't copy the system xinit to your .xinitrc! Two different things.
 
$RANDOM is a known bashism. And zsh tries to be bash-compatible to some extent, being smth like a superset.
You can swap $RANDOM by $(jot -r 1 0 32767) since jot(1) is available on all BSD flavours.
 
Back
Top