Sunday, October 16, 2022

AppleScripts to speed Java compile and execute with BBEdit

Students are often asked not to use an IDE (I like Visual Studio Java) for their Java projects. Instead they need to use BBEdit without an IDE. BBEdit does not appear to natively support facilitated compile/execute but it does run AppleScrips that can speed things a bit.

The davalign.com site has some scripts written for TextWranger. If you rename them to BBEdit they work well.

Reproducing them here in case that site vanishes. I didn't see much like this. Note if you open and save in macOS Script Editor they will be compiled. I like that the first action is to save the document, it's easy to forget to save before a compile.

Compile java.scpt

tell application "BBEdit"
save text document 1
set the_file to file of text document 1
end tell

set AppleScript's text item delimiters to ":"
set source_file to the last text item of (the_file as string)

tell application "Finder"
set the_folder to container of file the_file
end tell

tell application "Terminal"
activate
set p to POSIX path of (the_folder as string)
set shell_script to "cd " & (quoted form of p) & ¬
"; javac " & source_file
if (count windows) is 0 then
do script shell_script
else
do script shell_script in the front window
end if
end tell

Run java.scpt

tell application "BBEdit"
set the_file to file of text document 1
end tell

set AppleScript's text item delimiters to ":"
set source_file to the last text item of (the_file as string)
set compiled_file to text 1 thru -6 of source_file

tell application "Finder"
set the_folder to container of file the_file
end tell

tell application "Terminal"
activate
set p to POSIX path of (the_folder as string)
set shell_script to "cd " & (quoted form of p) & ¬
"; java " & compiled_file
if (count windows) is 0 then
do script shell_script
else
do script shell_script in the front window
end if
end tell

Friday, October 14, 2022

Apple Music subscriptions stop working when I changed my Media & Purchases Apple ID

Apple digital rights management (DRM, FairPlay in this case) is very complex, particularly when one adds Family Sharing or has an atypical Apple ID setup.

In our case, for reasons that made sense 10-15y ago, my iCloud Apple ID is different from my Media & Purchases Apple ID. My iCloud Apple ID is the family organizer and my Media Apple ID is a family member.

Over the past few years I've been trying to migrate to using a single Apple ID on my phone. I have migrated all but one family member.

Migration has been difficult. I don't think Apple has published a transition guide. You can't, of course, transfer purchases or media or subscriptions. There's a risk of losing a lot purchases and Apple is unlikely to help.

I looked at doing a test migration on a macOS Monterey account of mine but it seemed Monterey did not a user to change only their Media Apple ID. [Later I found you can. In Monterey, unlike iOS, it's obscure how you do this; it doesn't show up in an Apple ID. You change the Media Apple ID through the App Store (Sign Out, Sign In).]

Since it seemed couldn't test on Monterey without trying a full Apple ID transition I made the changes on my iPhone.  Let's say my iCloud Apple ID was "Sam" and my Media Apple ID was "Linda". So my device Apple ID configuration was Sam/Linda.  After the change it was Sam/Sam. Sam is the Family Organizer, Linda is a family member. Linda owns our app and media purchases -- at least that's where they show up when I look.

I was particularly curious how Apple Music would work including test playlist sharing. Unfortunately I couldn't test the playlist sharing because Apple Music didn't work at all! As far as iOS was concerned I didn't have an Apple Music subscription. It offered to give me 6 months free. I also didn't have any Playlists or other configuration. Music (iTunes) configuration is tied to the Media Apple ID, not the iCloud Apple ID.

To recap, Sam is family organizer and Sam/Linda purchased the family plan Apple Music subscription. Linda shows up in Family Sharing as a family member. Once I became Sam/Sam I had no access to Apple Music. Reviewing Family Sharing it appeared that Sam should have access to Linda's Apple Music subscription. That doesn't work.


... Make sure that you're using the same Apple ID for Family Sharing and Media & Purchases... 

They don't say how to migrate to that idea of course! Obviously it was possible to use a different Apple ID for Family Sharing and Media (Apple Music worked before). I don't know if the changes made to my device impacted any other family members (wish I'd checked!), but it appears for a Family Organizer device to see Apple Music they have to use the same Apple ID used at time of purchase.

Somewhat surprisingly Apple let me revert back to Sam/Linda on my iPhone. (I think there was some time limit/change limit on Apple ID media changes.) After a period of sync I had my old playlist and Apple Music access.

My guess is that to make the change to Sam/Sam and keep Apple Music I'll have to end my current subscription (tied to Linda) then change the Media Apple ID then resubscribe for the family. (In practice I'll end all subscriptions for Linda before the change.)

Friday, September 16, 2022

Expelling demons from 2020 Air: when Disk Utility says to run against the Container (and more)

If you have to maintain a modern Mac, it helps to be retired. How else would I have hours to spend one Friday pm?

The 2020 Air I inherited from my daughter had met with a beverage at a bad time. We paid a third party to resurrect it (Apple doesn't touch wet stuff) but the machine seemed quirky in a software way. Maybe related to the T2 chip and doing the battery swap and then (mistake) Migration Assistant from my ancient Air.

First I had to fix the VoiceTrigger bug, but the machine was slow and I kept running into weird sh*t, like being unable to enable the default App Expose gesture.

So I decided to cleanup by removing files on that machine (they are still on my working Air) and also clean up the user library. I removed a lot of 2007 and earlier items, including a RAZR plug-in. Maybe did nothing but didn't take long.

Then I ran Onyx and it complained the disk was corrupted. When I tried to run Disk Utility I ran into the SMC reset bug.

Once I fixed that Disk Utility would run, but it complained about a corrupt snapshot on my Data drive. Deleting the snapshot didn't fix the error though, so it's likely a red herring. The message said to run fsck on the Container, but I didn't see how to do that. Running it on the Volume didn't help.

The Disk Utility directions were, of course, wrong. As were various web sites that said to try fsck in single user mode (is single user even possible in Monterey?).

Eclectic Light had the best guidance, but the real missing piece was telling Disk Utility to show everyone, not just Volumes. That showed me the Container so I could run DU there; the details console shows it's running fsck_apfs -y -x /dev/disk0s2. It ran against all the /dev/disk* things and fixed them all, exiting successfully. My App Expose gesture returned.

I think the demons are purged for now. macOS is pretty damn fragile these days ...

Monterey T2 bug - First Aid, unlocking disk, operation canceled - Do an SMC reset

When I tried to run Disk Utility on my 2020 Intel Air running Monterey I got:

    Running First Aid on ..

    Unlocking Disk

    Operation Canceled. 

Google found exactly one reference to this in a 2021 Apple Discussion post with a link to an Apple Support article that has since been removed ...

... That turned out to the known issue linked with the T2 Security chip (https://support.apple.com/en-us/HT203127).  Resetting the SMC solved that problem as well as the original problem with the hard drive.

Resetting SMC (I used two methods) fixed the bug and First Aid was able to continue. (There are other problems, but at least this one was fixed.)

I don't know if this insanely rare or if Google simply isn't that useful any more (probably both). Resharing here.

Monday, September 05, 2022

Managing multiple Apple Store Apple IDs in Monterey: how to sign out and thus change default Apple ID for app update and purchase

There's a lot of complexity in Apple's software, but my nomination for the ultimate complexity is the web of undocumented and slowly changing rules and tools around Apple's Digital Rights Management (FairPlay) including rights to use media (music, video) and software (apps) for both individuals and family members.

I don't think anyone truly understands it all, not even Apple's senior developers. Sometime in the past decade Tim Cook said he'd fix the Apple ID problem and then things went silent. It's a nightmare. I remember when changing a phone number associated with an Apple ID could switch the ownership arrangement for device history (presumably a matching problem between disparate databases).

My most recent experience with this was trying to fix the default Apple Store Apple ID used to for Mac App Store DRM on my wife's Air Monterey account. It was defaulting to an Apple ID we used to share for iTunes purchases 10+ years ago. I've been slowly disentangling it for 4 years now and the rules change with each macOS/iOS release. Currently there's a bit more tooling to sort out who owns what on a Mac but it's obscure.

As far as I can tell the controls for this are now hidden in the App Store app. That kind of makes sense, because the rules (and Apple's DRM contracts) for movies/TV, music and apps are all likely different. You have to go into the App Store app, which can show the apps associated with multiple Apple IDs, then you have to sign out from the menu:

After signing out the default account for App Store purchases was her Apple ID.

Her Music account seems to be based on her Apple ID, but I didn't check to see if changing the App Store Apple ID changed that too. It would make sense if Apple were to have separate rules though. 

I think the complexity of Apple ID DRM may be one of the reasons Apple never provided a multi-user iPad for families. (Our shared iPad has its own unique Apple ID but is a member of our family sharing.)

Monday, August 29, 2022

Monterey orphaned our physical podcast files. What can we do with them?

Podcasts started out as distributing MP3 files; back then iTunes was a great podcast app (and music and audiobooks, and voice memos and more -- it was a glorious app before the fall.)

Over the years Podcasts really shifted to streaming, listen once, don't keep. Then, somewhere post Mojave (Monterey) Apple orphaned the physical podcast files stored in iTunes. The Finder shows physical files in your media library but neither Music.app or Podcast.app can browse them. Music. app's browser Get Info still shows the media type dropdown, but there's only one type! (Music)

If you click on a podcast file iTunes will play it and import the file into the media library where it has media type Music but genre podcast.

So the fix is:

1. Move Podcast folder out of media library

2. Reimport all podcast as music.

3. For genre podcast multi-edit to make more like podcasts. You use macOS Music.app column browse to see all with genre "podcast", select all then hit cmd-I. You'll see a prompt asking if you wish to multi-edit (yes). Then in Options select: 'remember playback position' 'skip when shuffling'. I think this operation may fail if a file is being uploaded to Apple Music (at least I get to burn GB of Apple Storage!) so let uploads complete if it doesn't work.

Reference Stack Exchange.

PS. Voice Memos are supposed to have a migrate path, but that didn't show for me.

Saturday, August 27, 2022

Using Apple's USB-C to T2 adapter: not for video but still good

My 2015 MacBook Air uses Thunderbolt 2; it was connected to an elgato T2 hub (reliable for over 6 years) with a few USB and Firewire 800 peripherals. That Air is in for a battery swap after which it will be primarily an Aperture machine with some portable use. At the moment I'm sharing my son's 2020 Air; there may be a Pro or M2 Air ahead.

To reduce costs and hassles I decided to try Apple's T3/USB-C to T2 adapter. It costs around $45. Everything works for now -- except my external HDMI monitor. It flickers on and off. I might play with it a bit but for now I have it connected directly to the laptop via a compact Anker USB-C hub [1]. Apple tells us that "This adapter does not support DisplayPort displays...". I wonder if the HDMI display connected to a Hub with a DisplayPort/T2 cables affected by this limitation.

Overall it's worth the money, even though I'm likely to switch everything to a USB-C or better hub eventually. The single remaining Firewire 800 device can be retired.

- fn -

[1] When I disconnect the laptop I have to pull two cables! Oldness helps with the indignity.