Ubuntu – How to run streamus app from terminal

bashchromiumscriptsxdotool

I use Streamus to stream music from you tube. I want to know whether streamus can be started from terminal itself. I have asked this question in main software site and the author recommended to use xdotool for it. I have installed xdotool (sudo apt-get install xdotool) and also able to successfully open the app.

I have mainly two problem

  1. Reloading the app
  2. Playing from the app

The problem is after the app opens it just shows blank screen. I have to use ctrl+r to reload the app, to automate it i used xdotool. This is my script.

 /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

But it seems xdotools is not working and its not reloading the app? And also can you help me with playing songs from the app.

Best Answer

TL;DR The script can not work because that shortcut will be sent to the active window, and that's not chromium-browser with Streamus.


This is your reload xdotool command:

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

The complete command in your case is:

/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

The execution of the shortcut can be somewhat delayed with 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

This is your play/pause xdotool command:

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

A sample script:

To start Streamus, reload and "press" play

#!/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

Explanation:

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

    • search

      Search for windows with titles, names, or classes with a regular expression pattern.

    • limit N

      Stop searching after finding N matching windows. Specifying a limit will help speed up your search if you only want a few results.

    • --name

      Match against the window name. This is the same string that is displayed in the window titlebar.

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

    • xargs -I {}

      Build and execute the command xdotool

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

      • windowactivate

        Activate the window.

      • sync

        After sending the window activation, wait until the window is actually activated.

      • {}

        xargs replaces {} with the window id

      • key ctrl+r

        sends the shortcut Ctrl+R