123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- #!/bin/bash
-
- . "$(ffoom path)" || exit 3
-
- ffoo import inigrep
- ffoo import pretty
- ffoo import sync
-
- ffoo import saturnin_meta
- ffoo import saturnin_zleep
-
-
- #
- # self help
- #
-
- available_commands="afk at back gone ooo wfh undocking zleeping"
-
- usage() {
- mkusage "$available_commands"
- }
-
-
- #
- # querying
- #
-
- where_i_am() {
- #
- # what is my physical location?
- #
- if=$(inigrep -p iam.using.if)
- gwmac=$(arp | grep "^gateway\\>.*\\<$if\$" | tr ' ' '\n' | grep :)
- inigrep -p "iam.seeing.gw.$gwmac" || echo OUT
- }
-
- set_status() {
- #
- # set public status $1 by command in conf file
- #
- local what=$1
- saturnin_runhook "say_$what"
- saturnin_runhook "log_$what"
- }
-
-
- #
- # subcommand handlers
- #
-
- i_am_afk() {
- #
- # away from keyboard; blocks until i'm back again
- #
- mocp --pause
- set_status "afk"
- saturnin kb home # make sure to set lang to default before locking
- slock
- set_status "atk"
- }
-
- i_am_at() {
- #
- # Just say where I am
- #
- where_i_am
- }
-
- i_am_back() {
- #
- # returning to work (should be called by other subcommands)
- #
- set_status "back"
- klist -s || urxvt -e kinit
- }
-
- i_am_gone() {
- #
- # gone fishin'
- #
- kdestroy
- ssh-add -D
- set_status "gone"
- i_am_afk
- i_am_back
- }
-
- i_am_ooo() {
- #
- # too dangerous to implement
- #
- die "not implemented"
- }
-
- i_am_wfh() {
- #
- # too dangerous to implement
- #
- die "not implemented"
- }
-
- i_am_undocking() {
- #
- # i.e. hibernated
- #
- inigrep -p iam.undocking.like | bash -
- }
-
- i_am_zleeping() {
- #
- # i.e. hibernated
- #
- set_status "zleeping"
- zleep
- i_am_back
- }
-
- cmd=$1
-
- test -n "$cmd" || usage
-
- echo "$available_commands" | grep -qw "$cmd" || usage
-
- shift
-
- "i_am_$cmd" "$1"
|