Skip to content

Commit

Permalink
Move plist template to remap.py
Browse files Browse the repository at this point in the history
  • Loading branch information
veehaitch committed Feb 7, 2021
1 parent 7b88c7b commit 0366433
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
17 changes: 0 additions & 17 deletions launchd-template.plist

This file was deleted.

25 changes: 21 additions & 4 deletions remap.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@
import re
import os

LAUNCHD_TEMPLATE = """\
<?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>ch.veehait.macos-remap-keys</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/hidutil</string>
<string>property</string>
<string>--set</string>
<string>{property}</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
"""

def filepath(string):
if os.path.exists(string):
return string
Expand Down Expand Up @@ -59,10 +79,7 @@ def create_property(


def launchd_definition(hidutil_property: str, outpath: str) -> str:
with open("./launchd-template.plist", "r") as f:
template = f.read()

res = template.replace("$REPLACEME$", hidutil_property)
res = LAUNCHD_TEMPLATE.format(property=hidutil_property)
with open(outpath, "w") as f:
f.write(res)

Expand Down

0 comments on commit 0366433

Please sign in to comment.