Skip to content

Instantly share code, notes, and snippets.

@tamanugi
Last active August 1, 2017 15:08
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 tamanugi/846648cc2fe85c3fc52d49a33b5365c9 to your computer and use it in GitHub Desktop.
Save tamanugi/846648cc2fe85c3fc52d49a33b5365c9 to your computer and use it in GitHub Desktop.
org-modeでclock-inしているタスクをMacのメニューバーに表示する ref: http://qiita.com/tamanugi/items/ef43056d5c9709e4f7ab
$ brew cask install bitbar
{任意の名前}.{更新間隔}.{拡張子}
(defvar clockin-task-file "~/.clockin_task")
(defun write-clockin-task-file ()
(with-temp-buffer
(insert (concat (format-time-string "%s" org-clock-start-time)
"\t"
org-clock-heading))
(write-region (point-min) (point-max) clockin-task-file))
)
(defun delete-clockin-task-file ()
(delete-file clockin-task-file))
(add-hook 'org-clock-in-hook 'write-clockin-task-file)
(add-hook 'org-clock-out-hook 'delete-clockin-task-file)
(add-hook 'org-clock-cancel-hook 'delete-clockin-task-file)
#!/bin/bash
if [ -e ~/.clockin_task ]; then
task_name=`cat ~/.clockin_task | cut -f 2`
start_time=`cat ~/.clockin_task | cut -f 1`
elapsed=$(expr `date +%s` - $start_time)
h=$(expr $elapsed / 3600)
m=$(expr $elapsed % 3600 / 60)
disph=`printf %02d $h`
dispm=`printf %02d $m`
echo ":hourglass_flowing_sand: [$disph:$dispm] $task_name"
else
echo ":coffee: Break Time"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment