Permalink
Browse files

commands for adding or removing apps from being managed by flow

* new commands: manage and unmanage
* new commonad: ls
  • Loading branch information...
1 parent b6ab830 commit ab91bc799c6876609e481a4f3ef9f8ee4c10cd0d @toolbear committed May 14, 2011
Showing with 58 additions and 9 deletions.
  1. +1 −0 .gitignore
  2. +57 −9 flow.sh
View
@@ -1 +1,2 @@
+/managed/
/target/
View
66 flow.sh
@@ -6,15 +6,20 @@ if [[ ! -d "$FLOW_DIR" ]]; then
fi
flow() {
- local TARGET=$FLOW_DIR/target
- local SCRIPTDIR=$FLOW_DIR/flow.d
-
- case $1 in
+ local TARGET="$FLOW_DIR/target"
+ local SCRIPTDIR="$FLOW_DIR/flow.d"
+ local MANAGED="$FLOW_DIR/managed"
+
+ local CMD=$1; shift
+ case $CMD in
compile)
[[ -d "$TARGET" ]] && return # FIXME: recompile when scripts modifed
+ flow force-compile
+ ;;
+ force-compile)
mkdir -p $TARGET
- local SCRIPTS=`find -L $SCRIPTDIR \( -type f -o -type l \) -regex '.*/[0-9][0-9][0-9][^/]*'`
+ local SCRIPTS=$(find -L "$MANAGED" \( -type f -o -type l \) -regex '.*/[0-9][0-9][0-9][^/]*')
cat $FLOW_DIR/include/diminish.scpt $FLOW_DIR/include/common.scpt $SCRIPTS |osacompile -o $TARGET/Enter\ Flow.app
cat $FLOW_DIR/include/restore.scpt $FLOW_DIR/include/common.scpt $SCRIPTS |osacompile -o $TARGET/Leave\ Flow.app
;;
@@ -29,6 +34,45 @@ flow() {
$TARGET/Leave\ Flow.app/Contents/MacOS/applet
;;
+ manage)
+ mkdir -p "$MANAGED"
+ local DIRTY=
+ while [[ $# -gt 0 ]] ; do
+ local APP=$1; shift
+
+ if [[ "$(find $SCRIPTDIR -type f -regex .*/[0-9][0-9][0-9]_$APP -exec ln -shfv {} $MANAGED ';')" ]] ; then
+ DIRTY=1
+ else
+ printf "Error: \`$APP\` isn't managed by flow\n" >/dev/stderr
+ return 1
+ fi
+ done
+ if [[ $DIRTY ]] ; then
+ flow force-compile
+ fi
+ ;;
+
+ unmanage)
+ [[ -d "$MANAGED" ]] || return
+
+ local DIRTY=
+ while [[ $# -gt 0 ]] ; do
+ local APP=$1; shift
+ if [[ "$(find $MANAGED -type l -regex .*/[0-9][0-9][0-9]_$APP -exec rm -v {} ';')" ]] ; then
+ DIRTY=1
+ fi
+ done
+ if [[ $DIRTY ]] ; then
+ flow force-compile
+ fi
+ ;;
+
+ ls)
+ mkdir -p "$MANAGED"
+ $(find $SCRIPTDIR -type f -execdir touch -a $MANAGED/{} ';')
+ env CLICOLOR_FORCE= \ls -G $MANAGED |sed -e 's/[0-9][0-9][0-9]_//' |sort -u
+ ;;
+
install)
flow compile
local APPLICATIONS=$HOME/Applications
@@ -42,13 +86,17 @@ flow() {
*)
cat <<'EOF' |cut -c17-
- usage: flow COMMAND
+ usage: flow COMMAND ...
Commands:
- enter Enter a state of flow by reducing distractions
- leave Leave a state of flow, restore communications, notifications, etc.
+ enter Enter a state of flow by reducing distractions
+ leave Leave a state of flow, restore communications, notifications, etc.
+
+ ls List apps which can be managed by flow, highlighting those which are
+ manage APP... Add APP to list of distracting apps which are diminished when entering flow
+ unmanage APP... Remove APP from list of distracting apps
- install Install `Enter Flow.app` and `Leave Flow.app` to $HOME/Applications
+ install Install `Enter Flow.app` and `Leave Flow.app` to $HOME/Applications
EOF
;;

0 comments on commit ab91bc7

Please sign in to comment.