Are emoji color preferences stored somewhere on MacOS?

Ascertaining the last color used of a changeable emojis.


Testing under macOS Catalina, when one makes changes within Emoji & Symbols, at least some of these changes are written to:

~/Library/Preferences/com.apple.EmojiPreferences.plist

In Terminal, run:

defaults read com.apple.EmojiPreferences

Then look at the output under EMFSkinToneBaseKeyPreferences, and for the emojis you've shown, it will most likely look like e.g.:

"\\Ud83d\\Udc4c" = "\\Ud83d\\Udc4c\\Ud83c\\Udfff";

While the defaults command is the normal one used with .plist files, nonetheless there is also /usr/libexec/PlistBuddy, and it may be easier in some cases than defaults when trying to retries nested keys.

In this particular use case if gives a visual representation of the emojis color change:

In Terminal:

/usr/libexec/PlistBuddy -c \
"Print :EMFDefaultsKey:EMFSkinToneBaseKeyPreferences" \
~/Library/Preferences/com.apple.EmojiPreferences.plist 
Dict {
    👌 = 👌🏿
} 

The default color of the emojis shows on the left of the equal sign and the last used color shows on the right.

Only changeable emoji that have been previously set from the default color will show, as well as any reset on a given changeable emojis.

As I know you use AppleScript, here is a programmatic solution to retrieving and displaying then information from the EMFSkinToneBaseKeyPreferences key:

Example AppleScript code:

set shellCMD to {¬
    "/usr/libexec/PlistBuddy -c ", ¬
    "'Print :EMFDefaultsKey:EMFSkinToneBaseKeyPreferences' ", ¬
    "~/Library/Preferences/com.apple.EmojiPreferences.plist ", ¬
    "| awk '/=/{sub(/^    /, \"\t\t\t\t\t\", $0); print}'"} ¬
    as string

set lastUsedColors to (do shell script shellCMD)

display dialog ¬
    "Last used color for changable Emoji:" & ¬
    linefeed & linefeed & lastUsedColors ¬
    buttons {"OK"} default button 1 ¬
    with title "Emoji & Symbols"

Displays the following example dialog:

enter image description here



Ascertaining the last used character/emojis/symbol.


On a side note, if one is interested in knowing which was the last used character/emojis/symbol...

There are two keys to look at in the output of the defaults command:

  • EMFRecentSequenceNumberKey
  • EMFUsageHistoryKey

After the use of additional character/emojis and looking at the value of the EMFRecentSequenceNumberKey key in relation to which was the actual character/emojis/symbol last used, the value of the last used character/emojis will be a -1 of its value and will appear in the array for the character/emojis/symbol last used under the EMFUsageHistoryKey key.

As an example, right now the value of the EMFRecentSequenceNumberKey key is 53 and I'm going to double-click the 👌🏿 emojis from Frequently Used in the Character Viewer while in TextEdit and watch for the update to the 👌🏿 array under the EMFUsageHistoryKey key.

The the EMFRecentSequenceNumberKey key went from 53 to 55 while 54 was added to the 👌🏿 array under theEMFUsageHistoryKey key.

Now it a matter of parsing the EMFUsageHistoryKey key to ascertain the value of the array that has the (value of EMFRecentSequenceNumberKey key) - 1 value to determine which was the actual last character/emojis/symbol used.

The following example AppleScript code will ascertain the last used character/emojis symbol from Emoji & Symbols and display as dialog with its results:

set shellCMD to {¬
    "/usr/libexec/PlistBuddy -c ", ¬
    "'Print :EMFDefaultsKey:EMFRecentSequenceNumberKey' ", ¬
    "~/Library/Preferences/com.apple.EmojiPreferences.plist"} ¬
    as string

set searchNumber to (do shell script shellCMD) - 1 as string

set shellCMD to {¬
    "/usr/libexec/PlistBuddy -c ", ¬
    "'Print :EMFDefaultsKey:EMFUsageHistoryKey:' ", ¬
    "~/Library/Preferences/com.apple.EmojiPreferences.plist ", ¬
    "| awk '/Array|", searchNumber, "/{print $1}'"} ¬
    as string

set awkOutput to paragraphs of (do shell script shellCMD)

repeat with i from 1 to count awkOutput
    if item i of awkOutput is equal to searchNumber then
        set lastUsedCharacterEmojisSymbol to ¬
            item (i - 1) of awkOutput
        exit repeat
    end if
end repeat

display dialog ¬
    "The last used character/emojis/symbol was: " & ¬
    lastUsedCharacterEmojisSymbol buttons {"OK"} ¬
    default button 1 with title "Emoji & Symbols"


Displays the following example dialog:

enter image description here