| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 | 
							- #!/bin/bash
 - 
 - . __FFOOD_INIT__
 - FFOOD_INIPATH="__FFOOD_INIPATH__"
 - 
 - ffood import core
 - ffood import recon
 - 
 - 
 - #
 - # self help
 - #
 - 
 - available_commands() {
 -     echo afk
 -     echo at
 -     echo back
 -     echo gone
 -     echo moving
 -     echo ooo
 -     echo wfh
 - }
 - 
 - usage() {
 -     cmd_hint=$(
 -         available_commands \
 -             | head -c -1 \
 -             | tr '\n' '|'
 -     )
 -     usage_is "$cmd_hint"
 - }
 - 
 - 
 - #
 - # querying
 - #
 - 
 - familiars_at() {
 -     test -n "$1" || usagef "location"
 -     iniread -p iam.needing.at.$1 iam.ini
 -     iniread -p iam.needing.at.ANY iam.ini
 - }
 - 
 - where_i_am() {
 -     if=$(iniread -p iam.using.if iam.ini)
 -     gwmac=$(arp | grep "^gateway\\>.*\\<$if\$" | tr ' ' '\n' | grep :)
 -     iniread -p iam.seeing.gw.$gwmac iam.ini | grep . || echo OUT
 - }
 - 
 - 
 - #
 - # subcommand handlers
 - #
 - 
 - i_am_afk() {
 -     mocp --pause
 -     slock
 - }
 - 
 - i_am_at() {
 -     where_i_am
 - }
 - 
 - i_am_back() {
 -     local f fbin
 -     for f in $(familiars_at $(where_i_am));
 -     do
 -         fbin=${f/ */}
 -         pids_matching $f || $f &
 -     done
 -     klist || urxvt -e kinit
 - }
 - 
 - i_am_gone() {
 -     kdestroy
 -     killall $(familiars_at $(where_i_am))
 -     i_am_afk
 -     i_am_back
 - }
 - 
 - i_am_moving() {
 -     die "not implemented"   # hint: use zleep
 - }
 - 
 - i_am_ooo() {
 -     die "not implemented"
 - }
 - 
 - i_am_wfh() {
 -     die "not implemented"
 - }
 - 
 - cmd=$1
 - 
 - test -n "$cmd" || usage
 - 
 - available_commands | grep -qse ^$1 || usage
 - 
 - 
 - i_am_$cmd
 
 
  |