Changeset 15258 in project


Ignore:
Timestamp:
07/25/09 20:12:30 (10 years ago)
Author:
sjamaan
Message:

Make the script warn only once when the battery drops below the threshold.
Only start warning again if the battery has been charged up again.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/wmiirc snippets

    r15248 r15258  
    5454
    5555<enscript highlight=scheme>
    56 (let loop ()
    57    (let ((charge (get-charge)))
    58      (wmii:write-tab
     56(let ((warned? #f))
     57  (let loop ()
     58    (let ((charge (get-charge)))
     59      (wmii:write-tab
    5960       "rbar" "status"
    6061       (conc charge "% | " (seconds->string (current-seconds))))
    61      (when (<= charge 5)
    62        (process-run "xmessage -center 'Low battery power!'")))
    63      (thread-sleep! 1)
    64      (loop))
     62      (when (and (<= charge 5) (not warned?))
     63        (set! warned? #t)
     64        (process-run "xmessage -center 'Low battery power!'"))
     65      (when (and warned? (> charge 5))
     66        (set! warned #f)))
     67    (thread-sleep! 1)
     68    (loop)))
    6569</enscript>
Note: See TracChangeset for help on using the changeset viewer.