GoldenChaos-BTT Support and Feedback Thread

Ok wait, looks like I'm making progress. I managed to get them both working:

tell application "Mail"
set mainaccount to mailbox "INBOX" of account "Main"
set mainunreadvalue to the (unread count) of mainaccount
end tell
return mainunreadvalue

That's the code i used for the first one, and this is the code for the second:

tell application "Mail"
set enqaccount to mailbox "INBOX" of account "Enquiries"
set enqunreadvalue to the (unread count) of enqaccount
end tell
return enqunreadvalue

It was working kinda weird though. The main one seemed to keep switching to the count of the Enquiries one. So it would have the right count for a minute, but then it'd be showing me the count for the other account. I realised that the variables needed to be unique along both scripts.

Man, Olivier, thank you so much. Any ideas how I can get the numbers of the total number of emails in a respective inbox?

Is there anything special happening with the hold down volume to mute, or is that just how the widget works?
I'd love to do include this in my Now Playing widget to mute if held down.

There is a named trigger for mute and, in the Volume Down button preferences, you'll see the named trigger entered under the "long press" option :slight_smile:

Ah sorry, there was a configuration issue with my reverse proxy that blocked too big files. This should now be resolved.

1 Like

I'm running into an issue with Fantastical. For whatever reason, none of my events are showing up after I update to my calendar names. There shouldn't be any problems if my calendars are from Google Calendars right?

Do you have iCalBuddy installed? The calendar widget doesn't actually get its data from Fantastical, it uses iCalBuddy :slight_smile:

Yeah. I have icalbuddy setup and if I type "icalbuddy eventsToday" in terminal, I get my calendars. However, if I try to run your script in BTT, I get "" in the results.

Strange. The script is working for me. I'll play around and see if I can make the script more reliable somehow, I have a few ideas.

I'm getting "error: No calendar" now, which is an improvement. I also installed the homebrew version of iCalbuddy since the other one was giving me issues (quick google search recommended I install the homebrew version).

Could you try the downloadable version from the official website? That's what I'm using afaik, so that might fix it for you. I'll try out the brew version and see if I can get it to work in the meantime.

Also, dang - we've blown through my Dark Sky API calls already! The weather widget is returning an error as a result. I'll figure out a new solution, haha. @Andreas_Hegenberg do you have any solutions for a weather widget? I feel like I've tried every weather script out there at this point and they all have significant drawbacks.

Actually, I was using the official one. I installed it via the install command in the downloaded folder.

I ended up getting this error:

I followed the resolution there. I should note that using icalbuddy in terminal worked fine using the official. It’s just in BTT I’m getting the errors.

OS: Lastest stable version of High Sierra.

P.S. I freaked out thinking I did something wrong with the new dark sky weather script and it wasn’t working for me only. I reverted back to the Apple script for the time being.

i think it would be better to wrap the whole album art related part of the itunes script in a try statement, because now the widget isn't shown when a song has no album art, because itunes throws an error
here is my quick and dirty fix, it uses a default icon at the same place the album art is temp stored

tell application "System Events"
	set num to count (every process whose name is "iTunes")
end tell
set maxSize to 20

if num > 0 then
    
	try
		tell application "iTunes" to tell artwork 1 of current track
			set srcBytes to raw data
			-- figure out the proper file extension
			if format is «class PNG » then
				set ext to ".png"
			else
				set ext to ".jpg"
			end if
		end tell
	    
	    
		set fileName to ((((path to application support folder from user domain) as text) & "BetterTouchTool:" as text) & "itunes_cover" & ext)
		-- write to file
		set outFile to open for access file fileName with write permission
		-- truncate the file
		set eof outFile to 0
		-- write the image bytes to the file
		write srcBytes to outFile
		close access outFile
	on error
		set filename to ((((path to application support folder from user domain) as text) & "BetterTouchTool:" as text) & "default.png")
	end try
    
	tell application "iTunes"
		set playState to (player state as text)
		if playState is equal to "playing" then
			set trackName to name of current track
			set artistName to artist of current track
			set albumName to album of current track
			if length of trackName is greater than maxSize then
				set trackName to text 1 thru (maxSize - 3) of trackName & "..."
			end if
			if length of artistName is greater than maxSize then
				set artistName to text 1 thru (maxSize - 3) of artistName & "..."
			end if
			set trackInfo to artistName & " - " & trackName
		else
			set trackInfo to "Paused"
		end if
		return "{\"text\":\"" & trackInfo & "\",\"icon_path\":\"" & (POSIX path of fileName as text) & "\"}"
	end tell
else
	return ""
end if
1 Like

I'll incorporate this into my preset with the next release :slight_smile: thanks for the fix!

1 Like

Any ideas on how to alter that Things 3 script to work with Todoist? I know TD has a rather robust web API, and I'm hoping I can do something similar to what you've got going with Things. Thanks!

another very small fix, in the youtube widget script if only safari is running but not youtube the script doesn't return, this causes the widget to continue showing the last youtube clip, even if that tab is already closed. I added a return statement after the loop, at the end of the safari clause to make sure it always returns something

if application "iTunes" is running then
    return ""
else if application "Spotify" is running then
    return ""
else if application "Safari" is running then
    tell application "Safari"
        repeat with t in tabs of windows
            tell t
                if URL starts with "https://www.youtube.com/watch" then
                    return name of t as text
                end if
            end tell
        end repeat
    end tell
    return ""
else
    return ""
end if
1 Like

Ooh! Have you been able to work out a hierachy player script?! Must play around soon!

Also interested in this! I currently use a shortcut to add to my Todoist, but would love to get a display going. I was thinking of working with IFTTT, creating a Dropbox file then reading that through BTT. Again quite a large workaround, but it might be worth exploring as it'd create a ton of possibilities for other IFTTT services...

I've got some other projects going on, so for now I can't look to much into this.

My biggest issue has been gaining access to Dropbox folder.
Here's the script if you want to try?

tell application "System Events"
set the_folder to path to folder "dropbox" from user domain as string
set the_file to "ToDo.txt" of (POSIX path of the_folder)
set the_text to (do shell script "cat " & quoted form of (POSIX path of the_file))
return the_text
end tell

** edit: Script was way off:

tell application "System Events"
set the_folder to the folder "~/Dropbox"
set the_file to the file "ToDo.txt" in the_folder

set the_text to do shell script "cat " & ¬
quoted form of (POSIX path of the_file as text)
end tell

return the_text

** Edit again. I've made a tutorial that's a lot cleaner.

It still uses multiple widgets each with their own conditional statements. I might try combining them into one widget in the future, but then you'd lose all the nice custom app icons.

As for todoist, I don't personally use it and I'm not familiar with their API, but if you guys manage to get something working I'll include it in the preset :slight_smile:

Hi @GoldenChaos this is truly amazing. I appreciate all the work you did with this.

  1. Is there a way to include the Do Not Disturb icon for immediate access? Is the only action that I currently use with the stock (and terrible) touch bar.

  2. Is there a way to switch Farenheit to Celsius on the weather widget?

Many thanks in advance, and congratulations on the hard work.

1 Like

I'm glad you're enjoying the preset :slight_smile: to answer your questions:

  • There is a Do Not Disturb toggle in the expanded control strip - just hold down the Option key, it's next to Night Shift. Most every button available on the stock control strip is there, plus some extras!
  • If you edit the weather widget, you'll find a line for Celcius conversion commented out. Just uncomment it and bam! SI units.