diff options
Diffstat (limited to 'plugins')
-rwxr-xr-x | plugins/display | 17 | ||||
-rwxr-xr-x | plugins/notify | 45 | ||||
-rwxr-xr-x | plugins/polybar | 43 |
3 files changed, 105 insertions, 0 deletions
diff --git a/plugins/display b/plugins/display new file mode 100755 index 0000000..7d8441c --- /dev/null +++ b/plugins/display @@ -0,0 +1,17 @@ +#!/bin/sh +[ "$1" = "info" ] && echo "plugin to display time nicely" && exit 2 + +. "$core_path/lib" +. "$core_path/update" + +# on reset, print empty line to clear module +if [ $lap -eq 0 ] && [ $running -eq 0 ] && [ $time = $("$prog" lap 0) ] ; then + echo "" + exit +fi + +# print time in square brackets if running, else between dashes +time="$(fmt_time $remaining)" +[ $running -eq 1 ] && echo "[$time]" \ + || echo "-$time-" + diff --git a/plugins/notify b/plugins/notify new file mode 100755 index 0000000..24565ec --- /dev/null +++ b/plugins/notify @@ -0,0 +1,45 @@ +#!/bin/sh +[ "$1" = "info" ] && echo "run the notification daemon" && exit 2 + +. "$core_path/lib" + +runtime_dir="$XDG_RUNTIME_DIR/$progname" + +mkdir -p "$runtime_dir" +notify_file="$runtime_dir/notify" + +pid_file="$runtime_dir/pid" +[ -e "$pid_file" ] && err "$pid_file exists! use \`kill $(cat "$pid_file")\` to stop the other daemon" +echo "$$" > "$pid_file" + +update() { + unset original_state remaining running + . "$core_path/update" + touch "$notify_file" +} +update + +watch_pid=0 + +cleanup() { + trap - TERM + rm -f "$pid_file" +} +trap cleanup INT TERM EXIT + +while inotifywait -qq -e modify "$POMODORO_STATE_PATH/primary" ; do + update + if [ $running -eq 1 ] ; then + if [ $watch_pid = 0 ] ; then + while :; do + update & + sleep 1 + done & + watch_pid=$! + fi + else + kill -- $watch_pid 2> /dev/null + watch_pid=0 + fi +done + diff --git a/plugins/polybar b/plugins/polybar new file mode 100755 index 0000000..430b814 --- /dev/null +++ b/plugins/polybar @@ -0,0 +1,43 @@ +#!/bin/sh +[ "$1" = "info" ] && echo "plugin for script module in polybar" && exit 2 + +. "$core_path/lib" + +usage() { + cat << EOF +usage: + $subcmd [options] + +options: + -h, --help display this help text + +this plugin is intended to be used in combination with polybar. add the +following to your config.ini file to use this plugin: + + [module/$progname] + type = custom/script + exec = $subcmd + tail = true + click-left = $progname toggle + click-middle = $progname reset +EOF +} + +while [ $# -gt 0 ] ; do + case "$1" in + -h|--help) usage && exit 0 ;; + --) shift ; break ;; + *) err "unknown parameter: $1" ;; + esac +done + +# launch notify daemon if it is not already active +("$prog" notify 1> /dev/null 2> /dev/null &) +sleep 0.1 # warm up a little + +"$prog" display +while inotifywait -qq -e attrib "$XDG_RUNTIME_DIR/$progname/notify" ; do + unset remaining lap time running + "$prog" display +done + |