Skip to content
Random scripts
Python Shell
Branch: master
Clone or download
Pull request Compare This branch is even with philipbel:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

After creating a custom [1] keyboard layout with Ukelele, I wanted it to match the original layout's icon. It turns out that OS X stores the country flags in /System/Library/Keyboard Layouts/AppleKeyboardLayouts.bundle/Contents/Resources/AppleKeyboardLayouts-L.dat.

I don't know the exact structure of that file, but the icons are simply there (look for icns in hex, i.e. 0x69636e73). is a quick and dirty script the exracts the icons (icns files) from the above file and writes them to the specified output directory.

[1] Not really custom. OS X doesn't support the БДС 5237-2005 Bulgarian phonetic layout (GNU/Linux does).

Sample usage

% mkdir /tmp/icons
% ./ -o /tmp/icons
./ Reading /System/Library/Keyboard Layouts/AppleKeyboardLayouts.bundle/Contents/Resources/AppleKeyboardLayouts-L.dat
./ Writing icon file /tmp/icons/icon1.icns
./ Writing icon file /tmp/icons/icon2.icns
./ Writing icon file /tmp/icons/icon3.icns
./ Writing icon file /tmp/icons/icon132.icns


Ipernity download script (uses their Shell API).


usage: [-h] [-v] --key KEY --secret SECRET -o OUTPUT

optional arguments:
  -h, --help            show this help message and exit
  -v, --verbose         Be verbose
  --key KEY             Ipernity API key
  --secret SECRET       Ipernity API secret
  -o OUTPUT, --output OUTPUT
                        Download output directory
You can’t perform that action at this time.