parsed.org

Tips by tag: scripts

This is a GlovePie example of a button that reacts differently depending on if the user quickly presses the button or holds it down.

The basic structure for this is:

if Released(<condition>)
   if not var.Held
      //Do something in response to pressed condition
   else
      var.Held = false
   endif
else
   if Pressed(HeldDown(<condition>, <time required>))
      //Do something in response to helddown condition
      var.Held = true
   endif
endif

A working example where tapping the A button sends "Up" keystroke and holding it down for 400ms sends "Down":

if not var.init
   var.HeldTime = 400ms
   var.init = true
endif

if Released(Wiimote.A)
   if not var.Held
      Press(Up)
      wait 25ms
      Release(Up)
   else
      var.Held = false
   endif
else
   if HeldDown(Wiimote.A, var.HeldTime)
      Press(Down)
      wait 25ms
      Release(Down)
      var.Held = true
   endif
endif
buttonsglovepiescriptswiiwiimote
Standalone Procmail by xinu on Sep 10, 2005 12:10 AM

You have a mailbox you need to sort. You can't have it come back through your MTA, of course. Use this script to push it through the procmail filter of your choice:

#!/bin/sh

ORGMAIL=/var/spool/mail/$LOGNAME

if cd $HOME &&
  test -s $ORGMAIL &&
  lockfile -r0 -l3600 .newmail.lock 2>/dev/null
then
  trap "rm -f .newmail.lock" 1 2 3 15
  umask 077
  lockfile -l3600 -ml
  cat $ORGMAIL >>.newmail &&
  cat /dev/null >$ORGMAIL
  lockfile -mu
  formail -s procmail <.newmail &&
  rm -f .newmail
  rm -f .newmail.lock
fi
exit 0
commandsmailboxmtaprocmailscriptsshellsort
RSS