Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hs.touchbar - Add Extension for Touch Bar Support #1078

Closed
latenitefilms opened this issue Nov 14, 2016 · 84 comments
Closed

hs.touchbar - Add Extension for Touch Bar Support #1078

latenitefilms opened this issue Nov 14, 2016 · 84 comments

Comments

@latenitefilms
Copy link
Contributor

Sorry - I've been out of action the last couple of weeks on an interstate film shoot.

Has anyone had a chance to look into the Touch Bar API as of yet?

It would be AWESOME if you could build something similar to this using Hammerspoon:

https://red-sweater.com/touche/

Thoughts?

@latenitefilms
Copy link
Contributor Author

This might also be of interest:

https://github.com/bikkelbroeders/TouchBarDemoApp

@Habbie
Copy link
Contributor

Habbie commented Nov 14, 2016

@cmsj mentioned https://github.com/bikkelbroeders/TouchBarDemoApp which also has useful code to steal I bet

@cmsj
Copy link
Member

cmsj commented Nov 15, 2016

I'm not exactly sure what we could bring to the table that those apps aren't already covering. Does anyone have something in mind?

@asmagill
Copy link
Member

I took a look at TouchBarDemoApp last night... When used without an iPad/iPhone as the "display", the bar appears right above the mouse cursor... I guess that makes sense since you have to use the mouse pointer to select the button you want, but from a visual standpoint, I might like more control over where the bar appears and maybe a way to make it persistent (both of which could more easily be done with the existing app, if they're accepting feature or pull-requests).

And while the PeerTalk framework looks interesting for communicating with physically attached iPad/iPhone devices, without having an iPad application to go with Hammerspoon, it's at best an interesting third-party module... with sideloading required to get even that, I'd much rather see a web/websocket interface to Hammerspoon explored that any web browser/web-enabled-app on any device could potentially use over the network and not require the physical connection. It think we have all of the pieces needed for this already.

I tend to agree that I'm not sure what we can add to this.

I'm much more interested in the idea of creating our own touch bars... it looks pretty straight forward to create a "Hammerspoon" touch bar, but I'm not sure yet if we can add anything to the touch bars of other applications.

Just my 2 cents...

@latenitefilms
Copy link
Contributor Author

@asmagill - I definitely think you should look into creating a proper Hammerspoon Touch Bar. I'd love to be able to press a button and instantly get up the Console.

However, why I'm interested in you porting the TouchBarDemoApp to Hammerspoon, is that in Final Cut Pro for example, Apple's added some features to the Touch Bar that don't really exist in the native Desktop app. There's a few button's in the Final Cut Pro touch bar, that users would LOVE to have on their older Mac laptops and desktops, even if it's controlled via a mouse. Why I want this functionality in Hammerspoon rather than a 3rd party App, is that then I could control when the Touch Bar appears, it's position on the screen, and in a perfect world, it would be awesome if you could programatically manipulate the touch bar (i.e. in the case of Final Cut Pro, I'd only show the user Touch Bar options that don't already have a easy-to-click Desktop app equivalent.

For me, bringing this functionality into Hammerspoon is all about control. I want to be able to control the Touch Bar simulator.

One day I would LOVE to see an iOS Hammerspoon App (which you "control" via the Desktop scripts) - but that's a big engineering challenge, and a discussion for it's own thread!

Any questions let me know!

@cmsj
Copy link
Member

cmsj commented Nov 15, 2016

@asmagill for injecting HS into other apps' TouchBars, we'd have to use code injection. I have done some work on this (see cmsj@79f76bc ) but it's extremely ugly, requires building a 32bit version of everything, and for some weird reason I had to completely butcher parts of LuaSkin's objects, to make it work.
My idea was that I'd inject LuaSkin into arbitrary apps, and then build some kind of layer on top of that to inject Lua into that LuaSkin object, but it was all feeling so ugly that I've pretty much abandoned the idea. It would also be extremely fragile, since you're messing with the private state of an app that could be updated at any time.

I'm afraid I'm not convinced that we should implement a TouchBar feature. I can see how it might be fun/useful, but I think the amount of work involved would outweight the benefits. If someone else wants to work on it, please don't let me stop you :)

As for a companion iOS app, it's something I've looked at before, there's an Issue open - #412 - and some code exists already, but I've not had much time to work on it.

@cmsj cmsj closed this as completed Nov 15, 2016
@asmagill
Copy link
Member

@cmsj, I suspect you're right about needing code injection... the little I have read so far talks about needing to put the NSTouchBarItems into the active NSTouchBar of the Application's responder chain, something I don't think we can access without code injection... I may toy with creating a Hammerspoon touchbar at some point (conceptually it seems similar to the toolbar code already in hs.webview.toolbar) since we can always programmatically make Hammerspoon the active application, then switch it back once "whatever" has been touched/clicked... but I tend to agree, short term I don't see it as a priority.

@latenitefilms are you certain the actions aren't available any other way? Apple guidelines strongly suggest that developers should never put something into the touch bar that can't be accessed another way since right now very few actually have the touch bar. (Of course it wouldn't be the first time a developer has ignored Apple's guidelines, but... this soon after its introduction?) I haven't explored it with axuielement yet though, so that may offer possibilities.

@latenitefilms
Copy link
Contributor Author

@asmagill - It's not so much that the actions aren't avalibile any other way, however for example, when you have a MacBook Pro with a Touch Bar and are using Final Cut Pro (which is made by Apple), it will display a mini-timeline on the Touch Bar, allowing you to very easily and quickly jump between different sections of the timeline with the tap of your finger. This feature doesn't really exist as part of the standard desktop app - you can't "jump" to a specific timeline section in one click, you just have to use the normal scrollbars. This "mini timeline" alone would be REALLY handy to desktop users WITHOUT a Touch Bar. I could then use Hammerspoon's amazing GUI Scripting abilities to keep track of Final Cut Pro's window positions, and "move" the Touch Bar Simulator so that it basically "feels" like it's a native part of the App. So although the 3rd Party Touch Bar tool is interesting - all it does it just display the Touch Bar on your screen. What I would like to do is CONTROL how that Touch Bar Simulation is positioned, and control WHEN it's visible.

I'll download the TouchBarDemoApp and have a play - but I don't think I'm smart enough to "port" it across to Hammerspoon sadly.

touchbar

@asmagill
Copy link
Member

@latenitefilms hope you don't mind... I needed a diversion and came up with this: https://github.com/asmagill/hammerspoon_asm/tree/master/touchbar

It just shows and hides the touch bar (and a few additions I wanted like automatic dimming and more control over placement) -- you'll need to wrap it with a hotkey or eventtap watcher to toggle it as you prefer, but it seems to work well for me so far.

I hope this doesn't dampen your interest in possibly contributing something in the future... it's really not that hard once you've done it a time or so... you can check out my walkthrough at https://github.com/asmagill/HS_ModuleWalkthrough/ if you like... it's a little dated, and I would trust the sample code a little more than I would the readme (as an example, we're importing the frameworks as modules now, so @import syntax needed to be added to the Makefile, and while I've checked that the code itself still compiles, I haven't had a chance to update that readme yet), but conceptually its still accurate.

I'm hoping over the December holidays to do a set of Wiki documents going into detail with LuaSkin and our object helpers, and that should help as well.

@latenitefilms
Copy link
Contributor Author

@asmagill - You're AMAZING! Thank you so much!! I need to update macOS before I can play, but will do this tonight, and give it a proper test run tomorrow!

I'll also definitely look into the Module Walkthrough properly at some point too!

Thanks again! I'm hoping to get back to doing some HS coding over the next few days, as I've been flat out the last couple of weeks.

@asmagill
Copy link
Member

I should note that I'm not completely happy with the garbage collection during a reload of Hammerspoon...

Essentially the code creates a window and then streams the video from the touchbar into it using undocumented/private functions to get at the stream... since the sample app does one thing and one thing only, it just relies on the normal application teardown to clean things up when you quit it... we have to be a little more careful (well we should be, since we support reloading without quitting). Usually any module which uses a window (hs.drawing, hs.webview, my canvas/enclosure modules, etc.) includes a [window close] as one of the final actions when the lua object representing it is garbage collected. When I do that with this, Hammerspoon crashes.

I did add code to stop the stream (the sample app didn't), but until I can dig a little deeper, anything else I add results in a crash, so... if you reload Hammerspoon a lot (without completely quitting it and then re-opening the application from the Finder), then I strongly suspect that this will leak memory... slowly, but still...

It's worked well for me for the last 24 hours (it's interesting to see what different applications put into the bar), but until I am more comfortable with the garbage collection portion, I wouldn't even consider adding this to core... and even then, since the undocumented calls are pretty new (we do already use some in Hammerspoon, but the ones I'm aware of have been around since at least 10.8 or longer and haven't changed in all that time)... well, I'll go with the consensus once I think it's ready.

@latenitefilms
Copy link
Contributor Author

@asmagill - This is really helpful and awesome - thank you!

I'm wondering - is there a way to "crop" the Touch Bar window? A lot of the Touch Bar icons on the far left of the "screen", are generic macOS functions (like volume, brightness, Siri, etc.) - which I don't really need. Thoughts?

Is there also a way to "scale" the Touch Bar window? Currently the icons are fairly large - I wonder if there's a way to make everything just a little bit smaller?

The ability to drag the Touch Bar around the screen with your mouse could also be a handy addition?

I've had a quick look through your Objective-C code to see if I could understand it, and I have absolutely no idea, so sadly these are additions I could definitely not do myself.

Thanks as always for your amazing code and support!

screen shot 2016-11-18 at 9 28 29 am

@asmagill
Copy link
Member

As to the system icons, that is determined by the setting in the Keyboard panel of the Keyboard System Preferences:

screen shot 2016-11-17 at 5 32 19 pm

As to resizing, at present, no, I don't think we can resize it... it's basically a streamed view of the touchbar display into a window and the stream is coming from non-published methods... I just don't know enough about the video source to manipulate it at present.

@latenitefilms
Copy link
Contributor Author

As to the system icons, that is determined by the setting in the Keyboard panel of the Keyboard System Preferences:

Perfect, thanks!

As to resizing, at present, no, I don't think we can resize it... it's basically a streamed view of the touchbar display into a window and the stream is coming from non-published methods... I just don't know enough about the video source to manipulate it at present.

No worries! Thanks @asmagill!

@latenitefilms
Copy link
Contributor Author

@asmagill - Because the Touch Bar is context sensitive, one of the issues I have is that if the Touch Bar is at the bottom of the screen for example, but the thing I want to control is at the top of the screen, when I move my mouse from the top of the screen to the bottom, obviously the Touch Bar changes. It would be great if there was somehow to hold down a modifier key, to prevent the Touch Bar from updating.

@asmagill
Copy link
Member

We have no control over what is presented in the touch bar itself -- all we are doing is streaming what the Mac would be showing in the touch bar if your Mac had a physical one.

You can move the touch bar window closer to your desired target if the problem is that mouse movements over the window causes the touch bar contents to change, but that's the best we can do -- we have no control over what is actually in it.

@cmsj
Copy link
Member

cmsj commented Nov 24, 2016

Shall we re-open this? If the code can be hammered into shape, maybe it should go in?

@latenitefilms
Copy link
Contributor Author

@cmsj - I've been using @asmagill awesome Hammerspoon code in FCPX Hacks shortly after he released it, and it's been working great for me! Haven't noticed any major bugs or issues yet.

@asmagill
Copy link
Member

I've added some additional methods and provided an example of how it might be used with an option to drag it into a new position without requiring console use.

I'd still like to clear up the __gc issue properly, and I'd like to find a way to detect when the user is customizing the toolbar so we can force it to alpha = 1... it's annoying to have it auto-dim if you've set it too low while you're trying to decide what to drag in or out of it.

Those two reasons, and of course more use-testing, would be my main reasons to hold off for a bit before adding this to core.

@cmsj, since we're hoping to be able to figure out how to maybe add an item like the example you give in #1096, and I'd like to be able to create a full Hammerspoon touch bar for use when the Hammerspoon application is focused, what do you think I should name this when it's added? "hs.touchbar"? "hs.touchbar.viewer"? Other ideas?

@latenitefilms
Copy link
Contributor Author

@asmagill - Awesome! Thanks so much! I'll test out this latest version tonight!

I also agree it would be great to add a proper Hammerspoon Touchbar. I think hs.touchbar makes sense to control Hammerspoon's native Touchbar. Maybe hs._asm.touchbar should be renamed to hs.onscreenTouchbar?

@latenitefilms
Copy link
Contributor Author

@asmagill - FYI: I just downloaded touchbar-v0.5.tar.gz, however when I try touchbar:movable() it gives me a "attempt to call a nil value (method 'movable')" error.

@asmagill
Copy link
Member

Have you fully quit and restarted Hammerspoon? Whenever the objective-c portion of a module changes, it requires an actual quit and re-launch before the new version is loaded.

@latenitefilms
Copy link
Contributor Author

@asmagill - Opps! Sorry, rookie error, I didn't know that - restarting has fixed! Thank you!

@asmagill
Copy link
Member

It's caught us all... and it's a bit of a pain, really. It's because of the way Objective-C loads dynamic code... Objective-C intentionally "opens" a library twice so the traditional method of calling dlclose (which Lua does during a regular reload) won't remove it from memory... a while back I dug into it (see #101) and came up with http://stackoverflow.com/a/8793766 as the final reason we decided to just accept the annoyance.

@latenitefilms
Copy link
Contributor Author

@asmagill - No worries at all! I should have really tried restarting before posting anyway.

Loving the moveable (or movable as you call it!) Touch Bar! Very handy!

I'm currently using setCallback as a way to know when the Touch Bar has moved (so I can save it's last position in settings so it can be restored during a restart) - however, I don't really get what you mean by using acceptsMouseEvents as a way to prevent mouse clicks in the touch bar from triggering the touch bar buttons? Are you thinking that rather than making the Touch Bar ALWAYS draggable, it should be used with a shortcut key held down or something?

@latenitefilms
Copy link
Contributor Author

@asmagill - Never mind! I just realised you've also posted an example. Will check it out!

@asmagill
Copy link
Member

Normally when you click on the bar, the click is passed through and interpreted as if you had "touched" the touch bar... while technically movable is toggling the ability for a window to be moved by clicking in it's background, in truth what is being displayed is a video stream, so... there is no "background"... the mouse click is still getting passed through... try clicking on a button and holding it while dragging -- you'll see that not only does the window move, but the "button" gets toggled as well.

I also found that some of the buttons which appear after a long "touch" (in Terminal, for example, if you touch one of the buttons for an extended period, it will show up some additional buttons for Search Term Display) were unusable when movable was true because you couldn't move over to them without releasing the mouse button and "untouching" the touch bar... hence the additional method.

I guess I could have combined them and made movable automatically make the touch bar "view only" but... I don't like doubling up on things when its not strictly necessary because the touch bar is usable in the movable mode, just not fully, and I prefer having options (as long as they don't cause a crash, of course!)

If you look at my example code in the Examples folder, I pair movable and acceptsMouseEvents -- when one is set to true, the other to false, and vice-versa.... and yes, in my example (which is pretty close to the code I'm actually using daily right now), it's only movable when holding down the left Option (Alt) key.

I can look at the documentation again tomorrow (it's almost 2 AM here, so I'm off to la-la-land in a bit!) and see if it needs some clarification.

As to the spelling... I guess it's an American thing... my dictionary says both spellings are correct, but dropping the e is more common, at least here 😁

@latenitefilms
Copy link
Contributor Author

@asmagill - Legend, thanks so much! Go to bed!

@cmsj
Copy link
Member

cmsj commented Nov 24, 2016

@asmagill re your question about namespacing, what about something like this:

  • hs.touchbar.window submodule for your current code (I think "window" might be slightly more obvious than "viewer". Not 100%, happy to go with "viewer" if you prefer)
  • hs.touchbar main module that allows for the creation and management of an NSTouchBar and various NSTouchBarItems it will contain.
  • hs.touchbar.addSystemItem()/hs.touchbar.removeSystemItem() - functions that take an NSTouchBarItem created with the above APIs, and use whatever private API is responsible for doing this stuff.

There is quite a lot of API to cover with NSTouchBarItems, but I think we could cover a bunch of common ground pretty quickly - which is to say NSButtons that are either text or NSImage based. From there we can extend over time to cover things like the scrubbers, sliders, color pickers, etc. Apple has a pretty excellent example app which covers most of the different kinds of system controls.
https://developer.apple.com/library/content/samplecode/NSTouchBarCatalog/Introduction/Intro.html

@latenitefilms
Copy link
Contributor Author

@asmagill - Also, is there a good way of programatically organising the order of new buttons? I've tried using item:visibilityPriority([priority]), but it doesn't seem to do anything. I've also tried sorting the table, but that doesn't seem to work either (although quickanddirtyBarExample.lua seems to keep it's order fine, which is odd).

@latenitefilms
Copy link
Contributor Author

Actually, ignore my last comment, sorting customizableIdentifiers, requiredIdentifiers and defaultIdentifiers seemed to do the trick! I was originally just trying to sort templateItems.

@latenitefilms
Copy link
Contributor Author

FYI: It seems the Touch Bar really only likes images that are 36px × 36px, so I can just "force" it to that using :setSize({w=36,h=36}) - problem solved!

Related: https://developer.apple.com/macos/human-interface-guidelines/touch-bar/touch-bar-icons-and-images/

@latenitefilms
Copy link
Contributor Author

FYI: The Touch Bar REALLY doesn't like it when you feed it two identical hs._asm.undocumented.touchbar.item's.

*** ERROR: NSInternalInconsistencyException: Duplicate item identifier (windowSlide) found in touch bar (<HSASMTouchBar: 0x60400048e010 delegate='HSASMTouchBar:0x60400048e010' items='HSASMCustomTouchBarItem:windowSlide, HSASMCustomTouchBarItem:windowSlide'>)
(
	0   CoreFoundation                      0x00007fff28b450fb __exceptionPreprocess + 171
	1   libobjc.A.dylib                     0x00007fff4f437c76 objc_exception_throw + 48
	2   CoreFoundation                      0x00007fff28b4ae92 +[NSException raise:format:arguments:] + 98
	3   Foundation                          0x00007fff2ac23690 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
	4   AppKit                              0x00007fff2665726c -[_NSTouchBarItemTreeBuilder _expandBarChildren:inNode:centeredNode:] + 3301
	5   AppKit                              0x00007fff266564db __68-[_NSTouchBarItemTreeBuilder _expandResponderBarAtIndex:centerNode:]_block_invoke + 130
	6   AppKit                              0x00007fff266562ba -[_NSTouchBarItemTreeBuilder _performWithResponderBarIndex:usingBlock:] + 34
	7   AppKit                              0x00007fff26656415 -[_NSTouchBarItemTreeBuilder _expandResponderBarAtIndex:centerNode:] + 332
	8   AppKit                              0x00007fff26655f97 -[_NSTouchBarItemTreeBuilder itemTree] + 2315
	9   AppKit                              0x00007fff265e0e2e -[NSTouchBarViewController _updateTree] + 818
	10  AppKit                              0x00007fff26b79270 +[NSTouchBar(NSSystemModalTouchBar) presentSystemModalTouchBar:placement:systemTrayItemIdentifier:] + 617
	11  bar.so                              0x000000010dcf31c4 touchbar_presentSystemModalFunctionBar + 420
	12  LuaSkin                             0x0000000106f64930 luaD_precall + 695
	13  LuaSkin                             0x0000000106f62e55 luaV_execute + 7345
	14  LuaSkin                             0x0000000106f64a86 luaD_call + 64
	15  LuaSkin                             0x0000000106f64ac7 luaD_callnoyield + 21
	16  LuaSkin                             0x0000000106f6c6cb luai_objcttry + 28
	17  LuaSkin                             0x0000000106f64f95 luaD_pcall + 116
	18  LuaSkin                             0x0000000106f75598 lua_pcallk + 122
	19  LuaSkin                             0x0000000106f720fa luaB_xpcall + 115
	20  LuaSkin                             0x0000000106f64930 luaD_precall + 695
	21  LuaSkin                             0x0000000106f62e55 luaV_execute + 7345
	22  LuaSkin                             0x0000000106f64a86 luaD_call + 64
	23  LuaSkin                             0x0000000106f64ac7 luaD_callnoyield + 21
	24  LuaSkin                             0x0000000106f6c6cb luai_objcttry + 28
	25  LuaSkin                             0x0000000106f64f95 luaD_pcall + 116
	26  LuaSkin                             0x0000000106f75598 lua_pcallk + 122
	27  CommandPost                         0x0000000106cdb469 MJLuaInit + 1695
	28  CommandPost                         0x0000000106cd78e8 -[MJAppDelegate applicationDidFinishLaunching:] + 2908
	29  CoreFoundation                      0x00007fff28ad4b5c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
	30  CoreFoundation                      0x00007fff28ad4a4a _CFXRegistrationPost + 442
	31  CoreFoundation                      0x00007fff28ad4792 ___CFXNotificationPost_block_invoke + 50
	32  CoreFoundation                      0x00007fff28a92570 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1664
	33  CoreFoundation                      0x00007fff28a916a3 _CFXNotificationPost + 595
	34  Foundation                          0x00007fff2ab50477 -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
	35  AppKit                              0x00007fff2620eef2 -[NSApplication _postDidFinishNotification] + 313
	36  AppKit                              0x00007fff2620eb3b -[NSApplication _sendFinishLaunchingNotification] + 220
	37  AppKit                              0x00007fff260e1403 -[NSApplication(NSAppleEventHandling) _handleAEOpenEvent:] + 562
	38  AppKit                              0x00007fff260e1039 -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:] + 690
	39  Foundation                          0x00007fff2ab93be4 -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:] + 287
	40  Foundation                          0x00007fff2ab93a62 _NSAppleEventManagerGenericHandler + 102
	41  AE                                  0x00007fff29b82e20 _Z20aeDispatchAppleEventPK6AEDescPS_jPh + 1788
	42  AE                                  0x00007fff29b826c7 _ZL25dispatchEventAndSendReplyPK6AEDescPS_ + 41
	43  AE                                  0x00007fff29b825b5 aeProcessAppleEvent + 383
	44  HIToolbox                           0x00007fff27dedf60 AEProcessAppleEvent + 55
	45  AppKit                              0x00007fff260dc70e _DPSNextEvent + 2788
	46  AppKit                              0x00007fff26871508 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 3044
	47  AppKit                              0x00007fff260d125d -[NSApplication run] + 764
	48  AppKit                              0x00007fff260a03fe NSApplicationMain + 804
	49  libdyld.dylib                       0x00007fff50026145 start + 1
	50  ???                                 0x0000000000000001 0x0 + 1
)

@asmagill
Copy link
Member

asmagill commented Oct 3, 2017

If it wasn't made clear in the documentation (such as it is), duplicate identifiers are not allowed. Of course a better error should be returned, but this isn't a surprise.

@latenitefilms
Copy link
Contributor Author

I just did it by accident - and it crashed Hammerspoon, so it would be good to just display a nice error message instead.

It's awesome by the way - really LOVING this extension!

@latenitefilms
Copy link
Contributor Author

It would also be good to be able to specify a width for a item.newSlider.

@asmagill
Copy link
Member

asmagill commented Oct 3, 2017

You're talking about it's horizontal width, correct? As I recall, I was having problems making that work -- it wants to expand to fit the available space based on the number of other elements... but I'll look into it again because it seems an obvious thing developers might want.

The touchbar is the first visual component I've come across that requires you to use constraint based layout features... it's optional everywhere else and so far I've found it easier most of the time to avoid them. A future extension to the guitk manager may allow using constraint based layout for guitk, but my initial attempt made things much more confusing and didn't quite work as expected, so I backed off of it for now. For touchbar I don't think that will be an option.

@asmagill
Copy link
Member

asmagill commented Oct 3, 2017

(ok, width is horizontal, I guess I meant physical width, as in display width)

@latenitefilms
Copy link
Contributor Author

@asmagill - Ok, so this is a long shot... Is it possible to "steal" elements from an existing Touch Bar and "insert" them into Hammerspoon's modal touch bar? For example, QuickTime Player in Sierra has an awesome timeline/thumbnail navigator. Would it be possible to "steal" this Touch Bar element and insert it into a Hammerspoon modal Touch Bar when QuickTime Player is open, so that you can also add custom buttons next to it? Basically the reason being - I'd like to add custom buttons to applications - but I don't want to loose native functionality that's built into macOS's applications. Thoughts?

@latenitefilms
Copy link
Contributor Author

@asmagill - I have "App Controls with Control Strip" selected in the Keyboard System Preferences, and have an icon in the control strip which enables my custom Touch Bar. It works great. However, sometimes when I press the X button on the far left of the Touch Bar, it will close my bar, but it won't restore the Touch Bar of whatever application I'm running. The only way I can get the applications "native" Touch Bar back is to restart Hammerspoon. Any ideas?

@latenitefilms
Copy link
Contributor Author

@asmagill FYI:

# Device: MacBook Pro Retina, 13", Late 2016, Four Thunderbolt 3 ports
# RAM Free: < 1%
# Disk Free: 3.8%

#12. Crashed: com.apple.touchbar.agent
0  libobjc.A.dylib                0x7fff8d9b405d objc_msgSend + 29
1  CoreFoundation                 0x7fff78b01788 -[__NSCFString isEqualToString:] + 56
2  DFRFoundation                  0x7fff84b3c00a __DFRElementSetControlStripPresenceForIdentifier_block_invoke + 245
3  libdispatch.dylib              0x7fff8e27a524 _dispatch_call_block_and_release + 12
4  libdispatch.dylib              0x7fff8e2718fc _dispatch_client_callout + 8
5  libdispatch.dylib              0x7fff8e2879a0 _dispatch_queue_serial_drain + 896
6  libdispatch.dylib              0x7fff8e27a306 _dispatch_queue_invoke + 1046
7  libdispatch.dylib              0x7fff8e2736b5 _dispatch_root_queue_drain + 476
8  libdispatch.dylib              0x7fff8e27348c _dispatch_worker_thread3 + 99
9  libsystem_pthread.dylib        0x7fff8e4c05a2 _pthread_wqthread + 1299
10 libsystem_pthread.dylib        0x7fff8e4c007d start_wqthread + 13

--

#0. com.apple.main-thread
0  libobjc.A.dylib                0x7fff8d9ba450 class_conformsToProtocol + 156
1  libobjc.A.dylib                0x7fff8d9ba3a1 -[NSObject conformsToProtocol:] + 52
2  AppKit                         0x7fff766ae1a3 -[NSView inputContext] + 171
3  AppKit                         0x7fff76609362 -[NSView _setWindow:] + 1041
4  AppKit                         0x7fff76899b64 -[NSWindow dealloc] + 1225
5  AppKit                         0x7fff7663ae87 -[NSWindow release] + 162
6  internal.so                    0x10a238a3c userdata_gc (internal.m:3895)
7  LuaSkin                        0x10354d930 luaD_precall (ldo.c:454)
8  LuaSkin                        0x10354da7a luaD_call (ldo.c:515)
9  LuaSkin                        0x10354dac7 luaD_callnoyield (ldo.c:527)
10 LuaSkin                        0x1035556cb luai_objcttry (lobjectivec_exceptions.m:173)
11 LuaSkin                        0x10354df95 luaD_pcall (ldo.c:162)
12 LuaSkin                        0x1035599f3 GCTM (lgc.c:823)
13 LuaSkin                        0x103559009 luaC_freeallobjects (lgc.c:860)
14 LuaSkin                        0x1035501c6 close_state (lstate.c:248)
15 LuaSkin                        0x1035422d4 -[LuaSkin destroyLuaState] (Skin.m:179)
16 CommandPost                    0x1032c0b2a -[MJAppDelegate applicationShouldTerminate:] (MJAppDelegate.m:288)
17 AppKit                         0x7fff76829be2 -[NSApplication _docController:shouldTerminate:] + 71
18 AppKit                         0x7fff76829a96 __91-[NSDocumentController(NSInternal) _closeAllDocumentsWithDelegate:shouldTerminateSelector:]_block_invoke + 567
19 AppKit                         0x7fff768296b5 -[NSDocumentController(NSInternal) _closeAllDocumentsWithDelegate:shouldTerminateSelector:] + 1318
20 AppKit                         0x7fff76829168 -[NSDocumentController(NSInternal) __closeAllDocumentsWithDelegate:shouldTerminateSelector:] + 307
21 AppKit                         0x7fff76828db9 -[NSApplication _shouldTerminate] + 843
22 AppKit                         0x7fff76828453 -[NSApplication terminate:] + 780
23 Sparkle                        0x1034d9b6e -[SUUIBasedUpdateDriver terminateApp] (SUUIBasedUpdateDriver.m:294)
24 Sparkle                        0x1034c1c72 -[SUBasicUpdateDriver installWithToolAndRelaunch:displayingUserInterface:] (SUBasicUpdateDriver.m:590)
25 Sparkle                        0x1034d9ac6 -[SUUIBasedUpdateDriver installWithToolAndRelaunch:] (SUUIBasedUpdateDriver.m:279)
26 libsystem_trace.dylib          0x7fff8e4d93a7 _os_activity_initiate_impl + 53
27 AppKit                         0x7fff76da5721 -[NSApplication(NSResponder) sendAction:to:from:] + 456
28 AppKit                         0x7fff76889cc4 -[NSControl sendAction:to:] + 86
29 AppKit                         0x7fff76889bec __26-[NSCell _sendActionFrom:]_block_invoke + 136
30 libsystem_trace.dylib          0x7fff8e4d93a7 _os_activity_initiate_impl + 53
31 AppKit                         0x7fff76889b44 -[NSCell _sendActionFrom:] + 128
32 AppKit                         0x7fff768cc539 -[NSButtonCell _sendActionFrom:] + 98
33 libsystem_trace.dylib          0x7fff8e4d93a7 _os_activity_initiate_impl + 53
34 AppKit                         0x7fff768e6f46 -[NSButtonCell performClick:] + 690
35 AppKit                         0x7fff768e6c4c __33-[NSButton performKeyEquivalent:]_block_invoke + 85
36 libsystem_trace.dylib          0x7fff8e4d93a7 _os_activity_initiate_impl + 53
37 AppKit                         0x7fff768768fa -[NSButton performKeyEquivalent:] + 356
38 AppKit                         0x7fff7687654e -[NSView _performKeyEquivalent:conditionally:] + 227
39 AppKit                         0x7fff7687677b -[NSControl _performKeyEquivalent:conditionally:] + 136
40 AppKit                         0x7fff7687664c -[NSView performKeyEquivalent:] + 234
41 AppKit                         0x7fff7687654e -[NSView _performKeyEquivalent:conditionally:] + 227
42 AppKit                         0x7fff7687664c -[NSView performKeyEquivalent:] + 234
43 AppKit                         0x7fff7687654e -[NSView _performKeyEquivalent:conditionally:] + 227
44 AppKit                         0x7fff76ec7ea2 -[NSWindow _commonPerformKeyEquivalent:conditionally:] + 79
45 AppKit                         0x7fff768bf81e -[NSWindow keyDown:] + 30
46 AppKit                         0x7fff76f1e2cc -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 4086
47 AppKit                         0x7fff76f1cf0a -[NSWindow(NSEventRouting) sendEvent:] + 541
48 AppKit                         0x7fff76da24a8 -[NSApplication(NSEvent) sendEvent:] + 4768
49 AppKit                         0x7fff7661c427 -[NSApplication run] + 1002
50 AppKit                         0x7fff765e6e0e NSApplicationMain + 1237
51 libdyld.dylib                  0x7fff8e2a7235 start + 1

#1. com.twitter.crashlytics.mac.MachExceptionServer
0  CommandPost                    0x103342781 CLSProcessRecordAllThreads
1  CommandPost                    0x10334261e CLSProcessRecordAllThreads
2  CommandPost                    0x1033322c9 CLSHandler
3  CommandPost                    0x10332d3bd CLSMachExceptionServer
4  libsystem_pthread.dylib        0x7fff8e4c093b _pthread_body + 180
5  libsystem_pthread.dylib        0x7fff8e4c0887 _pthread_start + 284
6  libsystem_pthread.dylib        0x7fff8e4c008d thread_start + 13

#2. com.apple.NSURLConnectionLoader
0  libsystem_kernel.dylib         0x7fff8e3ce34a mach_msg_trap + 10
1  libsystem_kernel.dylib         0x7fff8e3cd797 mach_msg + 55
2  CoreFoundation                 0x7fff78b2e434 __CFRunLoopServiceMachPort + 212
3  CoreFoundation                 0x7fff78b2d8c1 __CFRunLoopRun + 1361
4  CoreFoundation                 0x7fff78b2d114 CFRunLoopRunSpecific + 420
5  CFNetwork                      0x7fff77c6b734 +[NSURLConnection(Loader) _resourceLoadLoop:] + 313
6  Foundation                     0x7fff7a550b3d __NSThread__start__ + 1243
7  libsystem_pthread.dylib        0x7fff8e4c093b _pthread_body + 180
8  libsystem_pthread.dylib        0x7fff8e4c0887 _pthread_start + 284
9  libsystem_pthread.dylib        0x7fff8e4c008d thread_start + 13

#3. com.apple.NSEventThread
0  libsystem_kernel.dylib         0x7fff8e3ce34a mach_msg_trap + 10
1  libsystem_kernel.dylib         0x7fff8e3cd797 mach_msg + 55
2  CoreFoundation                 0x7fff78b2e434 __CFRunLoopServiceMachPort + 212
3  CoreFoundation                 0x7fff78b2d8c1 __CFRunLoopRun + 1361
4  CoreFoundation                 0x7fff78b2d114 CFRunLoopRunSpecific + 420
5  AppKit                         0x7fff76774f02 _NSEventThread + 205
6  libsystem_pthread.dylib        0x7fff8e4c093b _pthread_body + 180
7  libsystem_pthread.dylib        0x7fff8e4c0887 _pthread_start + 284
8  libsystem_pthread.dylib        0x7fff8e4c008d thread_start + 13

#4. Thread
0  libsystem_kernel.dylib         0x7fff8e3d5bf2 __psynch_cvwait + 10
1  libsystem_pthread.dylib        0x7fff8e4c17fa _pthread_cond_wait + 712
2  libc++.1.dylib                 0x7fff8ce404cd std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 47
3  JavaScriptCore                 0x7fff7bb3954c void std::__1::condition_variable_any::wait<std::__1::unique_lock<bmalloc::Mutex> >(std::__1::unique_lock<bmalloc::Mutex>&) + 108
4  JavaScriptCore                 0x7fff7bb394cb bmalloc::AsyncTask<bmalloc::Heap, void (bmalloc::Heap::*)()>::threadRunLoop() + 155
5  JavaScriptCore                 0x7fff7bb3939d bmalloc::AsyncTask<bmalloc::Heap, void (bmalloc::Heap::*)()>::threadEntryPoint(bmalloc::AsyncTask<bmalloc::Heap, void (bmalloc::Heap::*)()>*) + 29
6  JavaScriptCore                 0x7fff7bb3964d void* std::__1::__thread_proxy<std::__1::tuple<void (*)(bmalloc::AsyncTask<bmalloc::Heap, void (bmalloc::Heap::*)()>*), bmalloc::AsyncTask<bmalloc::Heap, void (bmalloc::Heap::*)()>*> >(void*) + 93
7  libsystem_pthread.dylib        0x7fff8e4c093b _pthread_body + 180
8  libsystem_pthread.dylib        0x7fff8e4c0887 _pthread_start + 284
9  libsystem_pthread.dylib        0x7fff8e4c008d thread_start + 13

#5. com.apple.coreanimation.render-server
0  libsystem_kernel.dylib         0x7fff8e3ce34a mach_msg_trap + 10
1  libsystem_kernel.dylib         0x7fff8e3cd797 mach_msg + 55
2  QuartzCore                     0x7fff7e70ebf0 CA::Render::Server::server_thread(void*) + 272
3  QuartzCore                     0x7fff7e7bf3af thread_fun + 25
4  libsystem_pthread.dylib        0x7fff8e4c093b _pthread_body + 180
5  libsystem_pthread.dylib        0x7fff8e4c0887 _pthread_start + 284
6  libsystem_pthread.dylib        0x7fff8e4c008d thread_start + 13

#6. Thread
0  libsystem_kernel.dylib         0x7fff8e3d644e __workq_kernreturn + 10
1  libsystem_pthread.dylib        0x7fff8e4c0621 _pthread_wqthread + 1426
2  libsystem_pthread.dylib        0x7fff8e4c007d start_wqthread + 13

#7. Thread
0  libsystem_kernel.dylib         0x7fff8e3d644e __workq_kernreturn + 10
1  libsystem_pthread.dylib        0x7fff8e4c048e _pthread_wqthread + 1023
2  libsystem_pthread.dylib        0x7fff8e4c007d start_wqthread + 13
3  forcetouch.so                  0x700005b5eb80 (Missing)

#8. Thread
0  libsystem_kernel.dylib         0x7fff8e3d644e __workq_kernreturn + 10
1  libsystem_pthread.dylib        0x7fff8e4c048e _pthread_wqthread + 1023
2  libsystem_pthread.dylib        0x7fff8e4c007d start_wqthread + 13
3  forcetouch.so                  0x6e656b6f74 (Missing)

#9. com.apple.appkit-heartbeat
0  libsystem_kernel.dylib         0x7fff8e3d5f46 __semwait_signal + 10
1  libsystem_c.dylib              0x7fff8e35cb72 nanosleep + 199
2  libsystem_c.dylib              0x7fff8e35ca66 usleep + 54
3  AppKit                         0x7fff768f1af6 -[NSUIHeartBeat _heartBeatThread:] + 2696
4  Foundation                     0x7fff7a550b3d __NSThread__start__ + 1243
5  libsystem_pthread.dylib        0x7fff8e4c093b _pthread_body + 180
6  libsystem_pthread.dylib        0x7fff8e4c0887 _pthread_start + 284
7  libsystem_pthread.dylib        0x7fff8e4c008d thread_start + 13

#10. Thread
0  libsystem_kernel.dylib         0x7fff8e3d644e __workq_kernreturn + 10
1  libsystem_pthread.dylib        0x7fff8e4c0621 _pthread_wqthread + 1426
2  libsystem_pthread.dylib        0x7fff8e4c007d start_wqthread + 13

#11. Thread
0  libsystem_kernel.dylib         0x7fff8e3d644e __workq_kernreturn + 10
1  libsystem_pthread.dylib        0x7fff8e4c0621 _pthread_wqthread + 1426
2  libsystem_pthread.dylib        0x7fff8e4c007d start_wqthread + 13

#12. Crashed: com.apple.touchbar.agent
0  libobjc.A.dylib                0x7fff8d9b405d objc_msgSend + 29
1  CoreFoundation                 0x7fff78b01788 -[__NSCFString isEqualToString:] + 56
2  DFRFoundation                  0x7fff84b3c00a __DFRElementSetControlStripPresenceForIdentifier_block_invoke + 245
3  libdispatch.dylib              0x7fff8e27a524 _dispatch_call_block_and_release + 12
4  libdispatch.dylib              0x7fff8e2718fc _dispatch_client_callout + 8
5  libdispatch.dylib              0x7fff8e2879a0 _dispatch_queue_serial_drain + 896
6  libdispatch.dylib              0x7fff8e27a306 _dispatch_queue_invoke + 1046
7  libdispatch.dylib              0x7fff8e2736b5 _dispatch_root_queue_drain + 476
8  libdispatch.dylib              0x7fff8e27348c _dispatch_worker_thread3 + 99
9  libsystem_pthread.dylib        0x7fff8e4c05a2 _pthread_wqthread + 1299
10 libsystem_pthread.dylib        0x7fff8e4c007d start_wqthread + 13

@latenitefilms latenitefilms mentioned this issue Dec 25, 2017
19 tasks
@latenitefilms
Copy link
Contributor Author

@asmagill The documentation says:

If you do not have "Touch Bar Shows" set to "App Controls With Control Strip" set in the Keyboard System Preferences, the modal bar will only be displayed when the Hammerspoon application is the frontmost application.

However, it looks like BetterTouchTool can now take over the entire Touch Bar, hiding the Control Strip for specific applications. Is this something that could be added to your Touch Bar module?

screen shot 2018-01-21 at 7 19 43 pm

@latenitefilms
Copy link
Contributor Author

@asmagill - Another crash, maybe related to this extension?

# Application: CommandPost
# Version: 1.0.0-beta.20
# Bundle Identifier: org.latenitefilms.CommandPost
# Issue #: 46
# Issue ID: 59eddfd761b02d480d0ee9c0
# Session ID: 717ef264783147c9a6ebd94a1dd7415d_DNE_0_v2
# Date: 2018-01-29T09:50:00Z
# OS Version: 10.12.6 (16G1212)
# Device: iMac 17,1
# RAM Free: 72.6%
# Disk Free: 85.2%

#2. Crashed: com.apple.touchbar.agent
0  libobjc.A.dylib                0x7fffc24c105d objc_msgSend + 29
1  CoreFoundation                 0x7fffad601788 -[__NSCFString isEqualToString:] + 56
2  DFRFoundation                  0x7fffb963c00a __DFRElementSetControlStripPresenceForIdentifier_block_invoke + 245
3  libdispatch.dylib              0x7fffc2d88524 _dispatch_call_block_and_release + 12
4  libdispatch.dylib              0x7fffc2d7f8fc _dispatch_client_callout + 8
5  libdispatch.dylib              0x7fffc2d959a0 _dispatch_queue_serial_drain + 896
6  libdispatch.dylib              0x7fffc2d88306 _dispatch_queue_invoke + 1046
7  libdispatch.dylib              0x7fffc2d816b5 _dispatch_root_queue_drain + 476
8  libdispatch.dylib              0x7fffc2d8148c _dispatch_worker_thread3 + 99
9  libsystem_pthread.dylib        0x7fffc2fce5a2 _pthread_wqthread + 1299
10 libsystem_pthread.dylib        0x7fffc2fce07d start_wqthread + 13

--

#0. com.apple.main-thread
0  libobjc.A.dylib                0x7fffc24c0fcc cache_getImp + 28
1  libobjc.A.dylib                0x7fffc24c20d8 lookUpImpOrForward + 365
2  libobjc.A.dylib                0x7fffc24c1ad4 _objc_msgSend_uncached + 68
3  AppKit                         0x7fffab19560d -[NSView(NSConstraintBasedLayout) removeConstraints:] + 277
4  AppKit                         0x7fffab10bbce -[NSView(NSConstraintBasedLayout) _constraints_snipDangliesWithForce:] + 596
5  AppKit                         0x7fffab1059ce -[NSView _setSuperview:] + 1077
6  AppKit                         0x7fffab10b575 -[NSView removeFromSuperview] + 447
7  internal.so                    0x11336293e userdata_gc (internal.m:3884)
8  LuaSkin                        0x10c0b6920 luaD_precall (ldo.c:454)
9  LuaSkin                        0x10c0b6a6a luaD_call (ldo.c:515)
10 LuaSkin                        0x10c0b6ab7 luaD_callnoyield (ldo.c:527)
11 LuaSkin                        0x10c0be6bb luai_objcttry (lobjectivec_exceptions.m:173)
12 LuaSkin                        0x10c0b6f85 luaD_pcall (ldo.c:162)
13 LuaSkin                        0x10c0c29e3 GCTM (lgc.c:823)
14 LuaSkin                        0x10c0c1ff9 luaC_freeallobjects (lgc.c:860)
15 LuaSkin                        0x10c0b91b6 close_state (lstate.c:248)
16 LuaSkin                        0x10c0ab2c4 -[LuaSkin destroyLuaState] (Skin.m:179)
17 CommandPost                    0x10b5ed68a -[MJAppDelegate applicationShouldTerminate:] (MJAppDelegate.m:288)
18 AppKit                         0x7fffab328be2 -[NSApplication _docController:shouldTerminate:] + 71
19 AppKit                         0x7fffab328a96 __91-[NSDocumentController(NSInternal) _closeAllDocumentsWithDelegate:shouldTerminateSelector:]_block_invoke + 567
20 AppKit                         0x7fffab3286b5 -[NSDocumentController(NSInternal) _closeAllDocumentsWithDelegate:shouldTerminateSelector:] + 1318
21 AppKit                         0x7fffab328168 -[NSDocumentController(NSInternal) __closeAllDocumentsWithDelegate:shouldTerminateSelector:] + 307
22 AppKit                         0x7fffab327db9 -[NSApplication _shouldTerminate] + 843
23 AppKit                         0x7fffab520056 -[NSApplication(NSAppleEventHandling) _handleAEQuit] + 325
24 AppKit                         0x7fffab567d7c -[NSApplication(NSScripting) handleQuitScriptCommand:] + 22
25 CoreFoundation                 0x7fffad62ab8c __invoking___ + 140
26 CoreFoundation                 0x7fffad62aa11 -[NSInvocation invoke] + 289
27 CoreFoundation                 0x7fffad644196 -[NSInvocation invokeWithTarget:] + 54
28 Foundation                     0x7fffaf1f3014 -[NSScriptCommand _sendToRemainingReceivers] + 667
29 Foundation                     0x7fffaf1f3374 -[NSScriptCommand executeCommand] + 512
30 Foundation                     0x7fffaf20e134 -[NSScriptingAppleEventHandler handleCommandEvent:withReplyEvent:] + 195
31 Foundation                     0x7fffaf06fafd -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:] + 290
32 Foundation                     0x7fffaf06f977 _NSAppleEventManagerGenericHandler + 102
33 AE                             0x7fffae473f26 aeDispatchAppleEvent(AEDesc const*, AEDesc*, unsigned int, unsigned char*) + 544
34 AE                             0x7fffae473c9d dispatchEventAndSendReply(AEDesc const*, AEDesc*) + 39
35 AE                             0x7fffae473ba9 aeProcessAppleEvent + 312
36 HIToolbox                      0x7fffacb9eddf AEProcessAppleEvent + 55
37 AppKit                         0x7fffab126d1d _DPSNextEvent + 1833
38 AppKit                         0x7fffab8a27ee -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 2796
39 AppKit                         0x7fffab11b3db -[NSApplication run] + 926
40 AppKit                         0x7fffab0e5e0e NSApplicationMain + 1237
41 libdyld.dylib                  0x10c104235 start + 1

#1. Thread
0  libsystem_kernel.dylib         0x10c12e44e __workq_kernreturn + 10
1  libsystem_pthread.dylib        0x7fffc2fce621 _pthread_wqthread + 1426
2  libsystem_pthread.dylib        0x7fffc2fce07d start_wqthread + 13

#2. Crashed: com.apple.touchbar.agent
0  libobjc.A.dylib                0x7fffc24c105d objc_msgSend + 29
1  CoreFoundation                 0x7fffad601788 -[__NSCFString isEqualToString:] + 56
2  DFRFoundation                  0x7fffb963c00a __DFRElementSetControlStripPresenceForIdentifier_block_invoke + 245
3  libdispatch.dylib              0x7fffc2d88524 _dispatch_call_block_and_release + 12
4  libdispatch.dylib              0x7fffc2d7f8fc _dispatch_client_callout + 8
5  libdispatch.dylib              0x7fffc2d959a0 _dispatch_queue_serial_drain + 896
6  libdispatch.dylib              0x7fffc2d88306 _dispatch_queue_invoke + 1046
7  libdispatch.dylib              0x7fffc2d816b5 _dispatch_root_queue_drain + 476
8  libdispatch.dylib              0x7fffc2d8148c _dispatch_worker_thread3 + 99
9  libsystem_pthread.dylib        0x7fffc2fce5a2 _pthread_wqthread + 1299
10 libsystem_pthread.dylib        0x7fffc2fce07d start_wqthread + 13

#3. Thread
0  libsystem_kernel.dylib         0x10c12e44e __workq_kernreturn + 10
1  libsystem_pthread.dylib        0x7fffc2fce48e _pthread_wqthread + 1023
2  libsystem_pthread.dylib        0x7fffc2fce07d start_wqthread + 13

#4. Thread
0  libsystem_kernel.dylib         0x10c12e44e __workq_kernreturn + 10
1  libsystem_pthread.dylib        0x7fffc2fce621 _pthread_wqthread + 1426
2  libsystem_pthread.dylib        0x7fffc2fce07d start_wqthread + 13

#5. Thread
0  libsystem_kernel.dylib         0x10c12e44e __workq_kernreturn + 10
1  libsystem_pthread.dylib        0x7fffc2fce621 _pthread_wqthread + 1426
2  libsystem_pthread.dylib        0x7fffc2fce07d start_wqthread + 13

#6. Thread
0  libsystem_kernel.dylib         0x10c12e44e __workq_kernreturn + 10
1  libsystem_pthread.dylib        0x7fffc2fce621 _pthread_wqthread + 1426
2  libsystem_pthread.dylib        0x7fffc2fce07d start_wqthread + 13

#7. Thread
0  libsystem_kernel.dylib         0x10c12e44e __workq_kernreturn + 10
1  libsystem_pthread.dylib        0x7fffc2fce621 _pthread_wqthread + 1426
2  libsystem_pthread.dylib        0x7fffc2fce07d start_wqthread + 13

#8. com.twitter.crashlytics.mac.MachExceptionServer
0  CommandPost                    0x10b6ab0e1 CLSProcessRecordAllThreads + 1449
1  CommandPost                    0x10b6aaf7e CLSProcessRecordAllThreads + 1094
2  CommandPost                    0x10b69a875 CLSHandler + 45
3  CommandPost                    0x10b695969 CLSMachExceptionServer + 546
4  libsystem_pthread.dylib        0x7fffc2fce93b _pthread_body + 180
5  libsystem_pthread.dylib        0x7fffc2fce887 _pthread_start + 284
6  libsystem_pthread.dylib        0x7fffc2fce08d thread_start + 13

#9. com.apple.NSURLConnectionLoader
0  libsystem_kernel.dylib         0x10c12634a mach_msg_trap + 10
1  libsystem_kernel.dylib         0x10c125797 mach_msg + 55
2  CoreFoundation                 0x7fffad62e434 __CFRunLoopServiceMachPort + 212
3  CoreFoundation                 0x7fffad62d8c1 __CFRunLoopRun + 1361
4  CoreFoundation                 0x7fffad62d114 CFRunLoopRunSpecific + 420
5  CFNetwork                      0x10b8bd344 +[NSURLConnection(Loader) _resourceLoadLoop:] + 313
6  Foundation                     0x7fffaf0508ad __NSThread__start__ + 1243
7  libsystem_pthread.dylib        0x7fffc2fce93b _pthread_body + 180
8  libsystem_pthread.dylib        0x7fffc2fce887 _pthread_start + 284
9  libsystem_pthread.dylib        0x7fffc2fce08d thread_start + 13

#10. Thread
0  libsystem_kernel.dylib         0x10c12e44e __workq_kernreturn + 10
1  libsystem_pthread.dylib        0x7fffc2fce621 _pthread_wqthread + 1426
2  libsystem_pthread.dylib        0x7fffc2fce07d start_wqthread + 13

#11. Thread
0  libsystem_kernel.dylib         0x10c12e44e __workq_kernreturn + 10
1  libsystem_pthread.dylib        0x7fffc2fce621 _pthread_wqthread + 1426
2  libsystem_pthread.dylib        0x7fffc2fce07d start_wqthread + 13

#12. com.apple.NSEventThread
0  libsystem_kernel.dylib         0x10c12634a mach_msg_trap + 10
1  libsystem_kernel.dylib         0x10c125797 mach_msg + 55
2  CoreFoundation                 0x7fffad62e434 __CFRunLoopServiceMachPort + 212
3  CoreFoundation                 0x7fffad62d8c1 __CFRunLoopRun + 1361
4  CoreFoundation                 0x7fffad62d114 CFRunLoopRunSpecific + 420
5  AppKit                         0x7fffab273f02 _NSEventThread + 205
6  libsystem_pthread.dylib        0x7fffc2fce93b _pthread_body + 180
7  libsystem_pthread.dylib        0x7fffc2fce887 _pthread_start + 284
8  libsystem_pthread.dylib        0x7fffc2fce08d thread_start + 13

#13. Thread
0  libsystem_kernel.dylib         0x10c12df46 __semwait_signal + 10
1  libsystem_c.dylib              0x7fffc2e6ab72 nanosleep + 199
2  libc++.1.dylib                 0x7fffc198e65b std::__1::this_thread::sleep_for(std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > const&) + 80
3  JavaScriptCore                 0x7fffb063b12f void std::__1::this_thread::sleep_for<long long, std::__1::ratio<1l, 1000l> >(std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000l> > const&) + 63
4  JavaScriptCore                 0x7fffb063a011 bmalloc::waitUntilFalse(std::__1::unique_lock<bmalloc::StaticMutex>&, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000l> >, bool&) + 113
5  JavaScriptCore                 0x7fffb0639e60 bmalloc::Heap::scavenge(std::__1::unique_lock<bmalloc::StaticMutex>&, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000l> >) + 48
6  JavaScriptCore                 0x7fffb0639cf6 bmalloc::Heap::concurrentScavenge() + 102
7  JavaScriptCore                 0x7fffb063b381 bmalloc::AsyncTask<bmalloc::Heap, void (bmalloc::Heap::*)()>::threadRunLoop() + 97
8  JavaScriptCore                 0x7fffb063b28d bmalloc::AsyncTask<bmalloc::Heap, void (bmalloc::Heap::*)()>::threadEntryPoint(bmalloc::AsyncTask<bmalloc::Heap, void (bmalloc::Heap::*)()>*) + 29
9  JavaScriptCore                 0x7fffb063b53d void* std::__1::__thread_proxy<std::__1::tuple<void (*)(bmalloc::AsyncTask<bmalloc::Heap, void (bmalloc::Heap::*)()>*), bmalloc::AsyncTask<bmalloc::Heap, void (bmalloc::Heap::*)()>*> >(void*) + 93
10 libsystem_pthread.dylib        0x7fffc2fce93b _pthread_body + 180
11 libsystem_pthread.dylib        0x7fffc2fce887 _pthread_start + 284
12 libsystem_pthread.dylib        0x7fffc2fce08d thread_start + 13

#14. com.apple.coreanimation.render-server
0  libsystem_kernel.dylib         0x10c12634a mach_msg_trap + 10
1  libsystem_kernel.dylib         0x10c125797 mach_msg + 55
2  QuartzCore                     0x7fffb3211bc4 CA::Render::Server::server_thread(void*) + 272
3  QuartzCore                     0x7fffb32c239b thread_fun + 25
4  libsystem_pthread.dylib        0x7fffc2fce93b _pthread_body + 180
5  libsystem_pthread.dylib        0x7fffc2fce887 _pthread_start + 284
6  libsystem_pthread.dylib        0x7fffc2fce08d thread_start + 13

#15. Thread
0  libsystem_kernel.dylib         0x10c12634a mach_msg_trap + 10
1  libsystem_kernel.dylib         0x10c125797 mach_msg + 55
2  CoreMIDI                       0x10bfc49c1 XServerMachPort::ReceiveMessage(int&, void*, int&) + 107
3  CoreMIDI                       0x10bfdaba9 MIDIProcess::RunMIDIInThread() + 105
4  CoreMIDI                       0x10bfe7a9a XThread::RunHelper(void*) + 10
5  CoreMIDI                       0x10bfeb053 CAPThread::Entry(CAPThread*) + 85
6  libsystem_pthread.dylib        0x7fffc2fce93b _pthread_body + 180
7  libsystem_pthread.dylib        0x7fffc2fce887 _pthread_start + 284
8  libsystem_pthread.dylib        0x7fffc2fce08d thread_start + 13

#16. Thread
0  libsystem_kernel.dylib         0x10c12639e semaphore_timedwait_trap + 10
1  libdispatch.dylib              0x7fffc2d97b09 _os_semaphore_timedwait + 72
2  libdispatch.dylib              0x7fffc2d88864 _dispatch_semaphore_wait_slow + 58
3  libdispatch.dylib              0x7fffc2d83290 _dispatch_worker_thread + 275
4  libsystem_pthread.dylib        0x7fffc2fce93b _pthread_body + 180
5  libsystem_pthread.dylib        0x7fffc2fce887 _pthread_start + 284
6  libsystem_pthread.dylib        0x7fffc2fce08d thread_start + 13

#17. WTF::AutomaticThread
0  libsystem_kernel.dylib         0x10c12dbf2 __psynch_cvwait + 10
1  libsystem_pthread.dylib        0x7fffc2fcf7fa _pthread_cond_wait + 712
2  JavaScriptCore                 0x7fffafad2fa7 WTF::ThreadCondition::timedWait(WTF::Mutex&, double) + 119
3  JavaScriptCore                 0x7fffb0622a22 WTF::ParkingLot::parkConditionallyImpl(void const*, WTF::ScopedLambda<bool ()> const&, WTF::ScopedLambda<void ()> const&, WTF::TimeWithDynamicClockType const&) + 2706
4  JavaScriptCore                 0x7fffb016fa16 bool WTF::ConditionBase::waitUntil<WTF::Lock>(WTF::Lock&, WTF::TimeWithDynamicClockType const&) + 150
5  JavaScriptCore                 0x7fffb0613587 std::__1::__function::__func<WTF::AutomaticThread::start(WTF::Locker<WTF::LockBase> const&)::$_0, std::__1::allocator<WTF::AutomaticThread::start(WTF::Locker<WTF::LockBase> const&)::$_0>, void ()>::operator()() + 199
6  JavaScriptCore                 0x7fffafacafd2 WTF::threadEntryPoint(void*) + 178
7  JavaScriptCore                 0x7fffafacaeff WTF::wtfThreadEntryPoint(void*) + 15
8  libsystem_pthread.dylib        0x7fffc2fce93b _pthread_body + 180
9  libsystem_pthread.dylib        0x7fffc2fce887 _pthread_start + 284
10 libsystem_pthread.dylib        0x7fffc2fce08d thread_start + 13

#18. WTF::AutomaticThread
0  libsystem_kernel.dylib         0x10c12dbf2 __psynch_cvwait + 10
1  libsystem_pthread.dylib        0x7fffc2fcf7fa _pthread_cond_wait + 712
2  JavaScriptCore                 0x7fffafad2fa7 WTF::ThreadCondition::timedWait(WTF::Mutex&, double) + 119
3  JavaScriptCore                 0x7fffb0622a22 WTF::ParkingLot::parkConditionallyImpl(void const*, WTF::ScopedLambda<bool ()> const&, WTF::ScopedLambda<void ()> const&, WTF::TimeWithDynamicClockType const&) + 2706
4  JavaScriptCore                 0x7fffb016fa16 bool WTF::ConditionBase::waitUntil<WTF::Lock>(WTF::Lock&, WTF::TimeWithDynamicClockType const&) + 150
5  JavaScriptCore                 0x7fffb0613587 std::__1::__function::__func<WTF::AutomaticThread::start(WTF::Locker<WTF::LockBase> const&)::$_0, std::__1::allocator<WTF::AutomaticThread::start(WTF::Locker<WTF::LockBase> const&)::$_0>, void ()>::operator()() + 199
6  JavaScriptCore                 0x7fffafacafd2 WTF::threadEntryPoint(void*) + 178
7  JavaScriptCore                 0x7fffafacaeff WTF::wtfThreadEntryPoint(void*) + 15
8  libsystem_pthread.dylib        0x7fffc2fce93b _pthread_body + 180
9  libsystem_pthread.dylib        0x7fffc2fce887 _pthread_start + 284
10 libsystem_pthread.dylib        0x7fffc2fce08d thread_start + 13

#19. WTF::AutomaticThread
0  libsystem_kernel.dylib         0x10c12dbf2 __psynch_cvwait + 10
1  libsystem_pthread.dylib        0x7fffc2fcf7fa _pthread_cond_wait + 712
2  JavaScriptCore                 0x7fffafad2fa7 WTF::ThreadCondition::timedWait(WTF::Mutex&, double) + 119
3  JavaScriptCore                 0x7fffb0622a22 WTF::ParkingLot::parkConditionallyImpl(void const*, WTF::ScopedLambda<bool ()> const&, WTF::ScopedLambda<void ()> const&, WTF::TimeWithDynamicClockType const&) + 2706
4  JavaScriptCore                 0x7fffb016fa16 bool WTF::ConditionBase::waitUntil<WTF::Lock>(WTF::Lock&, WTF::TimeWithDynamicClockType const&) + 150
5  JavaScriptCore                 0x7fffb0613587 std::__1::__function::__func<WTF::AutomaticThread::start(WTF::Locker<WTF::LockBase> const&)::$_0, std::__1::allocator<WTF::AutomaticThread::start(WTF::Locker<WTF::LockBase> const&)::$_0>, void ()>::operator()() + 199
6  JavaScriptCore                 0x7fffafacafd2 WTF::threadEntryPoint(void*) + 178
7  JavaScriptCore                 0x7fffafacaeff WTF::wtfThreadEntryPoint(void*) + 15
8  libsystem_pthread.dylib        0x7fffc2fce93b _pthread_body + 180
9  libsystem_pthread.dylib        0x7fffc2fce887 _pthread_start + 284
10 libsystem_pthread.dylib        0x7fffc2fce08d thread_start + 13

#20. WTF::AutomaticThread
0  libsystem_kernel.dylib         0x10c12dbf2 __psynch_cvwait + 10
1  libsystem_pthread.dylib        0x7fffc2fcf7fa _pthread_cond_wait + 712
2  JavaScriptCore                 0x7fffafad2fa7 WTF::ThreadCondition::timedWait(WTF::Mutex&, double) + 119
3  JavaScriptCore                 0x7fffb0622a22 WTF::ParkingLot::parkConditionallyImpl(void const*, WTF::ScopedLambda<bool ()> const&, WTF::ScopedLambda<void ()> const&, WTF::TimeWithDynamicClockType const&) + 2706
4  JavaScriptCore                 0x7fffb016fa16 bool WTF::ConditionBase::waitUntil<WTF::Lock>(WTF::Lock&, WTF::TimeWithDynamicClockType const&) + 150
5  JavaScriptCore                 0x7fffb0613587 std::__1::__function::__func<WTF::AutomaticThread::start(WTF::Locker<WTF::LockBase> const&)::$_0, std::__1::allocator<WTF::AutomaticThread::start(WTF::Locker<WTF::LockBase> const&)::$_0>, void ()>::operator()() + 199
6  JavaScriptCore                 0x7fffafacafd2 WTF::threadEntryPoint(void*) + 178
7  JavaScriptCore                 0x7fffafacaeff WTF::wtfThreadEntryPoint(void*) + 15
8  libsystem_pthread.dylib        0x7fffc2fce93b _pthread_body + 180
9  libsystem_pthread.dylib        0x7fffc2fce887 _pthread_start + 284
10 libsystem_pthread.dylib        0x7fffc2fce08d thread_start + 13

#21. WTF::AutomaticThread
0  libsystem_kernel.dylib         0x10c12dbf2 __psynch_cvwait + 10
1  libsystem_pthread.dylib        0x7fffc2fcf7fa _pthread_cond_wait + 712
2  JavaScriptCore                 0x7fffafad2fa7 WTF::ThreadCondition::timedWait(WTF::Mutex&, double) + 119
3  JavaScriptCore                 0x7fffb0622a22 WTF::ParkingLot::parkConditionallyImpl(void const*, WTF::ScopedLambda<bool ()> const&, WTF::ScopedLambda<void ()> const&, WTF::TimeWithDynamicClockType const&) + 2706
4  JavaScriptCore                 0x7fffb016fa16 bool WTF::ConditionBase::waitUntil<WTF::Lock>(WTF::Lock&, WTF::TimeWithDynamicClockType const&) + 150
5  JavaScriptCore                 0x7fffb0613587 std::__1::__function::__func<WTF::AutomaticThread::start(WTF::Locker<WTF::LockBase> const&)::$_0, std::__1::allocator<WTF::AutomaticThread::start(WTF::Locker<WTF::LockBase> const&)::$_0>, void ()>::operator()() + 199
6  JavaScriptCore                 0x7fffafacafd2 WTF::threadEntryPoint(void*) + 178
7  JavaScriptCore                 0x7fffafacaeff WTF::wtfThreadEntryPoint(void*) + 15
8  libsystem_pthread.dylib        0x7fffc2fce93b _pthread_body + 180
9  libsystem_pthread.dylib        0x7fffc2fce887 _pthread_start + 284
10 libsystem_pthread.dylib        0x7fffc2fce08d thread_start + 13

#22. WTF::AutomaticThread
0  libsystem_kernel.dylib         0x10c12dbf2 __psynch_cvwait + 10
1  libsystem_pthread.dylib        0x7fffc2fcf7fa _pthread_cond_wait + 712
2  JavaScriptCore                 0x7fffafad2fa7 WTF::ThreadCondition::timedWait(WTF::Mutex&, double) + 119
3  JavaScriptCore                 0x7fffb0622a22 WTF::ParkingLot::parkConditionallyImpl(void const*, WTF::ScopedLambda<bool ()> const&, WTF::ScopedLambda<void ()> const&, WTF::TimeWithDynamicClockType const&) + 2706
4  JavaScriptCore                 0x7fffb016fa16 bool WTF::ConditionBase::waitUntil<WTF::Lock>(WTF::Lock&, WTF::TimeWithDynamicClockType const&) + 150
5  JavaScriptCore                 0x7fffb0613587 std::__1::__function::__func<WTF::AutomaticThread::start(WTF::Locker<WTF::LockBase> const&)::$_0, std::__1::allocator<WTF::AutomaticThread::start(WTF::Locker<WTF::LockBase> const&)::$_0>, void ()>::operator()() + 199
6  JavaScriptCore                 0x7fffafacafd2 WTF::threadEntryPoint(void*) + 178
7  JavaScriptCore                 0x7fffafacaeff WTF::wtfThreadEntryPoint(void*) + 15
8  libsystem_pthread.dylib        0x7fffc2fce93b _pthread_body + 180
9  libsystem_pthread.dylib        0x7fffc2fce887 _pthread_start + 284
10 libsystem_pthread.dylib        0x7fffc2fce08d thread_start + 13

#23. WTF::AutomaticThread
0  libsystem_kernel.dylib         0x10c12dbf2 __psynch_cvwait + 10
1  libsystem_pthread.dylib        0x7fffc2fcf7fa _pthread_cond_wait + 712
2  JavaScriptCore                 0x7fffafad2fa7 WTF::ThreadCondition::timedWait(WTF::Mutex&, double) + 119
3  JavaScriptCore                 0x7fffb0622a22 WTF::ParkingLot::parkConditionallyImpl(void const*, WTF::ScopedLambda<bool ()> const&, WTF::ScopedLambda<void ()> const&, WTF::TimeWithDynamicClockType const&) + 2706
4  JavaScriptCore                 0x7fffb016fa16 bool WTF::ConditionBase::waitUntil<WTF::Lock>(WTF::Lock&, WTF::TimeWithDynamicClockType const&) + 150
5  JavaScriptCore                 0x7fffb0613587 std::__1::__function::__func<WTF::AutomaticThread::start(WTF::Locker<WTF::LockBase> const&)::$_0, std::__1::allocator<WTF::AutomaticThread::start(WTF::Locker<WTF::LockBase> const&)::$_0>, void ()>::operator()() + 199
6  JavaScriptCore                 0x7fffafacafd2 WTF::threadEntryPoint(void*) + 178
7  JavaScriptCore                 0x7fffafacaeff WTF::wtfThreadEntryPoint(void*) + 15
8  libsystem_pthread.dylib        0x7fffc2fce93b _pthread_body + 180
9  libsystem_pthread.dylib        0x7fffc2fce887 _pthread_start + 284
10 libsystem_pthread.dylib        0x7fffc2fce08d thread_start + 13

#24. WTF::AutomaticThread
0  libsystem_kernel.dylib         0x10c12dbf2 __psynch_cvwait + 10
1  libsystem_pthread.dylib        0x7fffc2fcf7fa _pthread_cond_wait + 712
2  JavaScriptCore                 0x7fffafad2fa7 WTF::ThreadCondition::timedWait(WTF::Mutex&, double) + 119
3  JavaScriptCore                 0x7fffb0622a22 WTF::ParkingLot::parkConditionallyImpl(void const*, WTF::ScopedLambda<bool ()> const&, WTF::ScopedLambda<void ()> const&, WTF::TimeWithDynamicClockType const&) + 2706
4  JavaScriptCore                 0x7fffb016fa16 bool WTF::ConditionBase::waitUntil<WTF::Lock>(WTF::Lock&, WTF::TimeWithDynamicClockType const&) + 150
5  JavaScriptCore                 0x7fffb0613587 std::__1::__function::__func<WTF::AutomaticThread::start(WTF::Locker<WTF::LockBase> const&)::$_0, std::__1::allocator<WTF::AutomaticThread::start(WTF::Locker<WTF::LockBase> const&)::$_0>, void ()>::operator()() + 199
6  JavaScriptCore                 0x7fffafacafd2 WTF::threadEntryPoint(void*) + 178
7  JavaScriptCore                 0x7fffafacaeff WTF::wtfThreadEntryPoint(void*) + 15
8  libsystem_pthread.dylib        0x7fffc2fce93b _pthread_body + 180
9  libsystem_pthread.dylib        0x7fffc2fce887 _pthread_start + 284
10 libsystem_pthread.dylib        0x7fffc2fce08d thread_start + 13

@latenitefilms
Copy link
Contributor Author

@asmagill - This may be of some interest: https://github.com/a2/touch-baer

@latenitefilms
Copy link
Contributor Author

@asmagill - This might be of interest if you're using macOS 10.14 Mojave:

a2/touch-baer@419a5cb

@latenitefilms
Copy link
Contributor Author

@asmagill - FYI:

2018-10-08 11:17:03: *** ERROR: NSInvalidArgumentException: +[NSTouchBar presentSystemModalFunctionBar:systemTrayItemIdentifier:]: unrecognized selector sent to class 0x7fff8c4436c0
(
	0   CoreFoundation                      0x00007fff34edd43d __exceptionPreprocess + 256
	1   libobjc.A.dylib                     0x00007fff60dea720 objc_exception_throw + 48
	2   CoreFoundation                      0x00007fff34f5a1a5 __CFExceptionProem + 0
	3   CoreFoundation                      0x00007fff34e7cad0 ___forwarding___ + 1486
	4   CoreFoundation                      0x00007fff34e7c478 _CF_forwarding_prep_0 + 120
	5   bar.so                              0x000000010f1ed1c4 touchbar_presentSystemModalFunctionBar + 420
	6   LuaSkin                             0x0000000109617577 luaD_precall + 697
	7   LuaSkin                             0x0000000109613869 luaV_execute + 733
	8   LuaSkin                             0x00000001096176ff luaD_call + 64
	9   LuaSkin                             0x0000000109617740 luaD_callnoyield + 21
	10  LuaSkin                             0x0000000109602c44 luai_objcttry + 28
	11  LuaSkin                             0x0000000109617cc8 luaD_pcall + 116
	12  LuaSkin                             0x0000000109611270 lua_pcallk + 236
	13  LuaSkin                             0x0000000109616ab4 luaB_xpcall + 115
	14  LuaSkin                             0x0000000109617577 luaD_precall + 697
	15  LuaSkin                             0x0000000109613869 luaV_execute + 733
	16  LuaSkin                             0x00000001096176ff luaD_call + 64
	17  LuaSkin                             0x0000000109617740 luaD_callnoyield + 21
	18  LuaSkin                             0x0000000109602c44 luai_objcttry + 28
	19  LuaSkin                             0x0000000109617cc8 luaD_pcall + 116
	20  LuaSkin                             0x0000000109611270 lua_pcallk + 236
	21  CommandPost                         0x00000001092b3dc8 MJLuaInit + 2068
	22  CommandPost                         0x00000001092b3485 MJLuaCreate + 14
	23  CommandPost                         0x00000001092b027b -[MJAppDelegate applicationDidFinishLaunching:] + 2863
	24  CoreFoundation                      0x00007fff34e88306 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
	25  CoreFoundation                      0x00007fff34e88280 ___CFXRegistrationPost_block_invoke + 63
	26  CoreFoundation                      0x00007fff34e881a1 _CFXRegistrationPost + 398
	27  CoreFoundation                      0x00007fff34e905ed ___CFXNotificationPost_block_invoke + 87
	28  CoreFoundation                      0x00007fff34df713a -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1633
	29  CoreFoundation                      0x00007fff34df64fd _CFXNotificationPost + 742
	30  Foundation                          0x00007fff37178bab -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
	31  AppKit                              0x00007fff32380c42 -[NSApplication _postDidFinishNotification] + 313
	32  AppKit                              0x00007fff32380566 -[NSApplication _sendFinishLaunchingNotification] + 209
	33  AppKit                              0x00007fff3237dec0 -[NSApplication(NSAppleEventHandling) _handleAEOpenEvent:] + 552
	34  AppKit                              0x00007fff3237db0f -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:] + 690
	35  Foundation                          0x00007fff371c3274 -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:] + 287
	36  Foundation                          0x00007fff371c30f0 _NSAppleEventManagerGenericHandler + 102
	37  AE                                  0x00007fff360adb6b _Z20aeDispatchAppleEventPK6AEDescPS_jPh + 1855
	38  AE                                  0x00007fff360ad3d5 _ZL25dispatchEventAndSendReplyPK6AEDescPS_ + 41
	39  AE                                  0x00007fff360ad2ad aeProcessAppleEvent + 439
	40  HIToolbox                           0x00007fff340c603e AEProcessAppleEvent + 55
	41  AppKit                              0x00007fff32379c3c _DPSNextEvent + 1734
	42  AppKit                              0x00007fff323786fa -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1362
	43  AppKit                              0x00007fff3237275d -[NSApplication run] + 699
	44  AppKit                              0x00007fff32361e97 NSApplicationMain + 780
	45  libdyld.dylib                       0x00007fff61eb8085 start + 1
	46  ???                                 0x0000000000000001 0x0 + 1
)

@latenitefilms
Copy link
Contributor Author

@asmagill - FYI: Another one:

2018-10-23 09:50:28: *** ERROR: NSInvalidArgumentException: +[NSTouchBar presentSystemModalFunctionBar:systemTrayItemIdentifier:]: unrecognized selector sent to class 0x7fff9708d6c0
(
	0   CoreFoundation                      0x00007fff3fb2743d __exceptionPreprocess + 256
	1   libobjc.A.dylib                     0x00007fff6ba34720 objc_exception_throw + 48
	2   CoreFoundation                      0x00007fff3fba41a5 __CFExceptionProem + 0
	3   CoreFoundation                      0x00007fff3fac6ad0 ___forwarding___ + 1486
	4   CoreFoundation                      0x00007fff3fac6478 _CF_forwarding_prep_0 + 120
	5   bar.so                              0x0000000110bd71c4 touchbar_presentSystemModalFunctionBar + 420
	6   LuaSkin                             0x000000010acc8577 luaD_precall + 697
	7   LuaSkin                             0x000000010acc4869 luaV_execute + 733
	8   LuaSkin                             0x000000010acc86ff luaD_call + 64
	9   LuaSkin                             0x000000010acc8740 luaD_callnoyield + 21
	10  LuaSkin                             0x000000010acb3c44 luai_objcttry + 28
	11  LuaSkin                             0x000000010acc8cc8 luaD_pcall + 116
	12  LuaSkin                             0x000000010acc2270 lua_pcallk + 236
	13  LuaSkin                             0x000000010acc7ab4 luaB_xpcall + 115
	14  LuaSkin                             0x000000010acc8577 luaD_precall + 697
	15  LuaSkin                             0x000000010acc4869 luaV_execute + 733
	16  LuaSkin                             0x000000010acc86ff luaD_call + 64
	17  LuaSkin                             0x000000010acc8740 luaD_callnoyield + 21
	18  LuaSkin                             0x000000010acb3c44 luai_objcttry + 28
	19  LuaSkin                             0x000000010acc8cc8 luaD_pcall + 116
	20  LuaSkin                             0x000000010acc2270 lua_pcallk + 236
	21  CommandPost                         0x000000010a965dc8 MJLuaInit + 2068
	22  libdispatch.dylib                   0x00007fff6cab2d4f _dispatch_call_block_and_release + 12
	23  libdispatch.dylib                   0x00007fff6cab3dcb _dispatch_client_callout + 8
	24  libdispatch.dylib                   0x00007fff6cabef5f _dispatch_main_queue_callback_4CF + 1125
	25  CoreFoundation                      0x00007fff3fa6e147 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
	26  CoreFoundation                      0x00007fff3fa6d856 __CFRunLoopRun + 2335
	27  CoreFoundation                      0x00007fff3fa6cce4 CFRunLoopRunSpecific + 463
	28  HIToolbox                           0x00007fff3ed06895 RunCurrentEventLoopInMode + 293
	29  HIToolbox                           0x00007fff3ed065cb ReceiveNextEventCommon + 618
	30  HIToolbox                           0x00007fff3ed06348 _BlockUntilNextEventMatchingListInModeWithFilter + 64
	31  AppKit                              0x00007fff3cfc395b _DPSNextEvent + 997
	32  AppKit                              0x00007fff3cfc26fa -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1362
	33  AppKit                              0x00007fff3cfbc75d -[NSApplication run] + 699
	34  AppKit                              0x00007fff3cfabe97 NSApplicationMain + 780
	35  libdyld.dylib                       0x00007fff6cb02085 start + 1
	36  ???                                 0x0000000000000001 0x0 + 1
)

@latenitefilms
Copy link
Contributor Author

Just saw this:

2019-04-01 15:36:30: ********
2019-04-01 15:36:30: 15:36:30 ERROR:      prop: Error while notifying a watcher: NSInvalidArgumentException: +[NSTouchBar dismissSystemModalFunctionBar:]: unrecognized selector sent to class 0x7fff87bc78b0
(
	0   CoreFoundation                      0x00007fff2f7daded __exceptionPreprocess + 256
	1   libobjc.A.dylib                     0x00007fff5b8a6720 objc_exception_throw + 48
	2   CoreFoundation                      0x00007fff2f8580e5 __CFExceptionProem + 0
	3   CoreFoundation                      0x00007fff2f77ca60 ___forwarding___ + 1486
	4   CoreFoundation                      0x00007fff2f77c408 _CF_forwarding_prep_0 + 120
	5   bar.so                              0x0000000113843b64 touchbar_dismissSystemModalFunctionBar + 148
	6   LuaSkin                             0x000000010d467552 luaD_precall + 699
	7   LuaSkin                             0x000000010d463877 luaV_execute + 723
	8   LuaSkin                             0x000000010d4676d8 luaD_call + 64
	9   LuaSkin                             0x000000010d467719 luaD_callnoyield + 21
	10  LuaSkin                             0x000000010d452ced luai_objcttry + 28
	11  LuaSkin                             0x000000010d467ca1 luaD_pcall + 116
	12  LuaSkin                             0x000000010d46129c lua_pcallk + 236
	13  LuaSkin                             0x000000010d466aa3 luaB_xpcall + 115
	14  LuaSkin                             0x000000010d467552 luaD_precall + 699
	15  LuaSkin                             0x000000010d463877 luaV_execute + 723
	16  LuaSkin                             0x000000010d4676d8 luaD_call + 64
	17  LuaSkin                             0x000000010d467719 luaD_callnoyield + 21
	18  LuaSkin                             0x000000010d452ced luai_objcttry + 28
	19  LuaSkin                             0x000000010d467ca1 luaD_pcall + 116
	20  LuaSkin                             0x000000010d46129c lua_pcallk + 236
	21  LuaSkin                             0x000000010d44b551 -[LuaSkin protectedCallAndTraceback:nresults:] + 203
	22  LuaSkin                             0x000000010d44b606 -[LuaSkin protectedCallAndError:nargs:nresults:] + 55
	23  usercontent.so                      0x0000000113487af7 -[HSUserContentController userContentController:didReceiveScriptMessage:] + 331
	24  WebKit                              0x00007fff3e67628e _ZN28ScriptMessageHandlerDelegate14didPostMessageERN6WebKit12WebPageProxyERKNS0_13FrameInfoDataERN7WebCore21SerializedScriptValueE + 190
	25  WebKit                              0x00007fff3e62e8f0 _ZN6WebKit29WebUserContentControllerProxy14didPostMessageERN3IPC10ConnectionEyRKNS_13FrameInfoDataEyRKNS1_13DataReferenceE + 178
	26  WebKit                              0x00007fff3e631179 _ZN3IPC13handleMessageIN8Messages29WebUserContentControllerProxy14DidPostMessageEN6WebKit29WebUserContentControllerProxyEMS5_FvRNS_10ConnectionEyRKNS4_13FrameInfoDataEyRKNS_13DataReferenceEEEEvS7_RNS_7DecoderEPT0_T1_ + 277
	27  WebKit                              0x00007fff3e34f08f _ZN3IPC18MessageReceiverMap15dispatchMessageERNS_10ConnectionERNS_7DecoderE + 127
	28  WebKit                              0x00007fff3e5d6000 _ZN6WebKit15WebProcessProxy17didReceiveMessageERN3IPC10ConnectionERNS1_7DecoderE + 24
	29  WebKit                              0x00007fff3e31be48 _ZN3IPC10Connection15dispatchMessageENSt3__110unique_ptrINS_7DecoderENS1_14default_deleteIS3_EEEE + 130
	30  WebKit                              0x00007fff3e31e6e7 _ZN3IPC10Connection24dispatchIncomingMessagesEv + 731
	31  JavaScriptCore                      0x00007fff32d45047 _ZN3WTF7RunLoop11performWorkEv + 231
	32  JavaScriptCore                      0x00007fff32d452d2 _ZN3WTF7RunLoop11performWorkEPv + 34
	33  CoreFoundation                      0x00007fff2f740395 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
	34  CoreFoundation                      0x00007fff2f74033b __CFRunLoopDoSource0 + 108
	35  CoreFoundation                      0x00007fff2f723dd1 __CFRunLoopDoSources0 + 195
	36  CoreFoundation                      0x00007fff2f72337a __CFRunLoopRun + 1219
	37  CoreFoundation                      0x00007fff2f722c64 CFRunLoopRunSpecific + 463
	38  HIToolbox                           0x00007fff2e9b9ab5 RunCurrentEventLoopInMode + 293
	39  HIToolbox                           0x00007fff2e9b97eb ReceiveNextEventCommon + 618
	40  HIToolbox                           0x00007fff2e9b9568 _BlockUntilNextEventMatchingListInModeWithFilter + 64
	41  AppKit                              0x00007fff2cc74363 _DPSNextEvent + 997
	42  AppKit                              0x00007fff2cc73102 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1362
	43  AppKit                              0x00007fff2cc6d165 -[NSApplication run] + 699
	44  AppKit                              0x00007fff2cc5c8a3 NSApplicationMain + 780
	45  libdyld.dylib                       0x00007fff5c974ed9 start + 1
	46  ???                                 0x0000000000000001 0x0 + 1
)
2019-04-01 15:36:30: ********

@Madd0g
Copy link

Madd0g commented Jan 24, 2020

hey guys, sorry if I'm asking in the wrong place, is hs._asm.undocumented.touchbar meant to allow to create custom buttons in the touchbar? I read that it's just a virtual touch bar?

It would be cool to shove my own buttons into the touchbar and customize everything with lua. I feel like the default apple touchbar options are pretty limited.

I saw all kinds of apps putting animations and other useless stuff in the touchbar, but there are very limited choices that allow the kind of customization that we could do with the rich HS api.

thanks

@latenitefilms
Copy link
Contributor Author

Yes, hs._asm.undocumented.touchbar allows you to create Touch Bar's in Hammerspoon - it's really awesome.

Check out this hs._asm.undocumented.touchbar.bar for more information. You can use hs.canvas to create whatever you want on there - it's very powerful.

We use it in CommandPost, and it works really well. FYI - CommandPost is a fork of Hammerspoon, with a bunch of custom Lua code to add additional features to the post production community. It's also open source, so you can check out how we use it.

@asmagill's code currently hasn't been updated to work with Mojave and Catalina, but you can refer to this pull request for the fix.

The only limitation we've run into is that it currently doesn't work with the 16-inch MacBook Pro. We currently don't have a solution for this yet.

Any questions let me know.

@Madd0g
Copy link

Madd0g commented Jan 24, 2020

Oops, thanks, I missed the fact that there are multiple readme files in that repo, I just saw the main one that says that it's a virtual touchbar :)

I saw a youtube video demonstrating how CommandPost manages the touchbar - it's really impressive.

I saw comments about it not working in the 16-inch model, that's unfortunate.

Thanks!

@latenitefilms
Copy link
Contributor Author

I would still recommend trying it, because I don't actually personally own a 16-inch MacBook Pro, so I'm just going off other user reports - maybe you can give some better clues as to why it's not working? I'm hoping the genius that is @asmagill might also have a chance to another look at the code at some point to see if anything obvious stands out.

The Touch Bar size on the 16-inch MacBook Pro is a different size, and uses a new T2 chip - so I'm guessing that's SOMETHING to do with it, but can't spot anything obvious in the code.

@latenitefilms
Copy link
Contributor Author

Now that Apple has dropped the Touch Bar on the 14-inch and 16-inch MacBook Pro, I'm going to close this issue. We'll still keep using @asmagill's awesome extension in CommandPost, but this functionality probably doesn't need to make it's way to the Hammerspoon core anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants