Help with JSON string 'return' aka new line

Hello, I would like some help with JSON strings.

I like the look of the native Now Playing widgets, I like how you can place things on different lines and with varying font sizes etc.. However, I use chrome and so I have to use my own Now Playing widget for things like youtube.

Now, I would like to mimic the look of the native Now Playing widget with my custom chrome widget. I can almost get there with just apple script but it would be a lot better if I could use JSON controls to change the font size of items.

How would I go about using JSON to mimic the native Now Playing Widget? Possible to mix applescript and JSON in a return?

This is basically what I do now:
return trackInfo & return & "(" & duration & ")" & " — " & album

but need something like this to work:

"{"text":"" & trackInfo & return & duration & album & ""}"

I've been trying \r and \n but it does some weird stuff :confused: where the text is off screen

an example of what I start with just using applescript (left) and what I would like for it to look like (right)

Escape special chars like so:

"{\"text\":\"" & trackInfo & "\\n" & duration & album & "\"}"

:+1::grin:Thank you! That worked.

Is it possible to make the track info a different font size than duration and album?

Not easily as far as I know. Maybe @Andreas_Hegenberg can add support for primary and secondary labels in widgets.

The only workaround I can think of is to render the entire widget (album art, labels) yourself to a bitmap and pass that as a base64 encoded string. It’d be fairly straightforward by writing a custom CLI utility that uses CoreGraphics, but if you’re using AppleScript then you’re kinda out of luck.

1 Like

whew, a bit beyond me, I'm pretty happy with this for now

I have another question that is related. I would like to do something like this with the JSON string options:

Where I basically have the icon occupying the full height of the TB and the text information on 2 separate lines. Its pretty much like how the Now Playing widget acts with the cover art and album info. But this would be for the weather and the icon is just a string (emoji). Possible?

I'm not using the native weather widget, just my own for right now but would it be possible in either case?

Yes, just add a \n to your output.
I'll soon expose the "detail" text line, so users will be able to use a small detail text line like in the "Now Playing" widget.

I don't understand :confused: Could you demonstrate with the native widget

for instance I have: {icon} {temp_rounded} \n {humidity} which gives something like fraction1

and I'm looking for:


If you leave out the {icon} BTT will place it on the left :slight_smile:
This however only works with the native BTT weather widget.

1 Like

your "now playing" JSON is good !!!!!

can you share your "now playing" JSON ? I'm not a developer..I can't make it.

I'm happy to help you out, I'm not a dev either and have been just picking things up as I go. Are you just interested in the iTunes now playing widget?

Have your tried adding a native now playing widget? its about 99% the same thing as mine :slight_smile: would be a bit easier to use and customize too

Yes! I just use iTunes!

thank you :slight_smile: