Categories
Apple Hardware Software

Script to display Mac battery information

You can see how this script makes that couple very happy.

Quick and dirty script that shows your Mac battery information (health, cycles, etc). If an Apple keyboard or mouse is connected, it’ll also display the battery % of those.

# Battery information
battery() {

	if !ioreg > /dev/null 2>&1; then
		echo "ioreg not found. Exiting."
		return 1
	fi

	_ioreg=`ioreg -l`
	_profile=`system_profiler SPPowerDataType`

	MOUSE=`echo $_ioreg -l | grep -A 10 "Mouse" | grep '"BatteryPercent" =' | sed 's/[^0-9]*//g'`
	TRACKPAD=`echo $_ioreg -l | grep -A 10 "Track" | grep '"BatteryPercent" =' | sed 's/[^0-9]*//g'`
	KEYBOARD=`echo $_ioreg -l | grep -A 10 "Keyboard" | grep '"BatteryPercent" =' | sed 's/[^0-9]*//g'`
	CYCLE=`echo $_profile | grep "Cycle Count" | awk '{print $3}'`

	if [ -n "$MOUSE" ]; then
		echo "Mouse: "$MOUSE"%"
	fi

	if [ -n "$TRACKPAD" ]; then
		echo "Trackpad: "$TRACKPAD"%"
	fi

	if [ -n "$KEYBOARD" ]; then
		echo "Keyboard: "$KEYBOARD"%"
	fi

	if [ -n "$CYCLE" ] && [ "$CYCLE" -ne 0 ]; then
		echo "Mac battery "`echo $_profile | grep "State of Charge" | awk '{print $5}'`"%"
		echo "Charging: "`echo $_profile | grep "Charging" | head -n 1 | awk '{print $2}'`
		echo "Cycles: "$CYCLE
		echo "Condition: "`echo $_profile | grep "Condition" | awk '{print $2}'`
		echo "Health: "`echo $_profile | grep "Maximum Capacity" | awk '{print $3}'`
	fi
}

Outputs something similar to this (no mouse or keyboard connected):

nazgul ~ $ battery
Mac battery 54%
Charging: No
Cycles: 224
Condition: Normal
Health: 89%

This works on zsh and may not work in bash.

Categories
Misc

Macbook Air M1 issues

I recently got my mom a Macbook Air M1, upgrading from a 2010 Macbook Pro (High Sierra).

When migrating over from High Sierra to Big Sur, using Migration Assistant (my Synology TimeMachine kept on failing — but besides that, migration went smoothly) two issues came up that required calling Apple.

But first off I noticed that when migrating, for some reason FileVault was turned off (more on that later). I, obviously, turned it on.

Problem A: when rebooting the Mac, I noticed the keyboard layout changed from Belgian (Azerty) to ABC (which is US English?) and it didn’t accept the password to unlock the Mac. You can manually select another keyboard layout which accepts the password, but at every reboot that resets and requires going back through the layout picker.

Solution A: M1 no longer supports the usual SMC or NVRAM reset. But this problem could be solved by turning off the mac, closing the lid (?!) and waiting 30+ seconds before turning it back on. According to the person on the phone, that’s the M1 SMC reset.

Problem B: I disabled guest mode in System Preferences > Users & Groups — but it was still showing alongside the regular/admin user. I don’t want guest mode.

Note that the guest mode only showed at the disk unlock (i.e.: after a reboot) and not when logged out (i.e.: Apple logo > Log Out from the regular user).

Solution B: Tried several things with Apple support:

  • Turning off screen sharing and print sharing (sure — didn’t care too much about these)
  • Turn guest mode on/off and reboot/force quite System preferences
  • Turn off Find My in iCloud settings (not acceptable)
  • Turn off FileVault (not acceptable)
  • Manually running:
    • sudo defaults write /Library/Preferences/com.apple.AppleFileServer guestAccess -bool NO\n
    • sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server AllowGuestAccess -bool NO\n
  • and a few other things I now forgot

This is what actually did help:

  • Turning off FileVault actually turns off Guest mode; so when the Mac was not encrypted, it only showered one user (instead of the user + Guest) at the login prompt.
    • Obviously, that’s not acceptable and I turned it back on
  • Supposedly turning off Find My in iCloud settings is needed (according to Apple this requires Guest mode)
    • I later turned it back on and Guest mode did not reappear. So, what Apple was saying was incorrect, and it does not make the Guest user show up.
  • Running sudo fdesetup list in Terminal shows the list of users. This may be helpful for debugging.
  • Running dscl . list /Users shows many users and included Guest in my mom’s case. Not entirely sure what I am looking at here.
  • Running sudo dscl . delete /Users/Guest solved the problem. This deletes the Guest user (?).

Categories
Apple Hardware

Yard Sale: Macbook Pro late 2013

For sale due to getting a portable Macbook:

  • Late 2013 Macbook Pro (15.4″ Retina)
  • 2.3Ghz i7 (quad core + Hyper-Threading)
  • 16Gb RAM
  • 512Gb SSD
  • Intel Iris onboard GFX + Nvidia GeForce GT 750M PCE GFX
  • BE-Azerty keyboard
  • €2445,41 in 28 October 2013
  • SUPER fast
  • Minor scratch in the back of the LCD
  • Minor (not very noticeable) corrosion at the right hand
  • Weird scratch “smear” in LCD display (only visible on white background; about 2x2cm; to be honest it’s not really visible)
  • Besides this very decent Macbook Pro, it has been used, but in very good shape for the extreme work it has committed. Taken care of this device as if it was my own child. And did I mention blazing fast?

Contact: [email protected]

Specs:

Processor 2.3GHz Quad-core Intel Core i7
Memory 16GB 1600MHz DDR3L SDRAM
Flash Storage 512GB Flash Storage
Apple Thunderbolt to Enet Adpt Apple Thunderbolt to Enet Adpt Apple Thunderbolt to FW Adptr No FireWire Adapter
Mini DisplayPort to VGA Adptr No VGA Adapter
Keyboard and Documentation Keyboard/User’s Guide(Z)-BEL Country Kit Country Kit-INT

Pictures:

IMG_20160823_010509

It’s a Macbook Pro !

IMG_20160823_010523

“Smear” above “AGE” (really hard to see)

IMG_20160823_010531

Scratch at the back (knocked it against a glass door at night in my old apartment)

IMG_20160823_010450

Corrosion at the right hand (not left, don’t ask why — probably because I use the touch pad all the time).

More info:

Screen Shot 2016-08-23 at 00.50.51

Screen Shot 2016-08-23 at 00.50.54

Screen Shot 2016-08-23 at 00.52.35

Screen Shot 2016-08-23 at 00.54.11Screen Shot 2016-08-23 at 00.54.28

Categories
Apple

Macbook Air vs Macbook Pro vs older Macbook Pro(s)

So, I had to migrate from a Pro to an Air a few weeks ago. My Macbook got repaired (out of warranty, for 600ish damn euro) and I sold it. I waited for the new line of Macbooks and ordered myself a new one. I picked the Retina version.

Just as with my previous Macbook Pro, I went for overkill in the hope to keep it as long as possible.

Except for a faulty GPU, my previous Mac was actually still very capable, and I would not have thought about getting rid of it any time soon.
It was still smooth and blazing fast. I had quite some bad experience with my first Macbook Pro (see below, SATA and 2Gb RAM); that device was already crippled after a few weeks of usage. Annoyingly slow and laggish.

So I hope to be able to do 4+ years with this one. This was my Macbook Air (with a SDD):

mba

These are my frustrations/comments now that I’m back on a Pro:

  • FFFFFFUUUUU for not having a builtin ethernet port. Same for the Air. I have had SO much shit not having a simple ethernet port (to test UTP, and for FlatTurtle demos). It’s unbelievable how much I still rely on a simple ethernet port. Needless to say I got a thunderbolt-to-ethernet adapter (another 20 or so € to Apple).
  • CD burner. I’ll miss you. Like, twice per year, I still burn an iso to CD to boot something or to install Linux. I’ll have to get a big/decent USB drive and start using that I guess.
  • WHY OH WHY DID YOU KILL THE REMOTE CONTROL. It already bothered me the Air didn’t have it… It was very useful with VLC and watching movies. You’ll be greatly missed.
  • It’s the first time I’m on Retina. It looks better. But it seems the actual resolution is the same as the Air (WTF!) and lower than the previous Macbook Pro (WTF!).
    I had the high-res MBP previously: “Optional 15.4-inch (diagonal) LED-backlit widescreen display with 1680 by 1050 pixels (glossy or antiglare)“; I miss that resolution 🙁 whenever I’m doing something on my mom’s Mac I really instantly notice the huge extra room. Now I could turn off retina and go for the higher resolution but… sigh…
  • Next to my Air, now that I got used to the size, it looks huge.
    But the more I work with it, the more I like my bigger screen and the somewhat more manly/robust size. I’ve also noticed I’ve been using my 2nd display a lot less (but this is also partly due to all that crap on my desk at the moment, and the temperature dropping in my study room with the cold weather).
  • Why did you have to change Magsafe adapter size. I ordered a Magsafe1 to Magsafe2 adapter from Techdata. another 7 euro (excl tax) down the drain.
  • It’s surprisingly thin. Why did no other hardware maker beat them to it?
  • THANK YOU APPLE FOR STILL INCLUDING A SD CARD SLOT. Yay for Raspberry Pi and other hacking.
  • The case no longer slices the wrists. It has somewhat been rounded.
  • Bluetooth + WiFi seems bugged (random packet loss (like 20-30 packets) and/or high latency. Turning off Bluetooth insta fixes the problem. Reconnecting to WiFi also fixes it (and keeping bluetooth on). This is shit. Don’t blame it on the router or signal strength, my previous MBP never had this problem, and neither did the Air.
  • Every connector at the left side of this Macbook Pro is too close to eachother. I have line-out, USB disk, my Mini display port and Magsafe2. Annoying when I need to just unplug the USB drive.
  • I managed to get 9h30 out of the battery. That’s a normal person’s work day (yeah, not quite in startups). And still had 17% to spare. While admittedly, I wasn’t doing that much on it (60-70% brightness, Sublime Text, Terminal, Git, SSH, some very light mailing & browsing and waiting for my desktop to finish bootstrapping while watching Star Wars semi actively), it’s still quite remarkable. If a i7 can do this, why can’t a stupid smartphone survive a day on 3G?
  • When having to charge your battery though, and while sitting ‘legged‘ with the Macbook on my lap, the Magsafe2 (having its cord not longer aligned to the laptop, and being longer) causes my Magsafe to always disconnect. I didn’t have this problem with the previous Magsafe (version two of Magsafe1)

This is my new laptop:

mbp3

And for the sake of completion: (A G4 powerbook, but don’t have any system info of that one; although it stills runs and is used by my dad).

Macbook Pro mid or late 2007 (7200 rpm, but it has always been a damn slow machine):

mbp1

Macbook pro mid 2010 (my mom got it now):

Capture d’écran 2013-11-10 à 16.24.19

Categories
Apple

My new Macbook Pro arrived

… Restoring from TimeMachine… 1 hour and 16 minutes remaining…

It took a weird route (Shanghai to Korea to Kazakhstan?!) but I finally got it. Yayyies.

ups

Later a blog post about what it’s like to migrate from a Macbook Air to a Macbook Pro again.