logo
EverydayChaos
Everyday Chaos
Too Big to Know
Too Big to Know
Cluetrain 10th Anniversary edition
Cluetrain 10th Anniversary
Everything Is Miscellaneous
Everything Is Miscellaneous
Small Pieces cover
Small Pieces Loosely Joined
Cluetrain cover
Cluetrain Manifesto
My face
Speaker info
Who am I? (Blog Disclosure Form) Copy this link as RSS address Atom Feed

September 24, 2020

Toggling a bluetooth device from the command line

I move my laptop from my home office to other rooms of the house after I realize, as I do at least twice a day, that my office looks like a hoarder’s storage locker. Rather than cleaning it up, I decided to make it slightly easier for me to make those moves.

The problem is that if I move my MacBookPro (2019) out of bluetooth range of my Apple MagicMouse, the trackpad doesn’t accept input. And that means I have to trudge the entire 15 feet back to my office to get my mouse. That obviously is simply not acceptable, so I instead spent several hours writing a shell script that I can run in a terminal that will toggle my mouse (or any other bluetooth device) on or off.

It requires you to install blueutil, an open source set of command line tools for managing your bluetooth connections. (Thank you, Ivan Kuchin). To install blueutil, in a terminal type “brew install blueutil”. If you don’t have Homebrew installed, you’ll get an error message, in which case install Homebrew. It’s very useful.

You also will need to know the bluetooth ID of the device you want to control. You can find that by going to your Mac’s Settings and clicking on the bluetooth icon, or by running blueutil in a terminal with the parameter “–paired.”

To use this script, copy and paste it into a text editor and save it with a “.sh” extension. To let your Mac know that this is a text file that should be run, not just read, you need to go to a terminal and change its permissions to 755. (For instructions on how to do that and how to run it from a terminal, check here.) (I have bound the crl-alt-com B key to running it, thanks to KeyboardMaestro.)

Note that I am a bad writer of shell scripts. I had to look up just about everything except how to write a comment. Have some compassion, people! And if not that, how about some pity?

#!/bin/zsh
# Toggles a device's bluetooth activity on and off.
# Useful for when you move out of range of your bluetooth
#   mouse and your Mac's trackpad becomes 
#   unresponsive. For example.
# Requires installing Blueutil:
# https://github.com/toy/blueutil/blob/master/README.md
#
# I post this as Creative Commons Zero, i.e., public domain. 
# David Weinberger, Sept. 24, 2020 [email protected]

# Add your device's bluetooth ID here.
# If you don't know it, run "blueutil --paired"
# in a terminal window to find out.
ID="04-4b-ed-d2-ef-23" # Just an example

echo "Toggles bluetooth device. Requires blueutils be installed.";
echo "USAGE: bluetoggle. No parameters";
echo "Device ID: ${ID}"
echo "--------";

# is the device connected?
# Run blueutil and returns the text.
STATUS=`blueutil --paired`

# is the ID mentioned in the status?
# If not, then it hasn't been connected, so there's
# nothing for this  script to do
if [[ $STATUS != *"${ID}"* ]]
then
    echo "Device not found. Edit bluetoggle.sh to add device's bluetooth ID. Exiting."
    exit
fi

# Look for the ID followed by ", not connected"
if [[ $STATUS == *"${ID}, not"* ]]
then
    echo "${ID} is not connected. Connecting..."
    CL=`blueutil --connect ${ID}` # Create command string
    NEWSTATUS=`${CL}` # Run the command
else
    echo "Disconnecting device..."
    CL=`blueutil --disconnect ${ID}`
    NEWSTATUS=`${CL}`
fi

exit

Tweet
Follow me

Categories: tech Tagged with: bluetooth • mac • shell script • tech Date: September 24th, 2020 dw

Be the first to comment »

April 28, 2013

When a new hard drive won’t accept a Mac OS

In my continuing series “How to Be an Idiot,” here’s what not to do when installing a new hard drive into your MacBook Pro.

I started off right. I had everything prepared: a new 500gB hybrid drive, a fresh Time Machine backup, and an 8gB USB stick with the Mac Mountain Lion installer on it. I still managed to fail maybe 20 times over the course of two days booting from everything I could find, re-installing Lion onto the stick, backing up from Time Machine, etc. The closest I came was when I installed off the repair partition over a backup drive. The Mac started up its install process, but got stopped with a message that said that Apple was unable to confirm that my computer is authorized for an OS install. At least, that’s what I think it meant; it’s not a very clear message, and, no I didn’t write it down :(

This made me think that the problem was that I was trying to install the wrong version, although I was pretty durn sure that I had upgraded to Mountain Lion a few weeks earlier, having resisted the blandishments of Lion. Maybe Apple was confused, although I couldn’t see why. I installed the prior version of the OS on my USB drive. Nope.

And now for the answer. And it’s not going to make me look smart, that I promise you.

You see, kids, for Apple to verify my machine, it has to get onto the Internet. It turns out that if during the install process you give your Mac a choice of wifi hotspots to connect to, it picks an open one without asking for your say-so. As a result, it happened to pick a hotspot that requires a login on a web site, but there’s no browser available during the install process. Once I pointed the Mac to another hotspot, it was able to connect and authorize my machine, enabling the installation to proceed.

Sure it was dumb of me. But it’s also dumb of Apple to give us an error message that says that it’s unable to authorize, rather than that it was unable connect. (I also didn’t see a relevant message in the Installer log, but I may have missed it.)

Fortunately, each of the things I tried took a relatively long time to fail, so I was able to get a lot done while trying. Still, the moment of victory was definitely a forehead-slapper for me.

Tweet
Follow me

Categories: tech, whines Tagged with: apple • install • mac • n00b Date: April 28th, 2013 dw

1 Comment »

May 20, 2012

Lion fixed my SuperDrive. (Alternative title: Snow Leopard broke my SuperDrive)

Yesterday Disk Utility told me to restart my Mac from a boot disk and run the disk repair function (= Disk Utility). Fine. Except I was unable to boot from any of my three Mac boot disks (including the original) whether they were in my laptop’s SuperDrive (= Apple’s plain old DVD drive) or in a USB-connected DVD drive. The system would notice the DVD when asked to look for boot devices (= hold down the Option key when starting up), but froze after I clicked on the DVD (= no change in the screen after 30 mins).

So, what the hell, I installed Lion, which I had been hoping to avoid (= my pathetic resistance to Apple’s creeping Big Brotherism). Thanks to the generosity of Guillaume Gète, I downloaded Lion DiskMaker, followed the simple instructions (= re-downloaded Lion, all part of Apple’s makings things hard by making them easy program), and now have a Lion boot disk. I was able to boot from it and fix my hard drive.

The whole episode was so reminiscent of why I left Windows (= Windows 7 looks pretty good these days).

Tweet
Follow me

Categories: tech, whines Tagged with: apple • mac • windows Date: May 20th, 2012 dw

3 Comments »

March 15, 2012

Little Mac trick

I learned a little Mac trick a few weeks ago and find that it has saved me, oh, probably close to a full minute. More important, it keeps me from the annoyance of fiddling with Finder unnecessarily.

Let’s say you’ve just finished working on a slide deck in Keynote — but the beauty of this little trick is that it works with every Mac app — and now you want to email it as an attachment. Open up your email client and simply drag the little tiny document icon at the top center of the window.

The little icon at the top

It's the icon next to "architecture01.key"

Drop it into your email client and (assuming it handles the ol’ dragondrop) it’s attached. No stinking Finder required! Use it whenever you want to drag your current file somewhere.

Tweet
Follow me

Categories: misc Tagged with: hint • mac • tip Date: March 15th, 2012 dw

3 Comments »

June 30, 2011

Nice people make life better.

My MacBook crashed hard today after installing an Apple update. I couldn’t even boot it from the spare boot disk I had with me; I got the slash-through-circle sign upon booting. Nor could I boot into single-user or safe mode. I couldn’t boot into any stinking mode.

So, I got the name of the nearest Mac store in Madrid and walked there. But they don’t do anything technical, so they sent me 6km away to a small Mac tech shop where two young men put up with my broken Spanish. They ran a test or two, and told me that my drive was shot. (I think it was probably cause by a bad interaction with the PGP software Harvard has guarded my drive with; it sometimes doesn’t like updates to the OS.) Because I’m traveling, I agreed to let them do a complete OS reinstall, wiping out all my data. (I have my current files on DropBox, and have a TimeMachine restore back in the office.) They got right on it, even though they undoubtedly had other jobs in the queue. I went for a lovely 34 minute walk, and came back.

My drive works. I’m restoring what I can off of my mini HD. And the lads charged me $0. Not because of AppleCare, but because they’re nice.

You can find these friendly, helpful, kind people at Univsersomac, Orense, 69 (entrance on General Varela, 38) in Madrid. +34 91 188 88 23.

Say hello for me.

Tweet
Follow me

Categories: misc Tagged with: mac • madrid • nice Date: June 30th, 2011 dw

4 Comments »

January 28, 2011

Stupid Mac tricks

Here’s a fun little Mac trick from MacLife:

1. Open a terminal.

2. Type:

/System/Library/Frameworks/ScreenSaver.framework//Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background &

3. Hit the return key.

4. Hit the button that lets you see your desktop.

5. Close the terminal to end the effect.

6. Blame MacLife for anything that goes wrong (although nothing should).

Tweet
Follow me

Categories: misc Tagged with: mac Date: January 28th, 2011 dw

Be the first to comment »

November 28, 2010

Annals of D’oh: Getting PDAnet to work on my Mac

I spent about an hour this morning trying to get PDAnet to work on my MacBookPro the way it once did. Had I not magically missed the question in the FAQ that addresses the issue, I could have saved myself 58 minutes of a Sunday morning.

PDAnet allows you to use your mobile phone as a modem. So, when there’s is no wifi, or when you don’t want to pay a hotel $25/day to use their stinking wifi, you can plug your mobile into your laptop via USB (PDAnet also supports Bluetooth, but as with every other Bluetooth app, it is as close to impossible to get to work as its evil masterminds could achieve) and surf the Web via your cellphone connection. Whatever data charges your cellphone company inflicts will apply.

PDAnet had been working like a dream for me. I had sprung for the paid version so that I could access secure sites. I was in tethered heaven. Then it stopped.

I uninstalled, redownloaded, rebooted, and tried again … and again and again. I wouldn’t get error msgs anywhere except in my browser when I tried to go to a site. The ping command in my terminal told me it couldn’t resolve the host. Weirdly, Console told me “before listening on daemon socket” and “CDaemonCon 2 exits.” These were only weird because the first has a single unhelpful hit at Google and the second has none. None! It’s an error message from another planet!

Then I re-checked the PDAnet help page. And there it says quite plainly: “Mac When connecting the PdaNet menubar icon keeps blinking and I have no Internet.” The explanation:

This is because the Network Interface create by PdaNet is not added on Mac automatically for some reason.

Try to open Networks Preferences and click on “+”, then select the new Network Interface the biggest “en” number such as en2 or en3 and click “Apply” with DHCP selected.

These instructions are almost correct. So, go to System Preferences, and then to Network. Click on “+” at the bottom of the list of connections on the left. Choose “Internet adaptor” from the list. “Internet adaptor” will have some number after it. After accepting, that connection will show up in the list on the left. Make sure that the choice to the right of “Configure IPv4” says “DHCP.” You should be good to go.

PDAnet rocks when you remember to reading the effing FAQ.

D’oh.

Tweet
Follow me

Categories: tech Tagged with: mac • pdanet • problem Date: November 28th, 2010 dw

4 Comments »

August 16, 2009

New Mac, and cloning BootCamp XP

Because one of our children needs a new computer, I’ve ordered a brand new 15″ MacBook Pro … for myself. Our child will get my current MacBook 13″. Don’t look at me like that! I’m more of a power user than our child is. And I’m older. Also, I’m paying for it. But mainly it’s a totally rational decision that happens to work out in my favor.

I know that setting up the new Mac will be simple. I’ll plug my old one into the new one (I’m getting a firewire cable that’s 400 on one and 800 on the other, and if that doesn’t work, I’ll connect through the ethernet ports) and the new Mac will suck the life force (= my user directories ‘n’ stuff) out of the old one.

What will really take some time is rebuilding my Bootcamp Windows XP partition: Reinstall XP, and reinstall the few apps I use. (I am still using Microsoft Money, waiting for the new version of Quicken for the Mac, which keeps getting postponed.) I’d much rather clone the old Bootcamp partition onto the new machine. So, I looked around and found Bart PE and YouTube instructions for burning a Bart PE boot disk. I believe I now have to make a disk image of my current Windows partition, save it onto a USB hard drive, and then, well, I don’t exactly know, but I’ll figure it out. Maybe.

[Tags: macbook mac windows os_x clone bootcamp ]

Tweet
Follow me

Categories: Uncategorized Tagged with: bootcamp • clone • mac • macbook • os_x • tech • windows Date: August 16th, 2009 dw

5 Comments »

January 14, 2009

Beginner-to-beginner: Restarting Apache after you’ve reinstalled Leopard from the Time Machine and your web server isn’t working

Last night I installed a new, blank hard drive on my MacBook. I installed from Time Machine, which went quite well. (I physically installed it, booted from a Leopard system disk, partitioned the disk via Tools > Disk Utility, restarted with the Time Machine external disk plugged in, went to Tools > Restore from Backup, chose the latest backup, and came back three hours later.) The process resulted in a painless transfer. Everything was working (as far as I can tell) except for the internal web server; my browser told me that it could not connect to http://127.0.0.1. I tried lots of things, including editing my httpd.conf file, following Webby advice (how could I go wrong?). Despite multiple restarts of apache, via Systems Pref and the terminal, no dice. (BTW, I’m running Leopard 10.5.6)

My friend Billo, diagnosed the problem almost immediately: I had no apache2 directory in /var/log/. So, I made one, changed the permissions, and a minute later, it was all up and running. (Thanks, Billo!)

In case you are feeling adventurous, here are the various commands to use in the terminal. (Note: I’m not good at this stuff. I’m likely to be giving you bad advice here. Most of it is pretty much non-destructive, though. I think.)

To restart the web server (=apache2): apachectl restart (Apachectl is in /usr/sbin/)

To create an apache2 directory in /var/log:

cd /var/log/
mkdir apache2
chown root apache2
chmod 755 apache2

It may take a minute or two for things to start working. If they do, when you go to http://127.0.0.1 in your browser, you should get a default page telling you that apache is working. And you’ll probably have to log in as root in the terminal to get permission to do this stuff.

Good luck. And, most important, don’t blame me!

[Tags: mac os_x apache restore_from_time_machine web_server leopard ]

Tweet
Follow me

Categories: Uncategorized Tagged with: apache • leopard • mac • tech Date: January 14th, 2009 dw

2 Comments »

December 5, 2008

Leadership and info: LeWeb pre-interview

I haven’t listend to this (I’m in an Amtrak station riding on some good soul’s free but flaky wifi), but here’s a podcast interview I did a couple of days ago as part of the LeWeb prep ‘n’ PR. I talk sort of about what I’m going to be talking about there, which (unless and until I rewrite it yet again) has something to do with leadership as the age of information ends. In the current draft of my overheads (Yes, I called them “overheads.” I’m old.), the connection seems to be that both the Information Age and leadership as we’ve generally known it assume/create scarcity. When the scarcity goes away, so does the primacy of information and the old idea of leadership.

I’ll try to say more about this as my overheads (Yes, overheads, dammit! And dittos that come from the mimeo machine!) go from draft to locked-in objects of fear and self-loathing. [Tags: leweb leweb2008 leadership information_age abundance overheads mimeo ]

Tweet
Follow me

Categories: Uncategorized Tagged with: abundance • business • digital culture • entertainment • infohistory • leadership • leweb • leweb2008 • mac • media • mimeo • overheads Date: December 5th, 2008 dw

2 Comments »

Next Page »


Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
TL;DR: Share this post freely, but attribute it to me (name (David Weinberger) and link to it), and don't use it commercially without my permission.

Joho the Blog uses WordPress blogging software.
Thank you, WordPress!