applescript – How to tell when Magic Keyboard or Trackpad are charging from bash

So I just registered and have not enough Kharma to comment on the original post (but I can ask a new question and this makes no sense to me; go figure), but I got this excellent script from Will Cain from here (Get low battery notifications for mouse earlier), and I modified it a little.

The intention is to keep the battery between 20 and 80%, but I don’t want the messages to keep appearing, for example, if the battery is lower then 20% but is already charging; or if the battery is highter then 80% and it’s not charging anymore.

I’m pretty noob when it comes to bash scripting, though. But here’s the general idea:

   #!/usr/bin/env bash
PATH=/usr/local/bin:/usr/local/sbin:~/bin:/usr/bin:/bin:/usr/sbin:/sbin

# actual battery level
BATT=`ioreg -c AppleDeviceManagementHIDEventService -r -l | grep -i keyboard -A 20 | grep BatteryPercent | cut -d= -f2 | cut -d' ' -f2`

#Devices is connected, not charging
CONN=`ioreg -c AppleDeviceManagementHIDEventService -r -l | grep -i connected - A 20`

#Device is charging
CHARG=`ioreg -c AppleDeviceManagementHIDEventService -r -l | grep -i charging -A 20`

# defaults to warn at 20%; accepts other number as 1st argument (useful for testing)
MIN=${1:-20}

# defaults to warn at 20%; accepts other number as 1st argument (useful for testing)
MAX=${1:-80}

if ( -z "$BATT" ); then
  echo 'No keyboard found.'
  exit 0
fi

if ((( BATT < MIN )) && ((CONN))); then
  osascript -e "display notification "Keyboard battery is at ${BATT}%." with title "Keyboard Battery Low""
fi

if ((( BATT > MAX )) && ((CHARG))); then
  osascript -e "display notification "Keyboard battery is at ${BATT}%." with title "Keyboard Battery High""
fi

Obviously line 11 (CHARG) doesn’t work because ioreg doesn’t seem to contain that information. Any suggestions, maybe something more elegant then this?

macbook pro – A1502 trackpad unresponsive and keyboard occasionally erratic

My computer is a mid-2014 retina MacBook Pro.

After five days of sleep, the trackpad stopped responding to touch input, and couldn’t be revived by any number of NVRAM/PRAM/SMC resets. Most recently, the keyboard has also started to become unresponsive after waking from sleep until the computer is rebooted. No water damage occurred.

I have access to some spare parts due to trackpad cable shenanigans from days past:

  • 2x iFixit trackpad (excluding cables),
  • 1x iFixit trackpad cable, and
  • 1x original Apple trackpad cable (known defective)

For clarification, in my attempts below, I refer to the Apple trackpad and cable as “original”, the two iFixit trackpads as trackpads “A” and “B”, and the iFixit trackpad cables as “1” and “2”.

The setup currently operating inside the MBP comprises iFixit trackpad cable “A” and the original Apple trackpad.

I’ve tried the following things, to no avail:

  1. Reboot
  2. NVRAM/PRAM reset
  3. SMC reset (NVRAM/PRAM/SMC were reset multiple times now and after almost every later step)
  4. Checked that trackpad is still recognized under System Information – still there, from previous experience if the trackpad isn’t detected it doesn’t show up in here
  5. Deleted trackpad preferences
  6. Tried updating software to latest version – macOS Catalina 10.15.6
  7. Tried diskutil verifyVolume and diskutil repairVolume
  8. Tried booting into Recovery to isolate if issue is software or hardware related – seems to be hardware related since the issue persists in Recovery
  9. Ran Diagnostic Test to see if any issues with trackpad were reported – no issues were found
  10. Tried booting into external boot drive to isolate if issue is software or hardware related – issue persists
  11. Tried original trackpad with original cable – this is a known defective combo, which gave me trackpad issues last year with wild inputs; no inputs were detected this time around
  12. Tried original trackpad with iFixit cable A
  13. Tried original trackpad with iFixit cable B
  14. Tried iFixit trackpad A with original cable
  15. Tried iFixit trackpad A with iFixit cable A
  16. Tried iFixit trackpad A with iFixit cable B
  17. Tried iFixit trackpad B with original cable
  18. Tried iFixit trackpad B with iFixit cable A
  19. Tried iFixit trackpad B with iFixit cable B
  20. Debugged in Single User Mode and saw errors arising from AppleUSBMultitouch saying (HID) (USBMT) (Error) ReportID is invalid in AppleUSBMultitouchDriver::_deviceGetReportWithLookup – I doubt this is the issue, since it should be driven by AppleMultitouchDriver; but as the trackpad is classified as a USB device under System Preferences, I wasn’t too sure
  21. Booted into Recovery and saw that the error message mentioned above did not appear, arousing suspicion it is software related – again, I’m not sure if this is the issue; even though the error message didn’t appear the issue persisted
  22. Tried replacing AppleUSBMultitouch, AppleMultitouchDriver, AppleTopCase kernel extensions with fresh kernel extensions from macOS installer – didn’t work because codesign is different
  23. Tried macOS 10.15.6 reinstall – also didn’t work, but the error mentioned in (20) was no longer present
  24. Tried fresh macOS install on a brand new partition – no luck here either
  25. Procured replacement iFixit trackpad cable, and tested with original trackpad – this was done on the suspicion that all my cables may be defective
  26. Tested replacement cable with trackpad A – didn’t work
  27. Tested replacement cable with trackpad B – didn’t work
  28. Reseated trackpad and keyboard cables fully – didn’t work
  29. Removed logic board to inspect CY8C24794-24LTXI USB controller connections for corrosion – I live in an area near the ocean where corrosion of metallic parts is inevitable after a few years, so I figured that might’ve been an unfortunate cause. However upon close inspection with a microscope looking for signs of corrosion, dejointing, or shorts no glaring issues were found with the chip or its joints. The ZIF connectors were also in good shape.

I’ve also taken it to an Apple Genius, but they ran their tests, found nothing wrong, and told me I’ve already done pretty much what they would’ve done, if not more. This leaves me quite stuck with truly no idea what’s going on with my trackpad and keyboard subsystem. For now, I’ve started using the ol’ wireless mouse (and sometimes keyboard), and that should tide me through for a while.

Are there any possible causes of this issue, or perhaps solutions to reviving the trackpad?

Macbook air 2012, installed new battery, bottom of trackpad sounds loose/clicky now, ideas?

My other one couldn’t hold a charge well but didn’t look bloated at all to have warped anything in my system.

All that was weird that happened was that I lost one of the bottom case screws (small ones), could this cause it? (I could get replacement from amazon).

I’m going to go back in and tighten all the case screws, battery screws and tighten the trackpad screws, that’s about all I can do right?

bluetooth – Magic Mouse2 keep loosing connection which keyboard and Magic Trackpad work fine

I have a Magic Mouse 2, Magic Trackpad and Apple keyboard. From time to time, mainly when I have higher CPU usage, my mouse drops it’s connection. I have my trackpad next to it and it is still working fine, as is my keyboard.

I think I have narrowed it down to the amount of screen I have attached to my computer. At work I have a Dell 43″ 4k screen and at home I have (2) 27, 1(34 wide) and (1) USB Screen. If I have all screens running then my mouse drops more frequently.

I have a 2018 Macbook Pro 15 with 16gb memory, i7, 4gb video memory

bluetooth – Best way to switch magic keyboard and trackpad between work/personal Macs?

I would like to seamlessly switch my bluetooth devices (headphones, magic keyboard, touchpad) between work / personal Macs without complex repairing.

Has anyone solved this problem?

Yes.

You purchase Bluetooth devices (keyboard, mouse, headset, etc.) that have multiple device support.

  • The Magic Keyboard, Mouse, and Track Pad are designed to be paired with a single computer. However, products like the Logitech MX series as well as the K380 (typing on it right now) can pair with up to 3 devices and switch with the press of a button.

  • Sennheiser headphones (my personal choice) can pair with up to 8 devices total and with 2 simultaneously. There are many other brands (Bose, Apple AirPods, Sony, etc.) that have this functionality.

There’s no software that is going to your initiate your Bluetooth devices to switch from one device to another – you can only imagine the security implications!

Bottom line, to easily switch between devices without complex the re-pairing as you describe, you need devices that support multiple pairings. If the device doesn’t support it, you’ll need to pair and unpair it each time.

macos – Can I see where I’m touching my trackpad on the screen and whether it’s being interpreted as a right or left click?

As a way of addressing Is there a spatial map for 2020 MacBook Air track pad’s right-click “sweet-spot”? I was wondering if I can see in real time on my screen what my trackpad “sees”, or more accurately, what it detects and interprets.

Is there a way to display the location that a single finger “click” on my 2020 MacBook Air’s track pad is interpreted, and whether it’s assigned as a right or left click?

touchpad – Function Keys for Trackpad, Keyboard Backlight, and Camera not Working

I have an Asus Zenbook UX425JA. Came pre-installed with Windows 10. I installed Ubuntu 20.04.1 instead.

Most function keys are working (Volume, mute, screen brightness, screen lock keys all work), but some do not, in particular the one for enabling/disabling the trackpad, one for controlling keyboard backlight, and one for enabling/disabling the camera.
Function lock (Fn+Esc) does not work either.

I tried the first answer here, but the grub edit made even more function keys nonfunctional, and when I added the config file, I was getting strange lines on my screen (green vertical line on my desktop, horizontal white strips in browser… thought my screen was broken tbh).

I’d super appreciate any help. I’m an absolute noob, this is my first ever experience with Linux, having “declared windependence” 3 hours ago… 😅

trackpad – Is there a spatial map for 2020 MacBook Air track pad’s right-click “sweet-spot”?

I’m migrating from a late 2012 to a new 2020 MacBook air and having difficulty right clicking. Sometimes when I push with the side of my right thumb:

  1. a light touch works perfectly and I feel some haptic feedback or “give” or “click”
  2. it feels solid and unyielding and nothing happens
  3. I feel some haptic feedback or “give” or “click” but it’s interpreted as a “left click”

I’ve try clicking around and making a map manually but I get strange results and I’m thinking there is something more complicated going on that I don’t understand. After eight years of using one trackpad it’s all in “muscle memory” and I’m struggling now that I have to think about it. I’m so tired of the wrong thing happening that now I’m afraid to right click.

I think if I could see a map of the track pad’s sensitivity for right-vs-left click and for haptic-feedback, or better yet some engineering-like testing of their spatial variability, that might help me to interpret what I’m doing wrong and how to improve it.

macbook pro – How to disable the “Your trackpad is wirelessly connected to this Mac” notification?

So I have a 2019 Macbook Pro connected to a Caldigit TS3 Plus dock. Connected to that I have a Magic Trackpad 2 via USB cable (to charge it). It is a Bluetooth device. Every time I connected my MBP to this docking station I get this stupid notification:

Your trackpad is wirelessly connected to this Mac

And I can’t for the life of me figure out how to disable this. There’s no Bluetooth setting for the device. Clicking on “Settings” takes you to the Bluetooth System Preferences. There’s nothing I can see under Notifications Systems Preferences that pertains to this.

Now I should also mention that I connect TWO different MBPs to this same docking station and it seems like only when I change laptops does this come up but I’m not 100% sure about that (as in, I’m not 100% certain it doesn’t show up when I power the same laptop on or wake it up).

I’m actually shocked that a Google search for “Your trackpad is wirelessly connected to this Mac” (including quotes) has exactly 0 matches.

Correct way with Macbook Pro trackpad to select from dropdown form?

Having started to use a MacBook Pro with Catalina a lot more than a Mac Mini, I’ve had trouble trying to negotiate the trackpad after using a mouse for so long.

I want to be able to use a dropdown / select, like this example at https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_optgroup but do not know the correct trackpad gesture for selecting it; I’ve done some light Google-ing but am unsure.

Any help is appreciated.