aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/dome-key.in.rb
blob: 736e7a59f9568ea7a3e5b48190ef5dda52687d30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
class DomeKey < Formula
  desc "Control your computer with a pair of headphones"
  homepage "https://domekey.teddywing.com"
  version "${VERSION}"
  url "https://domekey.teddywing.com/downloads/dome-key_${VERSION}.tar.bz2"
  sha256 "${SHA256}"

  # Rust code requires at least 10.7
  depends_on :macos => :lion if MacOS::Version::SYMBOLS.has_key?(:lion)

  def minimum_os
    return "" if MacOS::Version::SYMBOLS.has_key?(:lion)

    <<~EOS
      DomeKey requires Mac OS X 10.7 Lion or later.

    EOS
  end

  def install
    bin.install "dome-key"
    man1.install "dome-key.1"
    man7.install "dome-key-mappings.7"
  end

  def plist_name
    "com.teddywing.dome-key"
  end

  def caveats; <<~EOS
    #{minimum_os}To get started with a set of mappings, try running the these commands:

        mkdir -p $$HOME/.config/dome-key
        cat <<EOM > $$HOME/.config/dome-key/mappings.dkmap
        map <Play> <Nop>

        mode <Play><Play> {
            map <Up> <Left>
            map <Play> <Space>
            map <Down> <Right>
        }
        EOM

    If `dome-key` is already running, load the new mappings:

        dome-key --reload-mappings
  EOS
  end

  plist_options :manual => "dome-key --daemon --audio"

  def plist; <<~EOS
${PLIST}
  EOS
  end
end