Skip to content

Instantly share code, notes, and snippets.

@jk
Created February 15, 2025 15:53
Show Gist options
  • Save jk/0b3b3ed5e30d98bfe42b27ce8676af4c to your computer and use it in GitHub Desktop.
Save jk/0b3b3ed5e30d98bfe42b27ce8676af4c to your computer and use it in GitHub Desktop.
RWTH USGerman Keyboard Layout via Homebrew
brew create "https://hci.rwth-aachen.de/get-attachment/2764?fallback=/files/migrated/files/USGerman-Keyboard-Layout-0.98-Retina.zip&filename=USGerman%20Keyboard%20Layout%200.98%20Retina.zip" --set-name usgerman-keyboard-layout
brew uninstall usgerman-keyboard-layout
brew install --build-from-source /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/u/usgerman-keyboard-layout.rb
# Documentation: https://docs.brew.sh/Formula-Cookbook
# https://rubydoc.brew.sh/Formula
# PLEASE REMOVE ALL GENERATED COMMENTS BEFORE SUBMITTING YOUR PULL REQUEST!
class UsgermanKeyboardLayout < Formula
desc "USGerman Keyboard Layout for macOS"
homepage "https://hci.rwth-aachen.de/usgermankeyboard"
url "https://hci.rwth-aachen.de/get-attachment/2764?fallback=/files/migrated/files/USGerman-Keyboard-Layout-0.98-Retina.zip&filename=USGerman%20Keyboard%20Layout%200.98%20Retina.zip"
sha256 "3d6f420185a7b104da45411c0a380d342606d3b20281984b30cac59fbae8fb39"
version "0.98"
def install
# TISInputSourceID and TISIntendedLanguage are required for macOS 14.2 and later
system "/usr/libexec/PlistBuddy", "-c", "Add :TISInputSourceID string com.apple.keyboardlayout.roman.roman", "Roman.bundle/Contents/Info.plist"
system "/usr/libexec/PlistBuddy", "-c", "Add :TISIntendedLanguage string en-US", "Roman.bundle/Contents/Info.plist"
prefix.install "Roman.bundle"
(prefix/"postinstall.sh").write <<~EOS
#!/bin/bash
sudo cp -R #{prefix}/Roman.bundle /Library/Keyboard\\ Layouts/
EOS
chmod 0755, prefix/"postinstall.sh"
ohai "You NEED to run '#{prefix}/postinstall.sh' to install the keyboard system-wide."
end
def caveats
<<~EOS
The USGerman Keyboard Layout has been installed.
You may need to log out and back in again or restart your system to activate the new layout.
Then go to System Settings > Keyboard > Text Input > Input Sources > + > Others > U.S. With Umlauts via Option Key to add the new layout.
EOS
end
test do
assert_predicate "/Library/Keyboard Layouts/Roman.bundle", :exist?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment