Mac M1/M2: Keyboard Brightness Keys + Remap § to ~

I recently moved from the US layout to the UK layout for my shiny new MacBook Air M2. I’d get used to the keys, however, my work MacBook is still on the US layout. Therefore, I decided to:

  1. Remap the section key § to tilde/back-tick (I use the tilde and back tick keys a lot)
  2. Remap the original tilde key to the left shift, so that I don’t accidentally hit the tilde in the wrong place
  3. Bring back the keyboard brightness keys by remapping the Siri (F5) + DND keys (F6)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.judepereira.keyremapping</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/hidutil</string>
<string>property</string>
<string>–set</string>
<string>{"UserKeyMapping":[
{
"HIDKeyboardModifierMappingSrc": 0xC000000CF,
"HIDKeyboardModifierMappingDst": 0xFF00000009
},
{
"HIDKeyboardModifierMappingSrc": 0x10000009B,
"HIDKeyboardModifierMappingDst": 0xFF00000008
},
{
"HIDKeyboardModifierMappingSrc": 0x700000064,
"HIDKeyboardModifierMappingDst": 0x700000035
},
{
"HIDKeyboardModifierMappingSrc": 0x700000035,
"HIDKeyboardModifierMappingDst": 0x7000000E1
}
]}</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>

Save the contents above to ~/Library/LaunchAgents/com.judepereira.keyremapping.plist, and logout/login :)

That’s all!

Credits

A letter to Tim Cook regarding iOS 10, with love for Apple

Tim, iOS has always been known for it’s user interface, until recently. Your new take on notifications have not only made them very loud, and unsettling, but do not flow with the entire look and feel of Apple:

No Mr. Tim, no. My notifications will not be waiting for me. They're crying out for my attention.

No Mr. Tim, no. My notifications aren’t waiting for me. They’re crying out for my attention.
 

See that white background? While you’ve done a good job of highlighting the content, it breaks continuity. There was nothing wrong to start with. The way notifications used to render on my iPhone was simply perfect! The content did not need to be highlighted the way you’ve done so in iOS 10. I really loved iOS for not cluttering my life, and making it simpler, compared to Android (the new style does look like inspiration from Android, doesn’t it?).

Comparing this to iOS 9, what you’ve lost is absolute ingenuity:

Yes Tim, the beauty of your beloved platform has been lost, and Steve is waiting for you.

See? Nothing was ever wrong.
 

I’ve been using the beta version of iOS 10 for a little more than a few hours now, and the Today screen has also been ruined. Oh! I almost forgot – what you’ve done to the control centre is horrible. Do you know what this reminds me of? It reminds me of the Red Wedding – Lord Bolton murdering the King of the North, Robb Stark. That was truly gruesome, wasn’t it?

Tim, iOS 9 was the epitome of creation.

I truly hope that this letter talks solely about iOS 10 preview, and that it doesn’t speak for iOS 10 final.

 

Sincerely,
Jude

Sending notifications via Apple’s new HTTP/2 API (using Jetty 9.3.6)

HTTP/2 is still very much new to Java, and as such, there are just two libraries who support it – Jetty (from 9.3), and Netty (in alpha). If you’re going the Jetty way (as I have), you’ll need to add their ALPN library to your boot classpath.

Note: Jetty 9.3.x requires the use of Java 8.

A full library for this is available here, on GitHub.

Here’s a quick example:


package com.judepereira.jetty.apns.http2;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.client.api.Request;
import org.eclipse.jetty.client.util.StringContentProvider;
import org.eclipse.jetty.http2.client.HTTP2Client;
import org.eclipse.jetty.http2.client.http.HttpClientTransportOverHTTP2;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import java.io.FileInputStream;
import java.security.KeyStore;
public class Main {
public static void main(String[] args) throws Exception {
HTTP2Client http2Client = new HTTP2Client();
http2Client.start();
KeyStore ks = KeyStore.getInstance("PKCS12");
// Ensure that the password is the same as the one used later in setKeyStorePassword()
ks.load(new FileInputStream("MyProductionOrDevelopmentCertificate.p12"), "".toCharArray());
SslContextFactory ssl = new SslContextFactory(true);
ssl.setKeyStore(ks);
ssl.setKeyStorePassword("");
HttpClient client = new HttpClient(new HttpClientTransportOverHTTP2(http2Client), ssl);
client.start();
// Change the API endpoint to api.development.push.apple.com if you're using a development certificate
Request req = client.POST("https://api.push.apple.com")
// Update your :path "/3/device/<your token>"
.path("/3/device/b2482deaf55521b2ccd755d5817a39784cc0044e24s3523a4708c2fa08983bdf")
.content(new StringContentProvider("{ \"aps\" : { \"alert\" : \"Hello\" } }"));
ContentResponse response = req.send();
System.out.println("response code: " + response.getStatus());
// The response body is empty for successful requests
System.out.println("response body: " + response.getContentAsString());
}
}

view raw

Main.java

hosted with ❤ by GitHub