matryer / matryer/xbar-plugins

001-keyboard.1m.sh & 001-mouse.1m.sh on newer M1 mac

Open
#1,850 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

shell
Dominant language
Shell
Stars
2.6k
Forks
1.1k
Avg merge
9d 15h
Merged PRs (30d)
1

Description

These scripts didn't work for me on OSX Monterey with M1 but the commands used in https://github.com/aromig/scripts/tree/master/check_battery worked fine.

I altered my scripts so they work and look like the following. I just wanted to share here in case anyone else had this issue.
Screen Shot 2022-08-02 at 2 59 57 PM

### 001-keyboard.1m.sh
```sh
#!/bin/sh

# Keybard Battery
# Mat Ryer
# matryer

PERCENTAGE=$(ioreg -c AppleDeviceManagementHIDEventService -r -l | grep -i keyboard -A 20 | grep BatteryPercent | cut -d = -f2 | cut -d ' ' -f2)

if [ "$PERCENTAGE" ]; then
echo "⌨️ $PERCENTAGE%"
#else
# echo "without bluetooth keyboard?"
fi
```

### 001-mouse.1m.sh
```sh
#!/bin/sh
# Mouse battery
# 1.0
# Alexandre Espinosa Menor
# alexandregz
# Show battery percentage for Bluetooth Mouse
# http://i.imgur.com/IqjZMJg.png

# works fine with Magic Mouse

PERCENTAGE=$(ioreg -c AppleDeviceManagementHIDEventService -r -l | grep -i mouse -A 20 | grep BatteryPercent | cut -d = -f2 | cut -d ' ' -f2)

if [ "$PERCENTAGE" ]; then
echo "🖱️ $PERCENTAGE%"
#else
# echo "without bluetooth mouse?"
fi
```

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with 001-keyboard.1m.sh and 001-mouse.1m.sh, then compare their battery lookup commands with the ioreg pipeline shown in the issue. Verify the updated scripts on an M1 Mac running Monterey and confirm that each plugin reports the connected device's battery percentage.

Written by the indexing model from the issue text.

Assessment

Tech stack
macos, shell
Domain
desktop
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.