Post your favorite wmiirc scriptlets here.
Normally you have numbered tags and pressing Mod+n gives you tag n, but some people prefer to have more meaningful tag names. This means more work to type them in, so here's a way to navigate to the left or to the right of the current tab through the tabs as they appear in the bar.
((key ,modkey "comma") . ,(lambda _ (let loop ((list (wmii:tags)) (tag (wmii:tag))) (cond ((or (null? list) (null? (cdr list))) #f) ((string=? (cadr list) tag) (wmii:goto-tag (car list))) (else (loop (cdr list) tag)))))) ((key ,modkey "period") . ,(lambda _ (and-let* ((tag (member (wmii:tag) (wmii:tags))) ((not (null? (cdr tag))))) (wmii:goto-tag (cadr tag)))))
Battery charge in status bar on NetBSD
On my notebook, I want to have a quick view on my battery charge at all times. Starting with NetBSD 5.0, you can use the program "envstat" to obtain battery info (before you'd use "apm"). Unfortunately, there's no easy way to parse its output in a script. You could use the XML output, but then you'd have to wade through the entire output because the -s switch does not restrict the proplib output to the given sensors.
On my iBook G4 laptop, the battery is called smartbat0.
(define (get-charge) ;; Note that ordering of -s args doesn't influence ordering of output! (let* ((lines (cddr (with-input-from-pipe "envstat -s 'smartbat0:Battery design cap,smartbat0:Battery charge'" read-lines))) (max (string->number (irregex-match-substring (irregex-search 'real (car lines)) 0))) (charge (string->number (irregex-match-substring (irregex-search 'real (cadr lines)) 0)))) (/ (round (/ (* charge 1000) max)) 10)))
This procedure gives the output at a granularity of one tenth percent. I check the output in my status procedure that is run once every second and display a warning if the charge drops below a threshold:
(let ((warned? #f)) (let loop () (let ((charge (get-charge))) (wmii:write-tab "rbar" "status" (conc charge "% | " (seconds->string (current-seconds)))) (when (and (<= charge 5) (not warned?)) (set! warned? #t) (process-run "xmessage -center 'Low battery power!'")) (when (and warned? (> charge 5)) (set! warned #f))) (thread-sleep! 1) (loop)))