ターミナルからstreamusアプリを実行する方法

ターミナルからstreamusアプリを実行する方法

私が使うストリーマスYou Tube から音楽をストリーミングします。Streamus をターミナル自体から起動できるかどうかを知りたいです。この質問をメインのソフトウェア サイトで行ったところ、作成者は xdotool を使用することを推奨しました。xdotool ( sudo apt-get install xdotool) をインストールし、アプリを正常に開くこともできました。

主に2つの問題があります

  1. アプリをリロードする
  2. アプリから再生

問題は、アプリを開いた後に空白の画面が表示されることです。ctrl+rアプリをリロードするために、自動化するために xdotool を使用しました。これが私のスクリプトです。

 /usr/bin/chromium-browser --disable-gpu --enable-offline-auto-reload --enable-offline-auto-reload-visible-only --app=chrome-extension://jbnkffmindojffecdhbbmekbmkkfpmjd/foreground.html & xdotool key ctrl+r

しかし、xdotools が動作しておらず、アプリがリロードされないようです。また、アプリから曲を再生する方法についても教えていただけますか。

答え1

要約そのショートカットはアクティブ ウィンドウに送信されるため、スクリプトは機能しませchromium-browserStreamus


これはあなたのリロード xdotool指示:

xdotool search --limit 1 --name "^Streamus$" | xargs -I {} xdotool windowactivate --sync {} key ctrl+r

あなたの場合の完全なコマンドは次のとおりです:

/usr/bin/chromium-browser --disable-gpu --enable-offline-auto-reload --enable-offline-auto-reload-visible-only --app=chrome-extension://jbnkffmindojffecdhbbmekbmkkfpmjd/foreground.html & xdotool search --limit 1 --name "^Streamus$" | xargs -I {} xdotool windowactivate --sync {} key ctrl+r

ショートカットの実行は、以下の場合に多少遅れることがありますsleep 1:

/usr/bin/chromium-browser --disable-gpu --enable-offline-auto-reload --enable-offline-auto-reload-visible-only --app=chrome-extension://jbnkffmindojffecdhbbmekbmkkfpmjd/foreground.html & sleep 1; xdotool search --limit 1 --name "^Streamus$"| xargs -I {} xdotool windowactivate --sync {} key ctrl+r

これはあなたの再生/一時停止 xdotool指示:

xdotool search --limit 1 --name "^Streamus$" | xargs -I {} xdotool windowactivate --sync {} key alt+z

サンプルスクリプト:

Streamusを開始するには、リロードして「再生」を押します

#!/bin/bash

# Start Streamus
/usr/bin/chromium-browser --disable-gpu --enable-offline-auto-reload --enable-offline-auto-reload-visible-only --app=chrome-extension://jbnkffmindojffecdhbbmekbmkkfpmjd/foreground.html &

# Wait three seconds to finish the previous command
sleep 3

WID=$(xdotool search --limit 1 --name "^Streamus$")

# Refresh the page
xdotool windowactivate --sync "$WID" key ctrl+r

# Wait three seconds to update the page (Ctrl+R).
sleep 3

# "Press" Play
xdotool windowactivate --sync "$WID" key alt+z

説明:

  • xdotool search --limit 1 --name "^Streamus$"

    • search

      正規表現パターンを使用して、タイトル、名前、またはクラスを持つウィンドウを検索します。

    • limit N

      N 個の一致するウィンドウが見つかったら検索を停止します。制限を指定すると、少数の結果のみが必要な場合に検索を高速化できます。

    • --name

      ウィンドウ名と照合します。これは、ウィンドウのタイトルバーに表示される文字列と同じです。

  • xargs -I {} xdotool windowactivate --sync {} key ctrl+r

    • xargs -I {}

      コマンドをビルドして実行するxdotool

    • xdotool windowactivate --sync {} key ctrl+r

      • windowactivate

        ウィンドウをアクティブにします。

      • sync

        ウィンドウのアクティベーションを送信した後、ウィンドウが実際にアクティベートされるまで待機します。

      • {}

        xargs{}ウィンドウIDに置き換えます

      • key ctrl+r

        ショートカットを送信しますCtrl+R

関連情報