Reboot TP-Link router remotely or automatically

Standard

using cURL or wget, it’s easy to reboot a TP-Link router from a terminal or command line. Put it in a script and schedule it to run automatically if your router overheats or is flaky:

in OSX (using cURL):

curl --user username:password http://192.168.1.1/userRpm/SysRebootRpm.htm?Reboot=Reboot > /dev/null

If you have wget by default instead of cURL (i.e. most *nix):

wget -qO- --user=username --password=password http://192.168.1.1/userRpm/SysRebootRpm.htm?Reboot=Reboot > /dev/null

Replace username and password with the admin username and password of your router. Replace 192.168.1.1 with the IP address of your router.

If you have Windows, with neither of the above, and don’t want to download wget, try using bitsadmin to create a download job.

Run FileBot headless without Dock icon on OSX

Standard

FileBot is a great utility for finding the names and subtitles of downloaded TV shows and movies. I use it as part of a shell script to organise downloaded media files.

Unfortunately, the suggested way to invoke it from the command line is simply to call filebot, e.g. /Applications/FileBot.app/Contents/MacOS/filebot ....

This was causing FileBot to pop up a Java icon in the dock and steal focus, whenever it was invoked which was driving me crazy. Fortunately the solution is simple: Run the FileBot jar directly with the awt.headless set to true. As follows:

java -jar -Djava.awt.headless=true /Applications/FileBot.app/Contents/Resources/java/FileBot.jar ...

No more annoying icon.

How to use Apple bluetooth keyboard with multiple computers via a KVM

Standard

It’s easy to share traditional keyboards between multiple computers using a USB KVM. Obviously, with a bluetooth keyboard, things aren’t so simple.

I wanted to share my Apple bluetooth keyboard between my Mac mini and my desktop computer (running Ubuntu, but this would work with Windows).

First step was to get a USB bluetooth dongle and plug that into the KVM. Any USB dongle should do. When the KVM is switched to the Mac, the bluetooth dongle takes preference over the built-in Mac bluetooth receiver.

This works to share the keyboard, but the keyboard had to be disconnected and re-paired each time the KVM was switched — this is particularly problematic if you need to repair the keyboard at, for example, the login screen. It also requires you to enter a PIN code each time.

Fortunately this can be easily solved by sharing the generated link key between the two computers:

  1. Pair the keyboard in Ubuntu, then in OSX.
  2. In OSX, look at the bluetooth properties for your keyboard device to get the address.vThen open the terminal and type sudo defaults read /private/var/root/Library/Preferences/blued.plist. You will see something like the following:
    {
        LinkKeys =     {
            "00-aa-bb-cc-dd-ee" =         {
                "00-00-00-aa-aa-aa" = <81a83517 cc3c7afc fb8e99fc 5147fbf4>;
            };
        };
    }
    

    Here, the first code is the address of the bluetooth dongle. The second is the address of the keyboard, and the final, longer code is the link key.

  3. Convert the link key into a format suitable for Linux (or Windows), by reversing the endianness; simply reverse the order of the key, taking each pair of hexadecimal numbers as one value. So, the above key would be f4fb4751 fc998efb fc7a3ccc 1735a881. Easy…
  4. Use this link key in Linux or Windows. On Ubuntu the link key is at /var/lib/bluetooth/00:AA:BB:CC:DD:EE/linkkeys — the code is the address of the bluetooth dongle. Edit that file and replace the link key corresponding to the address of the bluetooth keyboard to the converted key, above.
  5. That’s it — restart Ubuntu, and the keyboard will work seamlessly as it is switched by the KVM.
  6. To change the link key in Windows, you need to edit the registry — I didn’t do this, but a search for “Windows bluetooth link key registry” should give the goods.

    Provided the keyboard doesn’t become unpaired, the setup should last indefinitely.