Created
January 2, 2023 18:33
-
-
Save robeden/7872d25316358111d3ee8f1e543780fd to your computer and use it in GitHub Desktop.
xbar plugin for showing tasks in Things 3's "Today" list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This is based off the "Thing 3 Today" plugin by Max Clayton Clowes (maxcc@me.com) | |
# | |
# Modifications: | |
# - Task count is shown in menu bar | |
# - Whitespace stripped from task names | |
function tellthings() { | |
osascript -e "tell application \"Things3\" | |
$1 | |
end tell" | |
} | |
if [ "$1" = 'launch' ]; then | |
tellthings 'activate' | |
exit | |
fi | |
case "$1" in | |
'show quick entry panel' | 'log completed now' | 'empty trash') | |
tellthings "$1" | |
exit | |
esac | |
if [ "$1" = 'complete' ]; then | |
tellthings "set toDo to to do named \"$2\" of list \"Today\" | |
set status of toDo to completed | |
delay 1.3" | |
exit | |
fi | |
if [ "$(osascript -e 'application "Things3" is running')" = "false" ]; then | |
echo "☑ ❌" | |
echo "---" | |
echo "Things 3 is not running" | |
echo "Launch Things3 | bash='$0' param1=launch terminal=false" | |
exit | |
fi | |
items=$(tellthings 'set targetList to {} | |
repeat with n from 1 to count of to dos of list "Today" | |
set toDo to item n of to dos of list "Today" | |
if activation date of toDo is equal to missing value then | |
else | |
copy name of toDo & "|" & status of toDo to the end of the targetList | |
end if | |
if n > 20 then | |
return targetList | |
end if | |
end repeat | |
return targetList'); | |
count=0 | |
IFS="," | |
for i in $items; do | |
count=$(($count+1)) | |
done | |
echo "☑ ${count}" | |
echo "---" | |
echo "Today..." | |
IFS="," | |
for i in $items; do | |
IFS="|"; | |
# shellcheck disable=SC2086 | |
set "--" ${i}; | |
name=$(echo ${1} | xargs) # This trims whitespace (had a space at front) | |
if [ "$2" = "open" ]; then | |
item="☐ ${name}"; | |
else | |
item="☑ ${name}"; | |
fi | |
echo "${item} | bash=$0 param1=complete param2='${1}' terminal=false" | |
done | |
echo "View more... | color=#aaaaaa bash='$0' param1=launch terminal=false" | |
echo "---" | |
echo "New to do | bash='$0' param1='show quick entry panel' terminal=false" | |
echo "Log completed | bash='$0' param1='log completed now' terminal=false" | |
echo "Empty trash | bash='$0' param1='empty trash' terminal=false" | |
echo '---' | |
echo "Open Things 3 | bash='$0' param1=launch terminal=false" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment