Skip to content

Instantly share code, notes, and snippets.

@jclaggett
Created April 14, 2011 20:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jclaggett/920415 to your computer and use it in GitHub Desktop.
Save jclaggett/920415 to your computer and use it in GitHub Desktop.
context switcher tool
#!/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}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment