Toxblh / MTMR

🌟 [My TouchBar My rules]. The Touch Bar Customisation App for your MacBook Pro
https://mtmr.app
MIT License
4.22k stars 220 forks source link

colored text and an updatable icon? #428

Open jmcmains opened 2 years ago

jmcmains commented 2 years ago

I'm creating a personalized version of the pomodoro button, and I originally set it up to change color based on the remaining time. But I'd also like to include an icon that displays the count of Pomodoro cycles, so basically a combination of the output of a shell script and an apple script. so I'm sort of asking a 2 part question: can I either: a) display a dynamic icon in shell script buttons? b) dynamically change text color in an apple script button? example

Thanks for any help!

jmcmains commented 2 years ago

Looking over the code, it seems like my issue might be properly formatting the output of the shell script: image I'm currently attempting to output json as a string, but it seems to throw an error: Expected to decode Dictionary<String, Any> but found a string/data instead.

here is the json string that my shell script outputs:

{"title":"25:00","image":"~/Library/Application Support/MTMR/pomodoro/t1.png"}
jmcmains commented 2 years ago

I was able to get a little further on this by figuring out that the issue was that I wasn't sending the image element correctly, but, ultimately i realized I could just do this with two separate buttons. It feels sort of hacky, but it solves my problem for now. Would still be nice to know if there is a proper way to output a shell script to display an icon though.