Peter Vollmar --> dwm (2008-01-19 21:51:17 +0100): > Thank you so much Jukka, your script works great. I've tried to simplify > it to fit my needs, now I have everything in one script. Apart from the > in.sh with FIFO solution, I have also managed to incorporate your script > in my .xinitrc in the usual dwm loop. (I didn't know how to get rid of > the [if $MCK...] clause though, since I don't need the "no" option here, > but anyhow, it's working...)
Just remove the whole line and the corresponding `fi' command. > I have noticed that when running with the FIFO option, upon dwm shutdown > some running programs get killed before they can save their > configuration (resulting in repeated file corruption in some cases!). What programs? > This doesn't seem to happen with the direct loop, although dwm sometimes > takes about 5-10 seconds to close down all programs (or is it the X > server?). > Can you explain this behaviour? I assume that by "direct loop" you are referring to the status bar code snippet from the dwm README. If your using something like that, calling `sleep n' after each call to your output printing commands, and exit dwm using its quit() function, you'll have to wait up to n seconds until the X server shuts down, depending on for how long the current `sleep n' command has already been running. When using the FIFO approach, the X server shuts down as soon as you tell dwm to quit (which is the correct behaviour IMHO). I don't know why this causes corrupted files for you. Maybe your programs somehow depend on those "up to n seconds", but such a setup would be broken IMHO because you might quit dwm after `sleep 1' has terminated but before the next loop iteration has started, thus shutting down the X server immediately as if you had use the FIFO approach. You'd probably see the same corruption then. > By the way, is "dwm -q" the same as "killall dwm" (to use in a shutdown > script)? $ dwm -q usage: dwm [-v] $ killall dwm ksh: killall: not found > Anyway, here's my most recent .xinitrc, running dwm without FIFO, and > showing uptime and date every 7 seconds and the number of mails calling > "fetchmail -c" every 280 seconds in the output bar. > > -- > xhkeys > feh --bg-scale /tmp/losung.pnm > while true; do > > : ${DELAY:=40} \ > ${MCK:=yes} \ > ${MCK_INT:=7} # if $MCK != no, run mail check every $(( $MCK_INT * $DELAY > )) seconds > > main() > { > local now loadavg > local i=0 nmsgs= > > # loop forever > while :; do > now="$(date +'%a %d %b %R')" > loadavg="$(uptime | sed 's/.*,//')" > > if [ $MCK != 'no' ]; then > if [ $i -eq 0 ]; then > > nmsgs="$(fetchmail -c --sslproto tls | sed 's/(//' | awk '{print > $1-$3}')" > fi > i=$(( ($i+1) % ${MCK_INT:?} )) > fi > > echo "$loadavg" "$now" "$nmsgs" > sleep ${DELAY:?} > > done > } > > main > sleep 1 > done | dwm Hmm, this doesn't make much sense: main() never returns, thus `sleep 1' never gets executed, and if it did, you really wouldn't need to redefine main() on every loop iteration. It's quite constant ;-) I'd suggest you to read about basic shell programming if you want to learn how to do this correctly... Cheers, Jukka -- bashian roulette: $ ((RANDOM%6)) || rm -rf ~