Skip to content

Instantly share code, notes, and snippets.

@jclaggett
Created April 14, 2011 20:24
Show Gist options
  • Select an option

  • Save jclaggett/920415 to your computer and use it in GitHub Desktop.

Select an option

Save jclaggett/920415 to your computer and use it in GitHub Desktop.

Revisions

  1. jclaggett created this gist Apr 14, 2011.
    48 changes: 48 additions & 0 deletions context.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,48 @@
    #!/bin/bash -e

    status_icon_000="/usr/share/icons/Humanity/apps/48/stock_delete-bookmark.svg"
    status_icon_100="/usr/share/icons/Humanity/apps/48/stock_bookmark.svg"

    function context_loop() {
    declare time_task
    while time_task=$(context_switch_dialog $*)
    do
    set $time_task # reference using positional args

    declare -i i=1+$1

    echo "icon:$status_icon_000"

    while ((--i>0))
    do
    echo "tooltip:Working on ${*:2} ($i minute$(s $i) left)"
    sleep 60
    done

    echo "icon:$status_icon_100"
    echo "tooltip:Working on ${*:2} ($i minute$(s $i) left)"
    echo "message:Your $1 minute$(s $1) for working on ${*:2} are spent."
    done | context_notification
    }

    function context_switch_dialog() {
    zenity \
    --entry \
    --title='Context Switcher' \
    --text='Please enter minutes and title for your next task:' \
    --entry-text="$*"
    }

    function context_notification() {
    zenity \
    --notification \
    --listen \
    --text="Context Switcher" \
    --window-icon="$status_icon_100"
    }

    function s() {
    (($1!=1)) && echo s
    }

    context_loop ${*:-5 sample task}
    Empty file added gistfile2.txt
    Empty file.