Touchbar - getting it to work with Java / Minecraft

I'm trying to make BTT display a custom touchbar for a java app (specifically Minecraft). I have used the "select running app" option and chosen "java", and configured a touchbar, but it never appears. Other app-specific touchbars all work fine.

There seem to be several discussions around this subject, some of which suggest that this is possible, but I have yet to find a solution that works for me. Any help/advice would be much appreciated.

1 Like

Did you ever figure this out? I'm keen to do something similar (again Minecraft)

I have also since found this page, but it does not work (with Minecraft 1.13 at least, this release also breaks the icon and display name, so I expect the BTTAppBundleIdentifier has changed - but can't figure out for the life of me how to look up the current BTTAppBundleIdentifier value.

Sorry to keep posting, I'm hoping someone can help me with this, so putting up what I'm finding :slight_smile:

I have now also found lsappinfo, that appears to have the potential to give me what we need, but for the running Java app, the output is not so good:

61) "java" ASN:0x0-0x149149:
    bundleID=[ NULL ]
    bundle path="/Applications/Minecraft.app/Contents/runtime/jre-x64/1.8.0_74/bin/java"
    executable path="/Applications/Minecraft.app/Contents/runtime/jre-x64/1.8.0_74/bin/java"
    pid = 18069 type="Foreground" flavor=2 Version=[ NULL ]  fileType="????" creator="????" Arch=x86_64
    parentASN="Minecraft Launcher" ASN:0x0-0x146146:  (inferred)
    checkin time = 2018/08/22 07:38:07 ( 19 minutes, 59.3683 seconds ago )

So I tried to modify the JSON above to match a BTTAppBundleIdentifier of "NULL", which let me add it, but did not work (trying to match the string NULL with an actual null value I assume), and trying to add the JSON with an actual JSON null just ignored my paste request (which makes sense I guess, as it's not very normal).

Unfortunately some java apps are still problematic. Selecting Minecraft while it is running from the list of apps doesn't work?

I should have mentioned that I tried that one first, and although it let me select java, when going to Minecraft the TouchBar widgets don't come up unfortunately :frowning:

Is mine craft really started or is it still in the "launcher"? (I think you would need to select not the launcher but the actual game).
I can try it maybe tomorrow.

This is what I have at the moment configured:
image

The entries are as follows:

  • "java": Me selecting the running program in BTT (ie: after actually starting it from the launcher)
  • "Minecraft" (the first one): This is the launcher app, and this works as expected (I'm just using Widgets for my testing at this stage)
  • "Minecraft" (the second one, with no icon): this is from pasting in the JSON on the linked GitHub issue
  • "MinecraftJavaNull": This is me hacking the JSON to match the string "NULL" for the BTTAppBundleIdentifier attribute

I was obviously hoping one of these combinations would work, but so far no luck. If you have any other thoughts, or ways I could mess with the JSON, I'm happy to have a crack, but so far have not been able to find much info about it (eg: matching on process path or similar, maybe matching on all processes in a process/app tree?)

Thanks!

I got the functions keys to work by adding this to the com.apple.touchbar.agent.plist in the preferences folder:

under the last "dict" tag
a new "key" tag with net.java.openjdk.cmd
and a "string" tag with functionKeys

EDIT: you can run this command from the Terminal:

defaults write com.apple.touchbar.agent PresentationModePerApp -dict-add net.java.openjdk.cmd functionKeys

maybe you can do something with this "net.java.openjdk.cmd"?

Thanks @wodan74, I tried that by pasting JSON config directly (see the github issue linked), unfortunately it didn't work.

I'm guessing that the Java with Minecraft has changed since v1.13 or something and the AppBundleIdentifier has changed (or is no longer there based on the output of lsappinfo).

Cheers

I have added an option to match for the executable path in the latest alpha/RC
https://updates.bettertouchtool.net/alpharls.html

It works using the new "Conditional Activation Groups"

Looking good! Thanks!

(For others, I used the appExecutablePath of /Applications/Minecraft.app/Contents/runtime/jre-x64/1.8.0_74/bin/java)

Appreciate the quick response!

Here is the preset I am using to get some basic Minecraft functions on the touch bar, namely F3 for debug and fullscreen. It works with Minecraft 1.14.2 and the current latest launcher (excluding betas). Although it works, it is rather hacked together. It checks whether the processes "java" and "Minecraft Launcher" are running independently, so theoretically if you had Minecraft open as well as another java process, these touch bar buttons would apply to the other java process as well. If there is a better way for the current/future versions of Minecraft, please let me know!!! Minecraft.bttpreset (58.7 KB)

Here's a much better preset. The newest version of Minecraft is currently 1.14.3, so it uses a conditional activation group that is:
executable path matches \/Users\/.*\/Library\/Application Support\/minecraft\/runtime\/jre-x64\/jre.bundle\/Contents\/Home\/bin\/java
Here's the BTT Preset that includes two buttons, one for toggling the debug screen and one for toggling macOS native fullscreen.

Minecraft.bttpreset (59.5 KB)

1 Like

How do I get this to work? Whenever I open the file it says missing application.

Make sure to replace * with your user folder name. Also, check that java is installed; go to terminal and type in ls -a ~/Library/Application\ Support/minecraft/runtime/jre-x64/jre.bundle/Contents/Home/bin
If you see “java” then this present should work if you replace the asterisk.

What version of Minecraft are you running?

This preset works great. I improved it a little bit, but it seems that this community requires participation karma before I can send attachments. ¯_(ツ)_/¯

here's a screenshot I guess. The 3-step sequences have key-down on the first F3's, and key-up on the last F3's. Copy/paste was buggy and I had to reset that each time. I don't see why this preset won't work with any version of minecraft, as long as the JRE is at the path specified. Tested as working on 1.15.2.