From 6d4334d189d29331d69c132ed7d85c0ea39b599c Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Thu, 7 Sep 2017 12:59:26 +1000 Subject: [PATCH] Add neato BitBar plugins to the repo, since I'm basically writing my own anyway --- .gitignore | 1 + config/bitbar/bin/mpd-control.1h.zsh | 48 ++++++++++++++++++++ config/bitbar/bin/taskpaper-ecoach.10s.py | 9 ++++ config/bitbar/bin/taskpaper-personal.10s.py | 9 ++++ config/bitbar/lib/taskpaper/__init__.py | 29 ++++++++++++ config/bitbar/lib/taskpaper/default.png | Bin 0 -> 413 bytes config/bitbar/lib/taskpaper/ecoach.png | Bin 0 -> 468 bytes 7 files changed, 96 insertions(+) create mode 100644 .gitignore create mode 100755 config/bitbar/bin/mpd-control.1h.zsh create mode 100755 config/bitbar/bin/taskpaper-ecoach.10s.py create mode 100755 config/bitbar/bin/taskpaper-personal.10s.py create mode 100644 config/bitbar/lib/taskpaper/__init__.py create mode 100644 config/bitbar/lib/taskpaper/default.png create mode 100644 config/bitbar/lib/taskpaper/ecoach.png diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0d20b64 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.pyc diff --git a/config/bitbar/bin/mpd-control.1h.zsh b/config/bitbar/bin/mpd-control.1h.zsh new file mode 100755 index 0000000..ae57aad --- /dev/null +++ b/config/bitbar/bin/mpd-control.1h.zsh @@ -0,0 +1,48 @@ +#!/bin/zsh + +path+=(/usr/local/bin) +mpc==mpc +print -n ♫ + +state=$(mpc status | sed '/^[^\[]/d; s/^\[\(.*\)\].*$/\1/') +i=$(mpc current -f %position%) + +if [[ $state == playing ]]; then + icon=' ▶ ' + menu=("Ⅱ Pause | terminal=false bash=$mpc param1=pause") +else + icon=' Ⅱ ' + menu=("▶ Play | terminal=false bash=$mpc param1=play") +fi + +if [[ -n $state ]]; then + print -n $icon + menu=( + "⏪ Previous | terminal=false bash=$mpc param1=prev" + $menu + "⏩ Next | terminal=false bash=$mpc param1=next" + "⏹ Stop | terminal=false bash=$mpc param1=stop" + ) +else + i=0 + print +fi +menu=(--- $menu "🔀 Shuffle | terminal=false bash=$mpc param1=shuffle" ---) + +format=() +for field in position title artist; format+=($field %$field%) + +songs=( ${(f)"$(mpc playlist -f ${(j-::-)format})"} ) +typeset -A song +for s in $songs; do + song=(${(s/::/)s}) + song[menu]="$song[title] - $song[artist] | length=50" + if (( $song[position] == $i )); then + print "$song[title] | length=30" + else + song[menu]+=" terminal=false bash=$mpc param1=play param2=$song[position]" + fi + menu+=($song[menu]) +done + +print -l -- $menu diff --git a/config/bitbar/bin/taskpaper-ecoach.10s.py b/config/bitbar/bin/taskpaper-ecoach.10s.py new file mode 100755 index 0000000..0c8bdf0 --- /dev/null +++ b/config/bitbar/bin/taskpaper-ecoach.10s.py @@ -0,0 +1,9 @@ +#!/usr/bin/python +import sys +from os.path import abspath, dirname, join + +LIB = join(dirname(dirname(abspath(sys.argv[0]))), 'lib') +sys.path.insert(0, LIB) + +import taskpaper +taskpaper.count('~/Dropbox/Tasks/eCoach.taskpaper', icon='ecoach') diff --git a/config/bitbar/bin/taskpaper-personal.10s.py b/config/bitbar/bin/taskpaper-personal.10s.py new file mode 100755 index 0000000..cae82b1 --- /dev/null +++ b/config/bitbar/bin/taskpaper-personal.10s.py @@ -0,0 +1,9 @@ +#!/usr/bin/python +import sys +from os.path import abspath, dirname, join + +LIB = join(dirname(dirname(abspath(sys.argv[0]))), 'lib') +sys.path.insert(0, LIB) + +import taskpaper +taskpaper.count('~/Dropbox/Tasks/Personal.taskpaper') diff --git a/config/bitbar/lib/taskpaper/__init__.py b/config/bitbar/lib/taskpaper/__init__.py new file mode 100644 index 0000000..b5c68eb --- /dev/null +++ b/config/bitbar/lib/taskpaper/__init__.py @@ -0,0 +1,29 @@ +import base64 +import inspect +import os.path as p +import sys + +PATH = p.dirname(p.abspath(inspect.getfile(inspect.currentframe()))) + +def count(file, icon='default'): + project = '' + items = [] + with open(p.expanduser(file)) as f: + for line in f: + if project.lower() == 'archive': break + line = line.strip() + if line.endswith(':'): + project = line[:-1] + elif line.startswith('- ') and '@done' not in line: + items.append('%s (%s)' % (line[2:], project)) + + if not items: return + + with open(p.join(PATH, icon + '.png')) as img: + icon = base64.b64encode(img.read()) + + print("%d | templateImage='%s'" % (len(items), icon)) + print('---') + print("%s | terminal=false bash=/usr/bin/open param1='%s'" % (file, p.expanduser(file))) + print('---') + for item in items: print(item) diff --git a/config/bitbar/lib/taskpaper/default.png b/config/bitbar/lib/taskpaper/default.png new file mode 100644 index 0000000000000000000000000000000000000000..e7837615de1d8e3acd01b51b12eda8ca257c3477 GIT binary patch literal 413 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VORbm5-W7W@ zqc`cD+T*nJaug*wV=5p8i-3Nhq3GU;}F$;UsI5%{K z+dLBKKA3TkWnaPE+Y5YDb~s2K3%+r}%|nO3ap?~?*=^2Ac^+>zY*t{?wwPo)y>X+& zng?cQW=F^ab=_UDpmVF^1__zzwOoc(!D8KxD@q-^Hx$45&Ro5)Fg^3mOAp8Ex;bnn z@ijfCn`X^Zs7c~JU%SD?Pp9>XA7jkXn&~yRSKdCI%;}a|-|R06XT&W&SJjVxoMxI?LU+>SVj}9n8otGKfrU)-ozUVU@ejR;U@762lYAE*6Yf%3 zqD`dbJ$7c~%Lk0om+Qh`e2M#EbP8>TI#w!-Mw0cPPeMy4VxkY*xR3ka(X@#>9Aiu9 z>QrL%lQ27J2M*BPqO8?SQ!j}9jMx!=dl?3?k(}Lyj!4#Uh=D}V6h`D4uhC#AUQp;7 z_==nKrfFez+8x>lB|}@FCd^JNlU>=cR$*57_7`}HaS?O%GQof6>6DNwdF5XK0000< KMNUMnLSTYgaKe)S literal 0 HcmV?d00001