Skip to content

Config and scripts used in my multi monitor Apollo setup

Notifications You must be signed in to change notification settings

drajabr/My-Sunshine-setup

Repository files navigation

My-Sunshine-setup

Config and scripts used in my multi monitor Apollo "fork of Sunshine" setup.

Preview

image

Motivation

Many thanks to ClassicOldSong for the great work making this easily possible out of the box.

Want to keep many windows opened at same time, but Ultrawide monitors are way out of my budget, Portable 15" displays are still expensive even I can't connect more than 1 "unless they're super the expensive Thunderbolt daisychain thing", and I had one extra 10" tablet that I rarely find myself using it. I found it useful as external display, and quite like the idea of multiple small monitors instead of big one, its more travel friendly, easier to manage windows alignment, and with touch input as a bonus "which turned out to be really useful in many cases".

Alternatives

Spacedesk and superDisplay are the only two good alternatives I found, but they're lagging behind sunshine in terms of performance and are not opensource.

Setup

  1. Install Apollo Download and install sunshine's fork Apollo from https://github.com/ClassicOldSong/Apollo/releases.
  2. Add '.conf files', you can use mine from repo as starting point, just make sure you create the '.json' files for each instance.
  3. Add json state files: create as many empty .json files to be used as state file, like sunshine_1.josn, sunshine_3.josn, and sunshine_3.josn. You can copy the first sunshinbe_state.json so the 3 instances will use same username/pass combination.
  4. Edit conf files For each conf file, you want to basically add the following configuration to be unique for each instance:
sunshine_name = instance_xx
port = xx
log_path = xx.log
file_state = xx.json
headless_mode = enabled
  1. Copy the launch script apollo_bulk_start.ps1, I like to keep all my script in one folder, for example I'll place it in C:\Tools\sunshine-tools.
  2. If modified, Edit the script and check the paths for sunshine:
    param (
     [string]$exePath = "C:\Program Files\Apollo\sunshine.exe", 
     [string]$workingDirectory = "C:\Program Files\Apollo\",
     [string[]]$exeParams = @(".\config\sunshine_1.conf", ".\config\sunshine_2.conf")
    )
  3. Test run the script, ideally it should start the 2 instances for example and you will see icon in status area, also, open each instance webUI "from the icon you can open the webui for example" and pair your devices one to each instance "Note that you can't keep logged in in 2 instances at same time in same browser".
  4. Create shortcut: Select the script > Right click > Create shortcut.
  5. Edit shortcut target to bypass excution policy: Select the shortcut > Right click > Properties then in target field add
    powershell.exe -ExecutionPolicy Bypass -File
    before the existing script target, for example it will be something like this: powershell.exe -ExecutionPolicy Bypass -File "C:\Tools\Sunshine-tools\apollo_bulk_start.ps1".

Note

If you don't want to change Apollo installation path, or add read permissions for cert/key to normal user, you will need to set the shortcut to run as adminstrator.

Bonus

Auto run at startup

While there is many ways to run the script at startup, I just copy the shortcut to startup shell:startup folder so it automatically run at startup: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup. However, this doesn't run as adminstrator as it fails to read cert/key with normal user rights, so needed to set read permession for cert/key.

Go to Apollo's config folder, i.e C:\Program Files\Apollo\config > right-click credentials folder > Security > Edit > Select Users group > Allow Read $ excute permession.

Connect android devices via USB

Using https://github.com/cotzhang/app.Cot-Hypernet2 to automatically enable "reverse" tethering for android devices via ADB, it actually runs proxy on laptop and use kinda VPN interface on Android to pass the connections over that proxy via ADB forward, it works better than WiFi on old/cheapo android tablets, and I need to keep usb connected for charging anyway.

Note

You can replace gnirehtet.apk with the https://github.com/Linus789/gnirehtetx as it has some quality of life enhancments, mainly for me its auto exit on tablet, which made it easier to use the big tablet as normal when I'm not working "just disconnect and it'll automaticall stop the gnirehtet vpn, so you don't have to ;)

Anopther option is to use native hardware tethering as a workaround to have a network between PC and Android, I noticed slight better performance than the ADB method, so here it is:

  1. Enable USB tethering from android settings
  2. Check the IP your computer acquired via DHCP
  3. Set it to static IP in the same range
  4. Use that IP to connect from the android tablet to the PC I noticed my 2 tablets gave diffrent IP range for the laptop one gave 192.168.42.x, and the other gave 192.168.98.x range, I have no clue if it will work if both gave same range "as the android device itself will usually have the .1 IP in the range, so having 2 devices with same IP in same subnet doesn't sound good, but further testing needed. Advantages: No internet connection to Android devices, No need for ADB, More stable connection, and no need extra software.

Auto launch and connect to hosts from android tablet clients

This may not be easy to setup for first time Automate App users, but ther result deserve the setup pain

  1. Download and install "Automate" App
  2. Create launcher shortcut for the desktop from Moonlight app "or better, Artimis from ClassicOldSong"
  3. Enable "App start inspect" flow in Automate app
  4. Now go back to home screen, and connect to host from the shortcut, then long-click home button to get the prameters which the app launched with, we're looking for the Extras section for example:
• Package: com.limelight.noir
• Activity class: com.limelight.Game
• Action: 
• Data URI: 
• MIME type: 
• Categories: 
• Extras: HttpsPort as Int: 17982, PcName as String: Left, UniqueId as String: b368efbc98069085, HDR as Boolean: 0, Host as String: 192.168.1.130, Port as Int: 17987, UUID as String: BBA3F7D5-7DA2-7B02-4C0E-681A7131C02B, AppId as Int: 881448767, VirtualDisplay as Boolean: 0, AppName as String: Desktop
  1. Edit "App start" block, in "Extras" field need to do little work, to match the parameters with Automate sytax, mainly the brackets and the quotation marks, something like this:
     {
     "HttpsPort": 17982,
     "PcName": "Left",
     "UniqueId": "b368efbc98069085",
     "HDR": false,
     "Host": "192.168.1.130",
     "Port": 17987,
     "UUID": "BBA3F7D5-7DA2-7B02-4C0E-681A7131C02B",
     "AppId": 881448767,
     "VirtualDisplay": false,
     "AppName": "Desktop"
     } 
    Doing that on touchscreen is annoying, so I used chatGPT to help me in this task and it didn't complain.
  2. Now, remaining the "HTTPS request" block, which is responsible to ping the url of sunshine WebUI to auto launch or close app, in my case it was https://192.168.1.130:17988 edit according to each instance webUI url, hint: WebUI Port = sunshine port - 1.

Seperate Audio output device for each display

To make use of the speaker in each of these devices, in such a way each display outputs audio of the thing beinng displayed on it. While audio multitasking may not always be practical, but most of the time I have background music playing even if I'm in a meeting 😆 even for watching multiple live streams.

If you need Audio multitasking, and your brain can handle it "not easy", this section is for you. the idea is to create multiple virtual audio devices, and set each one as a sink for each instance, also, disable "Play audio on PC" on android clients using artemis or monlight and enable "Mute host PC speakers while streaming" on windows clients using moonlight-qt, this is important so each Apollo/sunshine instace doesn't playback its captured stream to the main playback device again, thus combining what we want to seperate :) .

  1. Prepare virtual audio devices: In the host I used VAC "virtual audio cable" (paid) to create 3 virtual audio devices, you can also use ab-cable or any other virtual audio device app you like.
  2. Rename each virtual device: from windows audio control panell, you can rename each device to your like, for me I set these 3 names "left" "bottom" "right" so I can put them in configuration using their name, also when switching apps I have conventional names for audio outputs.
  3. Configure each instance: In Virtual Sink option for each instance add the corrosponding virtual device name. this is the device apollo/sunshine will capture and send to the client AND not play it back to default audio output.
  4. Now the annoying part, each time apollo/sunshine gets connection it'll override the default audio output to the device set for it to capture, sadly we don't have built in setting to disable this behaviour, but I personally use app called "SoundSwitch" with default force profile set to speaker "my main output" so its always set from there. Anyway, when you configure your setup in a specific way, windows remeber which apps are assigned to which output.

Now, to route audio output from windows apps, use windows control panel, and to route audio output from diffrent browser tabs, I found extension "AudioPick" as I'm using soundcloud, youtube, and others as PWA, and I can set each one to output specfic device by default and it remebers them too.

Note

This is guide is made using https://github.com/ClassicOldSong/Apollo repo. Apollo is a fork that despite being backed by only one dev, it recently got more fixes/features implemented in a faster pace than mainstream sunshine, and probably the two won't be compatible in the near future.

Caution

If you decided to use Apollo, please, don't ask for support on moonlight-stream discord server or open issues related to Apollo in sunshine mainstream repo.

Tip

If you want support or have issues you're welcome to open discussion or create an issue in Apollo's repo, but again, don't mix between both.

About

Config and scripts used in my multi monitor Apollo setup

Resources

Stars

Watchers

Forks