Alexa | Echo dot 4 clock で音楽ファイルを再生しようとしてわかったこと。

単に音楽をかけようとすると Amazon music なんちゃらで音楽をかけようとする。
ローカル(Nas)にあるflac(なりmp3)を使いたい。
skill を使うと色々できるらしい。  

1.みんな AWS S3を使ってやってる。

この辺参照

Alexaで手持ちの音楽(mp3)を再生するスキルの作成 - こんてんつこうかい

Alexaのスキルを自作して手持ちの音楽ファイルを再生させよう | あんどろいどスマート

Amazon Echoで自分の音楽を再生する方法

2.インターネット上からでないと再生できない。

オーディオストリームの要件 audioItem.stream.urlプロパティで指定するURLは、これらの要件を満たす必要があります。

オーディオファイルは、インターネットにアクセス可能なポート443のHTTPSエンドポイント側でホスティングされる必要があります。

AudioPlayerインターフェースのリファレンス | Alexa Skills Kit

3.一歩譲って自前サーバーから再生する方法。

【最短】自前サーバを使いmp3をEchoで再生する方法「AWS(Lambda)未使用」その2

4.ローカルファイルを再生する方法。

How to play music you own on an Amazon Echo | TechHive

ローカルファイルを再生すると言っても、結局インターネット上に開く感じ。
Plex というメディアサーバーを使う。

Stream Movies & TV Shows | Plex

インストールはこんな感じ。

Plex Media ServerをCentOS 7にインストールする - 東京生まれHOUSE MUSIC育ち

ポートは 32400 っぽい。
で、Plex の Skill がこちら

Amazon.com: Plex : Alexa Skills

ここで問題が、
この Skill は amazon.com のアカウントでないと見れない。入れられない。たぶん。
で、.com のアカウントを作り試したが、今度は、スマートホーム用の Ratoc のリモコンが .com アカウントだと動かない。
中華? の Smart life はどっちでも動いた。
https://play.google.com/store/apps/details?id=com.tuya.smartlife&hl=ja&gl=US

リモコンが動かなくなるのは論外、サーバーを外に開くのもいやなので、却下。
Skill でコードをいじる前に玉砕。 とりあえずここまで。

appendix. alexa skill Hello world

[Alexaスキル] AudioPlayerでハローワールド | DevelopersIO

Mac | Xcode keybinding

Xcode Key Bindings

environment

macOS Ventura 13.0.1
Xcode Version 14.1 (14B47b)

Xcode 上での編集

Xcode > Settings... > Key Bindings

GUIで編集できない、削除できないキーが複数ある。
その場合ファイルを直接いじることで(ほぼ)可能。

実ファイル

~/Library/Developer/Xcode/UserData/KeyBindings/
以下
xxx.idekeybindings

一つのコマンドを取り出すと、こんな感じ。

           <dict>
                <key>Action</key>
                <string>findAndReplace:</string>
                <key>Alternate</key>
                <string>NO</string>
                <key>CommandID</key>
                <string>Xcode.IDEKit.CmdDefinition.FindAndReplace</string>
                <key>Group</key>
                <string>Find Menu</string>
                <key>GroupID</key>
                <string>Xcode.IDEKit.MenuDefinition.Main</string>
                <key>GroupedAlternate</key>
                <string>NO</string>
                <key>Keyboard Shortcut</key>
                <string>@h</string>
                <key>Navigation</key>
                <string>NO</string>
                <key>Title</key>
                <string>Find and Replace…</string>
            </dict>

変更するには、

               <key>Keyboard Shortcut</key>

の下の string タグを編集する。

もしくは、

                <key>Keyboard Shortcut</key>
                <string>@h</string>

の部分を削除すればキーバインドを削除できる。

modifier

modifier sign
control ^
shift $
cmd @
option ~
                <key>Keyboard Shortcut</key>
                <string>@h</string>

で ( command h ) の意味

Reference

stackoverflow.com

developer.apple.com

Mac | Karabiner-Elements

Karabiner-Elements

Change an event if the frontmost application is the specified application.

Mac 上のwine で ctrl(control) と alt(command) を入れ替えたい。

~/.config/karabiner/assets/complex_modifications/ に以下のjsonを保存

swap_left_command_and_control.json

{
  "title": "swap left_command and left_control",
  "rules": [
    {
      "description": "swap left_command and left_control",
      "manipulators":
      [
        {
          "type": "basic",
          "from": {
            "key_code": "left_control"
          },
          "to": [
            {
              "key_code": "left_command"
            }
          ],
          "conditions": [
            {
              "type": "frontmost_application_if",
              "file_paths": [
                "/opt/homebrew/bin/wine-preloader"
              ]
            }
          ],
          "description": "swap left_command and left_control"
        },

        {
            "type": "basic",
            "from": {
              "key_code": "left_command"
            },
            "to": [
              {
                "key_code": "left_control"
              }
            ],
            "conditions": [
              {
                "type": "frontmost_application_if",
                "file_paths": [
                  "/opt/homebrew/bin/wine-preloader"
                ]
              }
            ],
            "description": "swap left_command and left_control"
          }
      ]
    }
  ]
}

Karabiner-Elements から
Preferences... > Complex Modifications > Add rule
~/.config/karabiner/assets/complex_modifications/ に問題のないjsonファイルが入れてあれば、項目が表示される模様

参考

www.870labo.com

karabiner-elements.pqrs.org

Mac | disable command-h "Hide App" command

OS Ventura でシステム設定の変更で迷子の今日この頃いかがお過ごしでしょうか。
OS Ventura のせいか、IntelliJ のアップデートのせいか command-h でまたもアプリが画面から消える衝撃が走ったけどなんとかなった個人的メモポエム。

システム設定>キーボード>キーボードショートカット...

以前はこれだけで動いてたのが緑
未だに動いてる青
緑がダメになったので追加したのが赤
(使わないkey bind を割り当てることでcommand-hを無視させる)

IntelliJ系でReplaceにアイコンが付いている(付くようになった?)のが原因かと。
IntelliJ系でReplaceにcommand-h は preference>keymap で個別に設定はしてある。

絵で見りゃわかるから、文字にするの面倒なんでおわり。

Mac | find: -printf: unknown primary or operator

find directory -type f -printf "%s\n" | awk '{ sum += $1; } END { print sum; }' | printf "%'d\n" $(cat)

と、やろうとしたら

find: -printf: unknown primary or operator

といわれる。
なにやら、Mac OSX の bash (zsh) のfind は少し違うらしい。
-printf がないらしい。

以下、参照という名のコピペ

問題あれば消しますコメントください。

Macでfindコマンドを使えるようにする

pointsandlines.jp

brew install findutils

インストール完了後、使用出来るコマンドは「gfind」となり間違えやすいのでエイリアスを作成する。

(.bash_profileへaliaseを記述する)

sudo vi ~/.bash_profile

vi インサートモードに切り替えて.bash_profileへ下記を追記

alias find=’gfind’

追記、保存が完了したらsourceコマンドで変更を反映

source ~/.bash_profile

Appendix

directory 以下のファイルの合計を取得(最後の| printf... は3桁区切り)

find directory -type f -printf "%s\n" | awk '{ sum += $1; } END { print sum; }' | printf "%'d\n" $(cat)

directory 以下のファイルの合計を取得(.DS_Store 除く)

find 'directory' -type f -not -name '.DS_Store' -printf "%s\n" | awk '{ sum += $1; } END { print sum; }' | printf "%'d\n" $(cat)

参照

it-ojisan.tokyo