Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic setup #35

Open
ksz16 opened this issue Mar 7, 2021 · 4 comments
Open

Automatic setup #35

ksz16 opened this issue Mar 7, 2021 · 4 comments
Labels
documentation Improvements or additions to documentation

Comments

@ksz16
Copy link

ksz16 commented Mar 7, 2021

Actually, automatic download of latest release is part of my complete setup script.
Feel free to add it to the wiki if you want.
It works on Windows 7 and probably on Windows 10 as well.

Requirements:
Cygwin
7-Zip
nircmd
Python
PuTTY
KeePass
KeeAgent

In addition, you need to have a backup folder at a location convenient for you.
This folder should include (e.g.):

D:\Backup\swyh-rs\.swyh-rs\config.ini
D:\Backup\swyh-rs\nogui.py
D:\Backup\swyh-rs\swyh-rs.bat

1. The following script downloads the latest version from GitHub, unzips it to the desired location, creates a shortcut in the Start Menu, copies the configuration file and additional files (nogui.py and swyh-rs.bat)

@echo off
set TOOLSDIR=C:\tools
set BACKUPDIR=D:\Backup

FOR /F "tokens=*" %%G IN ('curl -s https://api.github.com/repos/dheijl/swyh-rs/releases/latest ^| grep -oP '^"tag_name^": ^"\K^(.*^)^(^?^=^"^)'') DO set VERSION=%%G
curl -L https://github.com/dheijl/swyh-rs/releases/latest/download/swyh-rs-%VERSION%.zip -o %TEMP%\swyh-rs-%VERSION%.zip
7z x %TEMP%\swyh-rs-%VERSION%.zip -o%TOOLSDIR%\swyh-rs -x!swyh-rs-deb.exe
md "%APPDATA%\Microsoft\Windows\Start Menu\Programs\swyh-rs"
nircmd shortcut "%TOOLSDIR%\swyh-rs\swyh-rs.exe" "%APPDATA%\Microsoft\Windows\Start Menu\Programs\swyh-rs" "swyh-rs"
robocopy %BACKUPDIR%\swyh-rs\.swyh-rs %USERPROFILE%\.swyh-rs /MIR
copy %BACKUPDIR%\swyh-rs\nogui.py %TOOLSDIR%\swyh-rs /y
copy %BACKUPDIR%\swyh-rs\swyh-rs.bat %TOOLSDIR%\swyh-rs /y

2. nogui.py is a script by @Silun - wiki

import subprocess

def startProgram(target):
    SW_HIDE = 0
    info = subprocess.STARTUPINFO()
    info.dwFlags = subprocess.STARTF_USESHOWWINDOW
    info.wShowWindow = SW_HIDE
    subprocess.Popen(target, startupinfo=info)

program = r'C:\tools\swyh-rs\swyh-rs.exe'

startProgram(program)

3. swyh-rs.bat is a simple script that allows you to toggle application state (start/stop). Additionally it checks if KeePass with KeeAgent plugin is running (it serves SSH keys). It sets the selected sound device, volume to 100% and toggle mute mode. Finally, it remotely starts or stops playing the stream on your music player. The script can be run manually or by using a shortcut created with AutoHotkey

@echo off
tasklist | find /i "KeePass.exe" > nul || start "" "C:\Program Files (x86)\KeePass Password Safe 2\KeePass.exe" && pause

tasklist | find /i "swyh-rs.exe" > nul
IF %ERRORLEVEL% == 1 goto Start
IF %ERRORLEVEL% == 0 goto Stop

:Start
python C:\tools\swyh-rs\nogui.py
nircmd setdefaultsounddevice "Speakers" 1
nircmd setsysvolume 65535
nircmd mutesysvolume 1
plink -batch -ssh user@192.168.*.* -P 22 [your_command_to_start http://192.168.*.*:5901/stream/swyh.wav]
exit

:Stop
plink -batch -ssh user@192.168.*.* -P 22 [your_command_to_stop http://192.168.*.*:5901/stream/swyh.wav]
nircmd mutesysvolume 0
nircmd killprocess swyh-rs.exe

My scripts above are not very sophisticated. But they work :)
Maybe someone will find it helpful.

@dheijl
Copy link
Owner

dheijl commented Mar 7, 2021

Thanks again, I'll add it to the wiki!

@dheijl dheijl added the documentation Improvements or additions to documentation label May 5, 2021
@dheijl
Copy link
Owner

dheijl commented Apr 29, 2023

If you're still interested in swyh-rs: there is now a CLI version that should make automation a lot easier.

@Silun
Copy link

Silun commented Apr 29, 2023

Ooh that is great news! Is there a way to get the IP address and port that swyh-rs is serving on, rather than set it?

@dheijl
Copy link
Owner

dheijl commented Apr 29, 2023

  • Ip address: swyh-rs will try to get the ip address that connects to the internet, and will use that to serve unless you override it
  • Port number: defaults to 5901.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants