- 投稿日:2022-01-31T20:11:17+09:00
macos monterey 12.2にアップデート後、勝手にスリープが解除される。
1.環境 この記事ではmacos monterey 12.2 にインストールしたMacBook Proを使っています。またMX KEYS for MacをBluetoothで接続しています。 2.困ったこと アップデート後、macをスリープ状態にして画面を開いたままにしておくと、20秒ほどで勝手にスリープ解除されてしまう。 3.解決方法 MX KEYS for Macの電源を切ってスリープ状態にさせることで、勝手にスリープ解除されなくなりました。
- 投稿日:2022-01-31T18:35:56+09:00
UNIX系でのバイトオーダー(エンディアン)の調べ方
バイトオーダーとは 2bytes以上のデータをメモリに格納する際の順番のこと。 割り当てられているメモリの後ろの方から格納していくのをリトルエンディアン、反対に頭の方から格納していくのをビッグエンディアンという。 どちらが採用されているかはCPUによって異なる(Intel系はリトルエンディアン)。 調べ方 > sysctl hw.byteorder 出力結果が'1234'ならリトルエンディアン、'4321'ならビッグエンディアン。 参考 https://atmarkit.itmedia.co.jp/icd/root/70/5784470.html http://piyocast.com/as/archives/10591
- 投稿日:2022-01-31T17:05:57+09:00
Macの設定の半自動化方法
Macで、初期設定をある程度自動化したい。 必要なアプリのインストールとか。 以下あたりを参考にしてスクリプトを作成したのでメモとして残しておく。 https://qiita.com/7coAim/items/fe8ac542a78f9f985572 https://kiririmode.hatenablog.jp/entry/20200103/1578033722 試したのはMacの11.4 システムの環境設定 defaultsコマンドで行える。 # タップでクリックとドラッグ(DragLock)を許可 defaults write com.apple.AppleMultitouchTrackpad Clicking -bool true defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true defaults -currentHost write -g com.apple.mouse.tapBehavior -bool true defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Dragging -bool true defaults write com.apple.AppleMultitouchTrackpad Dragging -bool true # タッチバーをファンクションキーにする defaults write com.apple.touchbar.agent PresentationModeGlobal -string functionKeys # Finder:隠しファイル/フォルダを表示 defaults write com.apple.finder AppleShowAllFiles true # Finder:拡張子を表示 defaults write NSGlobalDomain AppleShowAllExtensions -bool true defaults以外だと以下のような設定がある # 起動音なくす sudo nvram StartupMute=%01 なお、ディスクの暗号化はfdesetupコマンドがあるが、ユーザ名の入力等は必要になるので、 これだけだと完全自動化はできなさそう。(Ansibleとかあればいけるのかも?) (まぁ、暗号化はルートユーザ、それ以外は個別ユーザというやり方もあるので、すべて自動化でなくてもいいかも) sudo fdesetup enable キッティングの場合はこことかが参考になる。 MDM利用の場合は構成プロファイルを使う手がある。 アプリ関係 とりあえずHomeBerwを入れる。 https://brew.sh/index_jaのコマンドを実行。 2022年1月だと以下だった。 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" echo 'export PATH=/opt/homebrew/bin:$PATH' >> ~/.bash_profile source ~/.bash_profile echo 'export PATH=/opt/homebrew/bin:$PATH' >> ~/.zshrc source ~/.zshrc 必要なソフトを入れる # Chrome brew cask install google-chrome # VSCode brew install visual-studio-code --cask echo 'export PATH="\$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin:$PATH"` >> ~/.bash_profile source ~/.bash_profile echo 'export PATH="\$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin:$PATH"` >> ~/.zshrc source ~/.zshrc # 略 #VScodeの拡張例 code --install-extension ms-ceintl.vscode-language-pack-ja nodebrewでのインストールや切り替え方はこことか参照。 pyenvはこことか Homebrewは 途中でWifiが切れて、再度homebrewのインストールコマンドを流すとエラーになった。 error: Not a valid ref: refs/remotes/origin/master これば rm -rf /opt/homebrew で一度削除してから実行で行けた。 一部は手動で良いので、.shは次のような形で一旦完成形としておいた。 macInstall.sh # 再起動が必要なものもあり # スリープとスクリーンセーバの解除にパスワードを要求 defaults write com.apple.screensaver askForPassword -bool true # パスワードを要求するまでの秒数 defaults write com.apple.screensaver askForPasswordDelay -int 600 # Dockに最近使ったもの、を表示しない defaults write com.apple.dock show-recents -bool false # タップでクリックとドラッグを許可 defaults write com.apple.AppleMultitouchTrackpad Clicking -bool true defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true defaults -currentHost write -g com.apple.mouse.tapBehavior -bool true defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Dragging -bool true defaults write com.apple.AppleMultitouchTrackpad Dragging -bool true # スペルミス修正しない defaults write -g NSAutomaticSpellingCorrectionEnabled -bool false # タッチバーをファンクションキーにする defaults write com.apple.touchbar.agent PresentationModeGlobal -string functionKeys # Finder:隠しファイル/フォルダを表示 defaults write com.apple.finder AppleShowAllFiles true # Finder:拡張子を表示 defaults write NSGlobalDomain AppleShowAllExtensions -bool true # CapsLock を Ctrl に変更することもコマンドから出来るらしい # どちらかといえばCtrlではなくCommand=30064771299の方がいい気がしたので keyboard_id="$(ioreg -c AppleEmbeddedKeyboard -r | grep -Eiw "VendorID|ProductID" | awk '{ print $4 }' | paste -s -d'-\n' -)-0" defaults -currentHost write -g com.apple.keyboard.modifiermapping.${keyboard_id} -array-add " <dict> <key>HIDKeyboardModifierMappingDst</key>\ <integer>30064771299</integer>\ <key>HIDKeyboardModifierMappingSrc</key>\ <integer>30064771129</integer>\ </dict> " # 起動音なくす sudo nvram StartupMute=%01 # home-brew /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" echo 'export PATH=/opt/homebrew/bin:$PATH' >> ~/.bash_profile source ~/.bash_profile echo 'export PATH=/opt/homebrew/bin:$PATH' >> ~/.zshrc source ~/.zshrc # Chrome brew install cask brew install google-chrome --cask # VSCode brew install visual-studio-code --cask echo 'export PATH="\$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin:$PATH"` >> ~/.bash_profile source ~/.bash_profile echo 'export PATH="\$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin:$PATH"` >> ~/.zshrc source ~/.zshrc # git appleGitではなくこちらを使う # https://hirooooo-lab.com/development/install-git-by-homebrew/ brew install git # node.js brew install nodebrew echo 'export PATH=$HOME/.nodebrew/current/bin:$PATH' >> ~/.bash_profile source ~/.bash_profile echo 'export PATH=$HOME/.nodebrew/current/bin:$PATH' >> ~/.zshrc source ~/.zshrc # https://qiita.com/sabinuki/items/3e5dd9285ceb8405e7f0 /opt/homebrew/opt/nodebrew/bin/nodebrew setup_dirs nodebrew install-binary latest # Python brew install pyenv echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bash_profile source ~/.bash_profile echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.zshrc source ~/.zshrc # インストールできるバージョンはpyenv install --listで確認可能 pyenv install 3.10.2 pyenv global 3.10.2 # UnityHub (本体はHubから手でインストール) brew install unity-hub --cask #VScodeの拡張 code --install-extension Unity.unity-debug code --install-extension kleber-swf.unity-code-snippets code --install-extension mhutchie.git-graph code --install-extension mosapride.zenkaku code --install-extension ms-ceintl.vscode-language-pack-ja ターミナルからこのシェルを実行するが、その際にはchmodで実行権限を付ける。 それ以外 (https://auto-worker.com/blog/?p=2847)[https://auto-worker.com/blog/?p=2847] IMEの入力設定は変更してライブ変換OFF、Windows風をONにした方が個人的には使いやすいが、コマンドラインでのやり方がよくわからなかったので手動切り替えした。 VSCode周りはhttps://zenn.dev/nmrtkhs/articles/0b75959281c9a7とかを確認。 AppleID ついでにメモ。 GmailのアドレスでAppleIDを作成する方法
- 投稿日:2022-01-31T15:50:34+09:00
VMWare Fusionでguest(windows)からhost(mac)の開発環境(localhost:3000)にアクセス
環境 Host: Mac Big Sur 11.5.2 VM: VMWare Fusion 12.1.2 Guest: Windows 10 x64 やりたいこと お客さんの環境(Windows)だけで、デザインが崩れたので修正したい Guest(Windows)からHost(Mac)の開発環境(localhost:3000)にアクセスして直接操作 手順 1 VMでWindowsを立ち上げる 2 Macのターミナルでコマンド実行 $ ifconfig 3 上記から該当するものを探す en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 options=400<CHANNEL_IO> ether 3c:22:fb:13:df:4f inet6 fe80::1c84:d089:5dae:5860%en0 prefixlen 64 secured scopeid 0x6 inet 192.168.128.56 netmask 0xffffff00 broadcast 192.168.128.255 nd6 options=201<PERFORMNUD,DAD> media: autoselect status: active 4 自分のは192.168.128.56 5 Windowsでchromeを立ち上げて、192.168.128.56:3000にアクセス 動作は遅いけどとりあえずこれで確認できた