Skip to content

Automatic setup #35

@ksz16

Description

@ksz16

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    OutdatedToo old with no activitydocumentationImprovements or additions to documentation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions