Docker Compose を使って WordPress、MySQL、phpMyAdmin、WP-CLI のローカル環境の構築

2023/03/28(Tue) 19:31:54
以前、知人から WordPress の使い方を教えて欲しいと相談があったので、さくらインターネットに WordPress をインストールしてブログを始めました。その時、知人がカスタムドメインを利用していました。お名前.com で .com ドメインの1年間の更新料金を調べてみると1287円 ~ と安いのに驚きました。1個目の登録料金は0円なので 2022/08/06(Sat) に購入してみました。そのまま塩漬けにしていたのですが、試しに iCloud+ のカスタムメールドメインに設定してみました。次回のブログに書きたいと思います。

お名前.com に500円のクーポンを貰ったので、.jp ドメインを登録してみました。お名前.com にログインして、.jp ドメインの1年間の更新料金を調べてみると 3686円でした。予想した価格と違ったので、自動更新は解除しています。

.com ドメインは所有したいので、下記のように1年間更新してみました。
.net ドメインにも興味があったので、更に登録してみました。.com ドメインを更新したおかげか、登録料は無料でした。1年間の更新料金も妥当なので保持するつもりです。

また、メールとサイトのドメインを分離して運用しようと思っています。

2023/03/28(Tue) 19:33:04
お名前.com サイトに表示されている1年間の更新料金目安

更新料金
.com
1,287円~

.net
1,507円~

.jp
1,276円~

2023/03/28(Tue) 19:33:04
実際の1年間のドメイン更新料金

kyoshiaki.com
ドメイン更新1年		1,408 円 (税込)
Whois情報公開代行		0円 (税込)
サービス維持調整費 ※	253 円 (税込)
お支払い金額		1,661 円 (税込)

kyoshiaki.net
ドメイン更新1年		1,628 円 (税込)
Whois情報公開代行		0円 (税込)
サービス維持調整費 ※	293 円 (税込)
お支払い金額		1,921 円 (税込)

kyoshiaki.jp
ドメイン更新1年		3,124 円 (税込)
Whois情報公開代行		0円 (税込)
サービス維持調整費 ※	562 円 (税込)
お支払い金額		3,686 円 (税込)

さくらインターネットに公開している WordPress やホームページを購入したカスタムドメインに変更しようと模索していました。

一度公開した WordPress サイトのドメインを変更することは、難易度が高そうですが、さくらインターネットの WordPress サイトを Docker 上に再現し、WP-CLI を使ってデータベースを書き換えてみた結果、上手くいきそうです。

大惨事になる可能性もありますが!

2023/03/28(Tue) 19:35:06
kyoshiaki/docker-compose-wordpress: Docker Compose を使って WordPress、MySQL、phpMyAdmin、WP-CLI のローカル環境の構築
https://github.com/kyoshiaki/docker-compose-wordpress

2023/03/28(Tue) 19:35:45
WP-CLI | WP-CLI
https://wp-cli.org/

ドメイン変更の検証のために、上記 URL で公開している docker-compose.yml に WP-CLI を下記 URL を参考に追加してみました。

2023/03/28(Tue) 19:36:40
WP-CLIのDocker公式イメージ「wordpress:cli」の使い方 | SIOS Tech. Lab
https://tech-lab.sios.jp/archives/25369

M2 Pro Mac mini (2023) でコマンド docker-compose up -d を実行すると下記エラーが出るので、

❯ docker-compose up -d

[+] Running 0/1
 ⠙ db Pulling                                                                                                                                                                  3.1s
no matching manifest for linux/arm64/v8 in the manifest list entries

docker-compose.yml ファイルの image: mysql:5.7 を image: mysql:latest に変更しました。

===== docker-compose.yml =====

version: '3.3'

services:
  db:
    image: mysql:5.7

↓

version: '3.3'

services:                                                             
  db:                                                                 
    image: mysql:latest    

通常、WP-CLI をインストールし、WordPress のデーターベースを wp コマンドを使って変更することになります。

さくらインターネットでの場合、WP-CLI コマンド wp はあらかじめインストールされています。

さくらインターネットに ssh ログインし、WordPress のディレクトリに移動した後、下記のように wp コマンドを実行するだけです。

下記例、wp db search kyoshiaki.sakura.ne.jp コマンドは、データーベースに、文字列 kyoshiaki.sakura.ne.jpが含まれるレコードを表示しています。

=== ssh ===

% cd wp

% pwd
/xxxx/xxxx/wp

% ls
index.php               wp-cron.php
license.txt             wp-includes
readme.html             wp-links-opml.php
wp-activate.php         wp-load.php
wp-admin                wp-login.php
wp-blog-header.php      wp-mail.php
wp-cli.local.yml        wp-settings.php
wp-comments-post.php    wp-signup.php
wp-config-sample.php    wp-trackback.php
wp-config.php           xmlrpc.php
wp-content

% wp db search kyoshiaki.sakura.ne.jp

wpxxxxxacomments:comment_author_url
8:http://kyoshiaki.sakura.ne.jp/osx/index.html
wpxxxxxaoptions:option_value
1:https://kyoshiaki.sakura.ne.jp/wp
wpxxxxxaoptions:option_value
2:https://kyoshiaki.sakura.ne.jp/wp
wpxxxxxaoptions:option_value
408:}}s:16:"background_image";s:84:"https://kyoshiaki.sakura.ne.jp/wp/wp-content/uploads/2020/12/advent-57
wpxxxxxaoptions:option_value
410:;s:17:"top_slide_image_1";s:91:"https://kyoshiaki.sakura.ne.jp/wp/wp-content/themes/lightning/assets/i [...] ;s:17:"top_slide_image_2";s:91:"https://kyoshiaki.sakura.ne.jp/wp/wp-content/themes/lightning/assets/i [...] g";s:15:"top_slide_url_2";s:33:"https://kyoshiaki.sakura.ne.jp/wp";s:22:"top_slide_text_title_2";s:18:
wpxxxxxaoptions:option_value

︙

wpxxxxxaposts:guid
1322:https://kyoshiaki.sakura.ne.jp/wp/?p=1322
wpxxxxxaposts:guid
1323:https://kyoshiaki.sakura.ne.jp/wp/?p=1323
wpxxxxxaposts:guid
1324:https://kyoshiaki.sakura.ne.jp/jwp/?p=1324
2023/03/28(Tue) 19:39:17
kyoshiaki/docker-compose-wordpress: Docker Compose を使って WordPress、MySQL、phpMyAdmin、WP-CLI のローカル環境の構築
https://github.com/kyoshiaki/docker-compose-wordpress

上記に公開した docker-compose.yml の場合、

2023/03/28(Tue) 19:40:40
wordpress - Official Image | Docker Hub
https://hub.docker.com/_/wordpress

2023/03/28(Tue) 19:41:14
wordpress/Dockerfile at 809519cc86bee0d6c7f2743976a850267983e2c2 · docker-library/wordpress
https://github.com/docker-library/wordpress/blob/809519cc86bee0d6c7f2743976a850267983e2c2/cli/php8.2/alpine/Dockerfile

ENTRYPOINT ["docker-entrypoint.sh"]
USER www-data
CMD ["wp", "shell"]

WP-CLI コンテナは、実行されると上記 Dockerfile の CMD [“wp”, “shell”] より、wp コマンドをシェルモードで起動します。

CMD 命令の詳細は、下記ページを参考にしてください。

2023/03/28(Tue) 19:42:07
Dockerfile reference
https://docs.docker.com/engine/reference/builder/

CMD

The CMD instruction has three forms:

・CMD [“executable”,”param1″,”param2″] (exec form, this is the preferred form)
・CMD [“param1″,”param2”] (as default parameters to ENTRYPOINT)
・CMD command param1 param2 (shell form)
There can only be one CMD instruction in a Dockerfile. If you list more than one CMD then only the last CMD will take effect.

The main purpose of a CMD is to provide defaults for an executing container. These defaults can include an executable, or they can omit the executable, in which case you must specify an ENTRYPOINT instruction as well.

If CMD is used to provide default arguments for the ENTRYPOINT instruction, both the CMD and ENTRYPOINT instructions should be specified with the JSON array format.

CMD
=== docker-compose.yml ===

version: '3.3' 

services:
  db:
    image: mysql:latest
    volumes:
      - db_data:/var/lib/mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: somewordpress
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: wordpress

  wordpress:
    depends_on:
      - db
    image: wordpress:latest
    ports:
      - "8000:80"

︙

 cli:
    image: wordpress:cli
    container_name: cli
    volumes_from: 
      - wordpress
    depends_on:
      - db
      - wordpress
    command: "--info"
    user: xfs
    environment:
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: wordpress
      WORDPRESS_DB_NAME: wordpress
      WORDPRESS_TABLE_PREFIX: wp_

volumes:
  db_data: {}

デフォルトだと上記 docker-compose.yml の cli コンテナの command: “–info” より、シェルモードで立ち上がっている wp に引数 –info が渡されます。

データベースを書き換えるには、docker-compose コマンドで cli コンテナを削除して、wp コマンドの引数を渡し、cli コンテナを再作成して起動させます。

❯ docker-compose run --rm cli search-replace 'Hello world' 'Welcome WordPress' 

上記 docker-compose コマンドを実行すると下記結果より、データベースのテーブル wp_posts、カラム post_title の ‘Hello world’ の文字列が1箇所 ‘Welcome WordPress’ に変更されています。

❯ docker-compose run --rm cli search-replace 'Hello world' 'Welcome WordPress' 

[+] Running 2/0
 ⠿ Container docker-compose-wordpress-db-1         Running                                                                                                                     0.0s
 ⠿ Container docker-compose-wordpress-wordpress-1  Running                                                                                                                     0.0s
+------------------+-----------------------+--------------+------+
| Table            | Column                | Replacements | Type |
+------------------+-----------------------+--------------+------+
| wp_commentmeta   | meta_key              | 0            | SQL  |
| wp_commentmeta   | meta_value            | 0            | SQL  |
| wp_comments      | comment_author        | 0            | SQL  |
︙
| wp_posts         | post_title            | 1            | SQL  |
︙
| wp_users         | display_name          | 0            | SQL  |
+------------------+-----------------------+--------------+------+
Success: Made 1 replacement.

WP-CLI コマンドの詳細については、下記ページの ‘お手軽 Docker コマンド起動 Ruby スクリプト docker.rb の WP-CLI コマンド’ を参照してください。

2023/03/28(Tue) 19:46:11
kyoshiaki/docker-compose-wordpress: Docker Compose を使って WordPress、MySQL、phpMyAdmin、WP-CLI のローカル環境の構築
https://github.com/kyoshiaki/docker-compose-wordpress#readme

2023/03/28(Tue) 19:46:34
kyoshiaki/docker-compose-wordpress: Docker Compose を使って WordPress、MySQL、phpMyAdmin、WP-CLI のローカル環境の構築
https://github.com/kyoshiaki/docker-compose-wordpress#%E3%81%8A%E6%89%8B%E8%BB%BD-docker-%E3%82%B3%E3%83%9E%E3%83%B3%E3%83%89%E8%B5%B7%E5%8B%95-ruby-%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%97%E3%83%88-dockerrb-%E3%81%AE-wp-cli-%E3%82%B3%E3%83%9E%E3%83%B3%E3%83%89
2023/03/28(Tue) 19:47:01
kyoshiaki/docker-compose-wordpress: Docker Compose を使って WordPress、MySQL、phpMyAdmin、WP-CLI のローカル環境の構築
https://github.com/kyoshiaki/docker-compose-wordpress

上記の docker-compose.yml とお手軽 Docker コマンド起動 Ruby スクリプト docker.rb を利用すれば、気軽にデータベースを変更できます。
失敗しても、docker-compose down を実行した後、忘れずに Volume を docker.rb の 6番、docker volume rm docker-compose-wordpress_db_data を使用して削除すれば、docker-compose up -d で何度でも WordPress のインストールから、やり直せます。

Mac で Karabiner-Elements を使ってファンクションキーにショートカットキー Ctrl + C を割り当てる方法

ロジクール マウス MX Master 3 を愛用しているのですが、macOS Monterey バージョン 12.1 にしてから、ホイールの挙動がおかしいので、純正マウスに戻すことにしました。

但し、アプリ毎に MX Master 3 の Back/forward ボタンにキーを割り当てています。

特に ターミナルで Back/forward ボタンにショートカットキー Ctrl + C を割り当てていました。

これがないと不便なので、カスタムキーボードなどを導入しようかと思ったのですが、キーボードのファンクションキーに割り当ててみることにしました。

2022/03/21(Mon) 12:38:36
Macでアプリケーションのキーボードショートカットを作成する - Apple サポート (日本)
https://support.apple.com/ja-jp/guide/mac-help/mchlp2271/12.0/mac/12.0

macOS 純正の機能では、アプリケーションのメニュータイトルをショートカットキーに割り当てることができます。

欲しい機能は、ファンクションキー f1 を押すと Ctrl + C を押したことになる動作です。即ち、特定のキーを押すと違うキー操作を実行するようにしたいのですが、アプリケーションのメニュータイトルをショートカットキーに割り当てることでは実現できません。

ちょうど US 配列キーボードを使っているので、Karabiner-Elements にお世話になっていました。

2022/03/21(Mon) 12:37:23
Karabiner-Elements
https://karabiner-elements.pqrs.org/
2022/03/21(Mon) 12:40:22
Use more complex rules | Karabiner-Elements
https://karabiner-elements.pqrs.org/docs/manual/configuration/configure-complex-modifications/

2022/03/21(Mon) 12:40:59
Karabiner-Elements complex_modifications rules
https://ke-complex-modifications.pqrs.org/

Table of Contents
	▼International (Language Specific)
		▼For Japanese (日本語環境向けの設定) (rev 6)
			▼コマンドキーを単体で押したときに、英数・かなキーを送信する。(左コマンドキーは英数、右コマンドキーはかな) (rev 3)

2022/03/21(Mon) 12:41:31
JSON ソース
https://ke-complex-modifications.pqrs.org/json/japanese.json

普段は、上記 Complex Modifications サイトから日本語キーバインド設定ファイル(左コマンドキーは英数、右コマンドキーはかな)をダウンロードして、英数が左コマンドキーに設定されている機能を左オプションキーに変更して使っています。

ファンクションキーの設定は、 /アプリケーション/Karabiner-Elements.app の Function keys タブで変更できますが、カスタマイズしたいので、下記 Complex Modifications サイトから

2022/03/21(Mon) 12:43:29
Karabiner-Elements complex_modifications rules
https://ke-complex-modifications.pqrs.org/

Table of Contents
	▼Modifier Keys
		▼Change Command_R Key (Right Command)
			▼Post Escape if Command_R is pressed alone.
2022/03/21(Mon) 12:44:16
JSON ソース
https://ke-complex-modifications.pqrs.org/json/change_command_l.json

Post Escape if Command_R is pressed alone. を雛形にして、ファンクションキー f1 を入力すると Ctrl + C に変更する設定ファイルを作成してみました。

2022/03/21(Mon) 13:38:48
KeyBinding.zip
https://kyoshiaki.sakura.ne.jp/blog/KeyBinding.zip

良かったら、上記リンクからダウンロードして利用してください。

使用方法は、ダウンロードした KeyBinding.zip ファイルを Finder で展開し、下記の作成されたファイルから

KeyBinding
|--ReadMe.txt
|--control_break_keybindings.json
|--bathyscaphe_and_terminal_key_bindings.json
|--japanese_option_eisuu_key_bindings.json
|--open_complex_modifications.sh
|--open_complex_modifications.scpt
|--Mac で Karabiner-Elements を使ってファンクションキーにショートカットキー Ctrl + C を割り当てる方法 – KOYAMA Yoshiaki のブログ – WordPres….webloc
|--Mac で Karabiner-Elements を使ってファンクションキーにショートカットキー Ctrl + C を割り当てる方法 – KOYAMA Yoshiaki のブログ – WordPres.url
|--LICENSE.txt

自分が使用したい拡張子が json の設定ファイルを $HOME/.config/karabiner/assets/complex_modifications/ フォルダにコピーしてください。

ターミナルで KeyBinding.zip を展開したいフォルダに移動し、

2022/03/21(Mon) 13:40:59
$ cd KeyBinding
$ ./open_complex_modifications.sh

上記のように open_complex_modifications.sh を実行すると $HOME/.config/karabiner/assets/complex_modifications/ フォルダをFinder で開くことができます。

また、KeyBinding.zip ファイルを展開して作成された KeyBinding フォルダに含まれるアップルスクリプト open_complex_modifications.scpt ファイルをダブルクリックするとスクリプトエディタが開くので、右上の実行ボタン (▶ アイコン) をクリックすると同じく $HOME/.config/karabiner/assets/complex_modifications/ フォルダを Finder で表示できます。

ファンクションキー f1 にショートカットキーCtrl + C を割り当てたいなら、control_break_keybindings.json ファイルを $HOME/.config/karabiner/assets/complex_modifications/ フォルダにコピーしてください。

2022/03/21(Mon) 13:41:48
Use more complex rules | Karabiner-Elements
https://karabiner-elements.pqrs.org/docs/manual/configuration/configure-complex-modifications/

後は、上記サイトのように /アプリケーション/Karabiner-Elements.app を起動し、下図のように Complex Modifications タブ > Rules タブ > Add rule ボタンをクリックしてください。

Add rule

下図から “無条件に f1 キーを押すと Control + C を送信する。(rev 0)” の ‘+ Enable’ ボタンをクリックして有効にしてください。

Enable
“無条件に f1 キーを押すと Control + C を送信する。(rev 0)”

上図のように表示されれば、これで f1 キーの入力を Ctrl + C に変更できます。

しかし、自分の好みのショートカットキーを登録したくなると思います。

2022/03/21(Mon) 13:46:25
External JSON generators | Karabiner-Elements
https://karabiner-elements.pqrs.org/docs/json/external-json-generators/

2022/03/21(Mon) 13:46:50
yqrashawn/GokuRakuJoudo: config karabiner with ease
https://github.com/yqrashawn/GokuRakuJoudo#usage

2022/03/21(Mon) 13:47:16
Goku は、拡張子 clj より Closure で作られている。
GokuRakuJoudo/tutorial.md at master · yqrashawn/GokuRakuJoudo
https://github.com/yqrashawn/GokuRakuJoudo/blob/master/tutorial.md

上記ドキュメントを読むと自分で設定ファイルを作るのは、敷居が高いと思うかもしれませんが、

control_break_keybindings.json

上記ファイルのように既存の JSON 形式 設定ファイルのキーコード (key_code) や修飾キー (modifiers) の文字列を変更すれば簡単に実現できます。

2022/03/21(Mon) 13:49:28
Visual Studio Code - Code Editing. Redefined
https://code.visualstudio.com/

2022/03/21(Mon) 13:49:57
JSON editing in Visual Studio Code
https://code.visualstudio.com/docs/languages/json

Visual Studio Code で JSON 形式 設定ファイルを開けば、構文チェックもしてくれます。

設定するキー文字列も、 /アプリケーション/Karabiner-EventViewer.app を起動し、確認したいキーを押せば表示してくれます。

2022/03/21(Mon) 13:51:08
快適キーボード操作のためのキーカスタマイズ ~Mac編~ | さくらのナレッジ
https://knowledge.sakura.ad.jp/23355/

上記サイトのキーバインド設定 JSON ファイルの解説が一番参考になりました。
特に mandatory、optional の違いは、ここで理解しました。

mandatory は、キーの組み合わせを指定し 、この組み合わせが入力されたときに ”to” の処理を行う。
optional に指定したキーは、”to” の時にもキー入力が引き継がれます。

私自身、

2022/03/21(Mon) 13:52:33
Karabiner-Elements complex_modifications rules
https://ke-complex-modifications.pqrs.org/

Table of Contents
	▼Emulation Modes
		▼Emacs key bindings (rev 12)
			▼Emacs key bindings [C-x key strokes] (rev 2)

2022/03/21(Mon) 13:53:00
JSON ソース
https://ke-complex-modifications.pqrs.org/json/emacs_key_bindings.json

のソースを読んで、理解を深めました。変数を使ってショートキーを押した数を数えたり、特定のアプリだけ動作する方法を学びました。

最後に JSON 設定ファイルを作成するのに必要なドキュメントの箇所をまとめておきます。

目次

JSON 設定ファイル書式

2022/03/21(Mon) 13:56:11
complex_modifications manipulator definition | Karabiner-Elements
https://karabiner-elements.pqrs.org/docs/json/complex-modifications-manipulator-definition/
"manipulators": [
    {
        "type": "basic",
        "from": {...},
        "to": [...],
        "to_if_alone": [...],
        "to_if_held_down": [...],
        "to_after_key_up": [...],
        "to_delayed_action": {
            "to_if_invoked": [...],
            "to_if_canceled": [...],
        },
        "conditions": [...],
        "parameters": {...},
        "description": "Optional description for human"
    },
    ...
]
Name	Required	Description
type				Required	"basic" is specified
from				Required	The name of key code, consumer key code or pointing button which you want to change
to				Optional	Events which are sent when you press from key
to_if_alone		Optional	Events which are sent when you press from key alone
to_if_held_down	Optional	Events which are sent when you hold down from key
to_after_key_up	Optional	Events which are sent after you release from key
to_delayed_action	Optional	Events which are sent after 500 milliseconds at you press from key
conditions		Optional	Manipulator is applied only if condition is matched (e.g., the frontmost application)
parameters		Optional	Override parameters such as to_if_alone_timeout_milliseconds
description		Optional	A human-readable comment
2022/03/21(Mon) 13:57:49
to_if_alone | Karabiner-Elements
https://karabiner-elements.pqrs.org/docs/json/complex-modifications-manipulator-definition/to-if-alone/

2022/03/21(Mon) 13:58:14
to_if_held_down | Karabiner-Elements
https://karabiner-elements.pqrs.org/docs/json/complex-modifications-manipulator-definition/to-if-held-down/

2022/03/21(Mon) 13:58:35
from.any | Karabiner-Elements
https://karabiner-elements.pqrs.org/docs/json/complex-modifications-manipulator-definition/from/any/

Conditions

2022/03/21(Mon) 13:59:55
Conditions | Karabiner-Elements
https://karabiner-elements.pqrs.org/docs/json/complex-modifications-manipulator-definition/conditions/
Conditions
frontmost_application_if, frontmost_application_unless
device_if, device_unless
keyboard_type_if, keyboard_type_unless
input_source_if, input_source_unless
variable_if, variable_unless
event_changed_if, event_changed_unless
2022/03/21(Mon) 14:01:04
frontmost_application_if, frontmost_application_unless | Karabiner-Elements
https://karabiner-elements.pqrs.org/docs/json/complex-modifications-manipulator-definition/conditions/frontmost-application/
frontmost_application_if, frontmost_application_unless
Change an event if/unless the frontmost application is the specified application.

{
    "type": "frontmost_application_if",
    "bundle_identifiers": [
        bundle identifier regex,
        bundle identifier regex,
        ...
    ],
    "file_paths": [
        file path regex,
        file path regex,
        ...
    ]
}
Name	Required	Description
type	Required	"frontmost_application_if" or "frontmost_application_unless"
bundle_identifiers	Optional	Bundle identifier regexs such as ["^com\\.apple\\.Terminal$", "^com\\.googlecode\\.iterm2$"]
file_paths	Optional	File path regexs such as ["/Finder$"]
description	Optional	A human-readable comment
Multiple

Event

2022/03/21(Mon) 14:02:38
from event definition | Karabiner-Elements
https://karabiner-elements.pqrs.org/docs/json/complex-modifications-manipulator-definition/from/
from event definition
{
    "from": {
        "key_code": "The name of key_code",
        "consumer_key_code": "The name of consumer_key_code",
        "pointing_button": "The name of pointing_button",
        "any": "key_code or consumer_key_code or pointing_button",

        "modifiers": {
            "mandatory": [
                modifier,
                modifier,
                ...
            ],
            "optional": [
                modifier,
                modifier,
                ...
            ]
        },

        "simultaneous": [
            {
                "key_code, consumer_key_code, pointing_button or any"
            },
            {
                "key_code, consumer_key_code, pointing_button or any"
            },
            ...
        ],
        "simultaneous_options": {
            "detect_key_down_uninterruptedly": false,
            "key_down_order": "A restriction of input events order",
            "key_up_order": "A restriction of input events order",
            "key_up_when": "When key_up events are posted",
            "to_after_key_up": [
                to event definition,
                to event definition,
                ...
            ]
        }
    }
}
Name	Required	Description
key_code				Optional	Key code which you want to change
consumer_key_code		Optional	Consumer key code (media key code) which you want to change
pointing_button		Optional	Pointing button name which you want to change
any					Optional	"any": "key_code", "any": "consumer_key_code" or "any": "pointing_button"
modifiers				Optional	Specify mandatory and optional modifiers (e.g., “change control-h to delete”)
simultaneous			Optional	Specify multiple events which are pressed simultaneously
simultaneous_options	Optional	Options for simultaneous

Note
key_code, consumer_key_code, pointing_button and any are exclusive.
You have to specify one of them.

Caution
Be careful using "pointing_button": "button1" and "any": "pointing_button".
You may lose the left click button and system will be unusable.

Bundle identifier の探し方

Finder で Bundle identifier を確認したいアプリケーション (例として ‘ターミナル.app ‘ を使って解説します。) を右クリック (Ctrl + 左クリック) し

メニュー

メニュー > パッケージの内容を表示 を選択

Contents

表示された Contents フォルダをダブルクリックして開く。

Info.plist

Finder 上で Info.plist ファイルをダブルクリックする。 Xcode をインストールしている場合、Xcode の property list editor で表示されます。

Xcode の property list editor

表示されたウインドウの Bundle identifier の横に表示された文字列 com.apple.Terminal が目的の値です。

Bundle identifier を raw で表示するには、

Raw Keys & Values

上図のように property list editor 内を右クリック (Ctrl + 左クリック) して、メニュー > Raw Keys & Values を選択すれば表示されます。

raw で表示された状態

詳細は、少し古いですが下記ページを参照してください。間違って値を変更しないように気を付けてください。

2022/03/21(Mon) 14:09:42
Edit property lists - Xcode Help
https://help.apple.com/xcode/mac/11.4/#/dev3f399a2a6

2022/03/21(Mon) 14:10:12
Xcode Help
https://help.apple.com/xcode/mac/11.4/

Apple Watch で iPhone をロック解除と拙作 Apple Watch アプリ Densuke

2021/02/05(Fri) 19:05:59
iOS 14.5でマスクをしたままでもiPhoneのロック解除が顔認証で可能に - GIGAZINE
https://gigazine.net/news/20210202-ios-14-5-unlocking-iphone-face-mask/

2021/02/05(Fri) 19:06:39
How to use the new 'Unlock with Apple Watch' iPhone feature - 9to5Mac
https://9to5mac.com/2021/02/04/iphone-face-id-unlock-apple-watch-mask/

マスクをしている時に、Apple Watch で iPhone をロック解除できるようになるみたい。
心電図も利用可能になったし、Apple Watch 買おうかな?

Xcode で 画像と時刻を表示する簡単な Apple Watch アプリ Densuke を作ってみました。
Xcode のシミュレータで撮ったスクリーンショットを下記に載せておきます。

図 1) 拙作 Apple Watch アプリ Densuke
図 2) Apple Watch 文字盤を表示