mirrorboard-mac/toggle_profiles.pl

13 lines
600 B
Perl
Raw Normal View History

2018-02-13 23:47:04 +01:00
local $/; # black magic — don't remove
open(FILE, "<:encoding(UTF-8)", "/Users/YOUR_USERNAME/.config/karabiner/karabiner.json") or die "Can't open file";
$string = <FILE>;
close FILE;
$string =~ /"name": "YOUR_MIRRORING_KARABINER_PROFILE_NAME_REGEX_READABLE",\n *"selected": (.*),/m;
if($1 eq 'false'){
`'/Library/Application Support/org.pqrs/Karabiner-Elements/bin/karabiner_cli' --select-profile 'YOUR_MIRRORING_KARABINER_PROFILE_NAME'`}
if($1 eq 'true'){
`'/Library/Application Support/org.pqrs/Karabiner-Elements/bin/karabiner_cli' --select-profile 'YOUR_DEFAULT_KARABINER_PROFILE_NAME'`}