aboutsummaryrefslogtreecommitdiffstats
path: root/HomebrewFormula/dome-key.rb
blob: 7a5c106e016ddda50666b7e605fc6b2948a20fba (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
class DomeKey < Formula
  desc "Control your computer with a pair of headphones"
  homepage "https://domekey.teddywing.com"
  version "1.0"
  url "https://domekey.teddywing.com/downloads/dome-key_1.0.tar.bz2"
  sha256 "03fd038e1ae67ce1fce949d2d5fcafb50bbee2f4344b71c16577929c557718a1"

  # 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
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
    	"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    	<key>Label</key>
    	<string>com.teddywing.dome-key</string>
    	<key>ProgramArguments</key>
    	<array>
    		<string>/usr/local/bin/dome-key</string>
    		<string>--daemon</string>
    		<string>--audio</string>
    	</array>
    	<key>RunAtLoad</key>
    	<true/>
    	<key>KeepAlive</key>
    	<true/>
    	<key>StandardErrorPath</key>
    	<string>/tmp/dome-key.log</string>
    </dict>
    </plist>
  EOS
  end
end