Display a todo list in the menu bar with items taken from the macos' Reminders.app from the list called 'Today'. Click the item to complete the reminder and display the next one.
#!/bin/sh
# <xbar.title>Todo List for menu bar</xbar.title>
# <xbar.version>v1.0</xbar.version>
# <xbar.author>Julian Naumann</xbar.author>
# <xbar.author.github>JulianNaumann</xbar.author.github>
# <xbar.desc>Display a todo list in the menu bar with items taken from the macos' Reminders.app from the list called 'Today'. Click the item to complete the reminder and display the next one.</xbar.desc>
# <xbar.image>https://i.imgur.com/d4cBUKW.png</xbar.image>
# <xbar.dependencies>bash,osascript</xbar.dependencies>
# <xbar.abouturl>https://github.com/JulianNaumann/bitbar-todolist</xbar.abouturl>
# Icon credit, all icons from <https://www.flaticon.com>:
# - Bell icon made by Nice And Serious <https://niceandserious.com>
# - Todo list icon made by Freepik <https://www.freepik.com>
# - Check icon made by Smashicons <https://smashicons.com>
if [ "$1" = "done" ]; then
osascript -e 'tell application "Reminders"
set activeReminders to (reminders of list "Today" whose completed is false)
set todo to first item of activeReminders
tell todo
set completed to true
end tell
end tell'
fi
reminder=$(osascript -e 'tell application "Reminders"
set activeReminders to (reminders of list "Today" whose completed is false)
if activeReminders is not {} then
return name of first item of activeReminders
else
return "No Todos!"
end if
end tell')
# Choose a different icon by uncommenting the appropriate line and commenting out all others:
# todo list
image=iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAYAAAByDd+UAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAABYlAAAWJQFJUiTwAAABWWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNS40LjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0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xST0FlFzMGMYY4MRbNia1nT2qKp5wGx77ZCKDbKqqrg4idCuqrVcLWmtdVocBXLzc6eNTNpItqNbIuR5qeGNa2tRgWfswU407vt24fa1Xopu3GH6At1RhZgbTXU6pyBziBHv0x2vA3lym4S/BEerJPSRmuroVbnNpzTAOUe9Dzr/xqfnOvYHpBDdUomnvE5/Gp1nsHLGiB913bTm6OsYw3Kg3WesRV4oo4p68RWQ63OIuxqgLWz6nlXn9PcK5ZCp7AV8xUorJETmnuvarzXWNuGBDvbswbUiIC3sY9if4bXdALbJ0tkEbZarQHBJDhzX9I3DKqhkA+22A8/wHK8PEDGiAHB9Vp6jATHH8HdMBjHeAXvxcE1hQtXZcZvSxddzRKcqIZWe+8nxbEX0NeS9nN4GIoH0Pak5a7cb98wZIvUWLKQH0+/Z8LvYKCoz5Ev4JPwIbwPX0OLnIZCMb+D/0JqqqFW64OfA2LsJfgEun+iHOt5+n/Tzr4H3/1YgDN1bA5FmZrE0md32pBa1lZDrQq+WNte3gpkP0YRy+p9n/a9vFV0r+bhrDfAwsNWpX/Y0TenhLmZnDWtrUaFzOR/fYCtF7GhH+By1tMEb/hfDJepaPZFUZ8xW2H/A8edve0qqS+5mO1/ogwSJiXR9tp3N9sT5rFugzHGmmOuNURZt+l1b2h1pRv2RzibG0Gv+mxZ3h4+O1OwC/2rvxdmxSvYy3Dkv/p/ATQejPjjKGMzAAAAAElFTkSuQmCC
echo "$reminder | length=30 bash='$0' param1='done' terminal=false refresh=true templateImage=$image"