Skip to content

Commit

Permalink
Homebrew — convert formula to cask
Browse files Browse the repository at this point in the history
See the PR to the upstream repository: Homebrew/homebrew-cask#128508
  • Loading branch information
devnoname120 committed Jul 24, 2022
1 parent d52870e commit 16d1e13
Showing 1 changed file with 23 additions and 31 deletions.
54 changes: 23 additions & 31 deletions mac/homebrew/qwerty-fr.rb
@@ -1,40 +1,32 @@
class QwertyFr < Formula
desc "Qwerty keyboard layout with French accents"
homepage "https://qwerty-fr.org"
url "https://github.com/qwerty-fr/qwerty-fr/releases/download/v0.7/qwerty-fr_0.7_mac.zip"
cask "qwerty-fr" do
version "0.7"
sha256 "34bc8c8f764798ed7e48a3f2404319e09a6d8bfcbef350b25df32387a3199bfa"
license "MIT"

def install
# Homebrew automatically extracts the folder inside the archive to the cur directory (not configurable)
# so we need to rebundle it
mkdir "qwerty-fr.bundle"
mv "Contents", "qwerty-fr.bundle/"
prefix.install "qwerty-fr.bundle"
end

def caveats
<<~EOS
1) Finishing the installation
To globally install the layout, you need to manually link the layout bundle (only once):
sudo ln -sf '#{prefix}/qwerty-fr.bundle' '/Library/Keyboard Layouts/'
url "https://github.com/qwerty-fr/qwerty-fr/releases/download/v#{version}/qwerty-fr_#{version}_mac.zip",
verified: "github.com/qwerty-fr/qwerty-fr/"
name "qwerty-fr keyboard layout"
desc "QWERTY-based layout. Type EU languages, greek, math, currencies, & more!"
homepage "https://qwerty-fr.org/"

If you only want to only install the layout for the current user, do the following instead:
ln -sf '#{prefix}/qwerty-fr.bundle' '~/Library/Keyboard Layouts/'
depends_on macos: ">= :sierra"

artifact "qwerty-fr.bundle", target: "/Library/Keyboard Layouts/qwerty-fr.bundle"

2) Restart your system (dead keys don't work properly before restarting).
3) You can then enable the qwerty-fr layout by doing the following:
a) Open "System Preferences" → "Keyboard" → "Input Source".
b) Click on "+" → Search for "qwerty-fr" → Click on "Add".
c) Click on the layout selection icon in the menu bar of macOS and choose "qwerty-fr"
EOS
postflight do
# clear the layout cache before new layouts are recognized
system_command "/bin/rm",
args: ["-f", "--", "/System/Library/Caches/com.apple.IntlDataCache.le*"],
sudo: true
end

test do
system "false"
uninstall delete: [
"/Library/Keyboard Layouts/qwerty-fr.bundle/",
"/Library/Caches/com.apple.IntlDataCache*",
"/System/Library/Caches/com.apple.IntlDataCache.le*",
"/private/var/folders/*/*/-Caches-/com.apple.IntlDataCache.le*",
]

caveats do
reboot
end
end

0 comments on commit 16d1e13

Please sign in to comment.