hjuutilainen / dotfiles Goto Github PK
View Code? Open in Web Editor NEWMy dotfiles and OS X settings
My dotfiles and OS X settings
Hi there, I am writing a bash script to switch between my native and external keyboard. It happens a lot that I need to take my laptop somewhere and I forget to change the keyboards manually. I have a native French keyboard (AZERTY) and an external US International keyboard (QWERTY). You see, the French native was a mistake...
I stumbled upon your Keyboard Preferences in
dotfiles/bin/macos-system-defaults.sh, lines 100 - 112
Let's say I want to switch to the native keyboard, which is a French-numerical layout with ID 1111. Therefore I run:
defaults write ~/Library/Preferences/com.apple.HIToolbox AppleCurrentKeyboardLayoutInputSourceID "com.apple.keylayout.French-numerical"
defaults write ~/Library/Preferences/com.apple.HIToolbox AppleDefaultAsciiInputSource -dict InputSourceKind "Keyboard Layout" "KeyboardLayout ID" -int 1111 "KeyboardLayout Name" French-numerical
# Delete the default layouts
defaults delete ~/Library/Preferences/com.apple.HIToolbox AppleEnabledInputSources
# Enable French-numerical layout
defaults write ~/Library/Preferences/com.apple.HIToolbox AppleEnabledInputSources -array '{ InputSourceKind = "Keyboard Layout"; "KeyboardLayout ID" = 1111; "KeyboardLayout Name" = French-numerical; }'
defaults write ~/Library/Preferences/com.apple.HIToolbox AppleInputSourceHistory -array '{ InputSourceKind = "Keyboard Layout"; "KeyboardLayout ID" = 1111; "KeyboardLayout Name" = French-numerical; }'
defaults write ~/Library/Preferences/com.apple.HIToolbox AppleSelectedInputSources -array '{ InputSourceKind = "Keyboard Layout"; "KeyboardLayout ID" = 1111; "KeyboardLayout Name" = French-numerical; }'
I can check this simply with
defaults read ~/Library/Preferences/com.apple.HIToolbox
{
AppleCurrentKeyboardLayoutInputSourceID = "com.apple.keylayout.French-numerical";
AppleDefaultAsciiInputSource = {
InputSourceKind = "Keyboard Layout";
"KeyboardLayout ID" = 1111;
"KeyboardLayout Name" = "French-numerical";
};
AppleDictationAutoEnable = 1;
AppleEnabledInputSources = (
{
InputSourceKind = "Keyboard Layout";
"KeyboardLayout ID" = 1111;
"KeyboardLayout Name" = "French-numerical";
}
);
AppleGlobalTextInputProperties = {
TextInputGlobalPropertyPerContextInput = 0;
};
AppleInputSourceHistory = (
{
InputSourceKind = "Keyboard Layout";
"KeyboardLayout ID" = 1111;
"KeyboardLayout Name" = "French-numerical";
}
);
AppleSelectedInputSources = (
{
InputSourceKind = "Keyboard Layout";
"KeyboardLayout ID" = 1111;
"KeyboardLayout Name" = "French-numerical";
}
);
}
However, when I am pressing keys, the keyboard is still on QWERTY, the US layout. And I do get the same error (no layout switch) when I just use your code and try to set the keyboard layout to Finnish. Any ideas?
My laptop is a MacBook Pro (2015) running macOS Mojave 10.14.6
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.