Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
arctixdev committed Aug 10, 2023
2 parents 740115b + 73eaef2 commit cbaf1ea
Show file tree
Hide file tree
Showing 8 changed files with 143 additions and 62 deletions.
2 changes: 1 addition & 1 deletion PKGBUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Maintainer: Jonathan Bangert <[email protected]>
pkgname='music-assistant-desktop'
_pkgname='massapp'
pkgver=0.0.9
pkgver=0.0.10
pkgrel=1
pkgdesc="Music Assistant Desktop app"
arch=('x86_64')
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Music Assistant Desktop App

## WARNING: This is still in very early alpha. Bugs *will* occur
## WARNING: This is still in very early alpha. Bugs *will* be present. Please help finding them. You can report it on the Discord server

## The app requires that the webserver is exposed. You can set that in the settings:
![image](https://github.com/Un10ck3d/massapp/assets/74015378/8ea0b53a-e2a5-42c2-a98b-d04fcbe591bc)
Expand All @@ -13,8 +13,10 @@ Right now the setup thing will always show upon opening. But it shuold save your
The app can also do Discord Rich Presence. Meaning it will show on discord what music you are playing. It only shows the music playing on the app's squeezelite player. Example:
![image](https://github.com/Un10ck3d/massapp/assets/74015378/8de18bac-b963-4aba-bb61-5730b41759a9)

Notice: (WINDOWS ONLY!)
Untill [this PR](https://github.com/tauri-apps/wry/pull/994) gets merged and released the app runs the frontend openly on your computer on port 22863. The reason behind that is that webkit2 in windows dosnt allow connections to unsecured websockets if the app itself is secured with TLS..
## Notice: (WINDOWS ONLY!)
- There seems to be a layout issue with the sidebar on windows
- There seems to be a discord rpc issue on windows
- Untill [this PR](https://github.com/tauri-apps/wry/pull/994) gets merged and released the app runs the frontend openly on your computer on port 22863. The reason behind that is that webkit2 in windows dosnt allow connections to unsecured websockets if the app itself is secured with TLS..

## Installation

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "music-assistant-desktop",
"version": "0.0.9",
"version": "0.0.10",
"type": "module",
"description": "The Music Assistant frontend developed in Vue.",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "music-assistant-desktop"
version = "0.0.9"
version = "0.0.10"
description = "Music Assistant Desktop App"
authors = ["you"]
license = "Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/Tauri.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ withGlobalTauri = false

[package]
productName = "music-assistant-desktop"
version = "0.0.9"
version = "0.0.10"

[tauri.allowlist.shell]
all = false
Expand Down
122 changes: 68 additions & 54 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,79 +4,93 @@ mod discord_rpc;
use gethostname::gethostname;
use std::thread;
use tauri::api::process::Command;
use tauri::{utils::config::AppUrl, window::WindowBuilder, WindowUrl};
use std::sync::Once;

static DISCORD_RPC_STARTER: Once = Once::new();
static SQUEEZELITE_STARTER: Once = Once::new();

// Set the IS_WINDOWS constant to true if the target OS is windows
#[cfg(target_os = "windows")]
const IS_WINDOWS: bool = true;
#[cfg(not(target_os = "windows"))]
const IS_WINDOWS: bool = false;

#[tauri::command]
fn start_rpc(websocket: String) {
// Start the discord rich presence manager in a new thread
thread::spawn(move || {
let hostname: std::ffi::OsString = gethostname();
discord_rpc::start_rpc(websocket, hostname);
// To prevent it from starting multiple times even if frontend gets reloaded
DISCORD_RPC_STARTER.call_once(|| {
// Start the discord rich presence manager in a new thread
thread::spawn(move || {
let hostname: std::ffi::OsString = gethostname();
discord_rpc::start_rpc(websocket, hostname);
});
});
}

#[tauri::command]
fn start_sqzlite(ip: String) {
thread::spawn(move || {
// Start squeezelite
let hostname: std::ffi::OsString = gethostname();
Command::new_sidecar("squeezelite")
.expect("Failed to create command")
.args([
"-s",
ip.as_str(),
"-M",
"MusicAssistantDesktop",
"-n",
hostname
.to_str()
.expect("Couldnt convert hostname to &str -_-"),
])
.spawn()
.expect("Failed to start squeeselite");
// To prevent it from starting multiple times even if frontend gets reloaded
SQUEEZELITE_STARTER.call_once(|| {
// Start squeezelite in a new thread
thread::spawn(move || {
let hostname: std::ffi::OsString = gethostname();
Command::new_sidecar("squeezelite")
.expect("Failed to create command")
.args([
"-s",
ip.as_str(),
"-M",
"MusicAssistantDesktop",
"-n",
hostname
.to_str()
.expect("Couldnt convert hostname to &str -_-"),
])
.spawn()
.expect("Failed to start squeeselite");
});
});
}

fn main() {
use tauri::{utils::config::AppUrl, window::WindowBuilder, WindowUrl};

let port: u16 = 22863;

let window_url = if IS_WINDOWS {
WindowUrl::External(format!("http://localhost:{}", port).parse().unwrap())
} else {
WindowUrl::App("index.html".into())
// Port to use for the local webserver (Windows only)
let port: u16 = 22863;

};
// Set the window url to the local webserver if the target OS is windows
let window_url = if IS_WINDOWS {
WindowUrl::External(format!("http://localhost:{}", port).parse().unwrap())
} else {
WindowUrl::App("index.html".into())
};

let mut context = tauri::generate_context!();
let mut builder = tauri::Builder::default();
// Create the tauri context and builder
let mut context = tauri::generate_context!();
let mut builder = tauri::Builder::default();

if IS_WINDOWS {
context.config_mut().build.dist_dir = AppUrl::Url(window_url.clone());
builder = builder.plugin(tauri_plugin_localhost::Builder::new(port).build());
}
// If the target OS is windows, set the dist dir to the local webserver and add the localhost plugin
if IS_WINDOWS {
context.config_mut().build.dist_dir = AppUrl::Url(window_url.clone());
builder = builder.plugin(tauri_plugin_localhost::Builder::new(port).build());
}

builder
.invoke_handler(tauri::generate_handler![start_rpc, start_sqzlite])
.setup(move |app| {
WindowBuilder::new(
app,
"main".to_string(),
if cfg!(dev) {
Default::default()
} else {
window_url
}
)
.title("Music Assistant")
.build()?;
Ok(())
})
.run(context)
.expect("error while running tauri application");
// Run the tauri application
builder
.invoke_handler(tauri::generate_handler![start_rpc, start_sqzlite])
.setup(move |app| {
WindowBuilder::new(
app,
"main".to_string(),
if cfg!(dev) {
Default::default()
} else {
window_url
},
)
.title("Music Assistant")
.build()?;
Ok(())
})
.run(context)
.expect("error while running tauri application");
}
65 changes: 65 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,68 @@
# yarn lockfile v1


"@tauri-apps/[email protected]":
version "1.4.0"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-darwin-arm64/-/cli-darwin-arm64-1.4.0.tgz#e76bb8515ae31f03f2cbd440c1a09b237a79b3ac"
integrity sha512-nA/ml0SfUt6/CYLVbHmT500Y+ijqsuv5+s9EBnVXYSLVg9kbPUZJJHluEYK+xKuOj6xzyuT/+rZFMRapmJD3jQ==

"@tauri-apps/[email protected]":
version "1.4.0"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-darwin-x64/-/cli-darwin-x64-1.4.0.tgz#dd1472460550d0aa0ec6e699b073be2d77e5b962"
integrity sha512-ov/F6Zr+dg9B0PtRu65stFo2G0ow2TUlneqYYrkj+vA3n+moWDHfVty0raDjMLQbQt3rv3uayFMXGPMgble9OA==

"@tauri-apps/[email protected]":
version "1.4.0"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm-gnueabihf/-/cli-linux-arm-gnueabihf-1.4.0.tgz#325e90e47d260ba71a499850ce769b5a6bdfd48d"
integrity sha512-zwjbiMncycXDV7doovymyKD7sCg53ouAmfgpUqEBOTY3vgBi9TwijyPhJOqoG5vUVWhouNBC08akGmE4dja15g==

"@tauri-apps/[email protected]":
version "1.4.0"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm64-gnu/-/cli-linux-arm64-gnu-1.4.0.tgz#b5d8f5cba3f8f7c7d44d071681f0ab0a37f2c46e"
integrity sha512-5MCBcziqXC72mMXnkZU68mutXIR6zavDxopArE2gQtK841IlE06bIgtLi0kUUhlFJk2nhPRgiDgdLbrPlyt7fw==

"@tauri-apps/[email protected]":
version "1.4.0"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm64-musl/-/cli-linux-arm64-musl-1.4.0.tgz#f805ab2ee415875900f4b456f17dc4900d2a7911"
integrity sha512-7J3pRB6n6uNYgIfCeKt2Oz8J7oSaz2s8GGFRRH2HPxuTHrBNCinzVYm68UhVpJrL3bnGkU0ziVZLsW/iaOGfUg==

"@tauri-apps/[email protected]":
version "1.4.0"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-x64-gnu/-/cli-linux-x64-gnu-1.4.0.tgz#d3f5e69c22420c7ac9e4021b7a94bce2e48cb45d"
integrity sha512-Zh5gfAJxOv5AVWxcwuueaQ2vIAhlg0d6nZui6nMyfIJ8dbf3aZQ5ZzP38sYow5h/fbvgL+3GSQxZRBIa3c2E1w==

"@tauri-apps/[email protected]":
version "1.4.0"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-x64-musl/-/cli-linux-x64-musl-1.4.0.tgz#2e7f718272ffdd9ace80f57a35023ba0c74767ad"
integrity sha512-OLAYoICU3FaYiTdBsI+lQTKnDHeMmFMXIApN0M+xGiOkoIOQcV9CConMPjgmJQ867+NHRNgUGlvBEAh9CiJodQ==

"@tauri-apps/[email protected]":
version "1.4.0"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-win32-arm64-msvc/-/cli-win32-arm64-msvc-1.4.0.tgz#85cdb52a06feb92da785def4d02512099464525e"
integrity sha512-gZ05GENFbI6CB5MlOUsLlU0kZ9UtHn9riYtSXKT6MYs8HSPRffPHaHSL0WxsJweWh9nR5Hgh/TUU8uW3sYCzCg==

"@tauri-apps/[email protected]":
version "1.4.0"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-win32-ia32-msvc/-/cli-win32-ia32-msvc-1.4.0.tgz#0b7c921204058215aec9a5a00f735e73909bd330"
integrity sha512-JsetT/lTx/Zq98eo8T5CiRyF1nKeX04RO8JlJrI3ZOYsZpp/A5RJvMd/szQ17iOzwiHdge+tx7k2jHysR6oBlQ==

"@tauri-apps/[email protected]":
version "1.4.0"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-win32-x64-msvc/-/cli-win32-x64-msvc-1.4.0.tgz#23abe3f08c0df89111c29602f91c21a23577b908"
integrity sha512-z8Olcnwp5aYhzqUAarFjqF+oELCjuYWnB2HAJHlfsYNfDCAORY5kct3Fklz8PSsubC3U2EugWn8n42DwnThurg==

"@tauri-apps/cli@^1.4.0":
version "1.4.0"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli/-/cli-1.4.0.tgz#72732ae61e6b7d097e44a8a2ef5f211b2d01d98b"
integrity sha512-VXYr2i2iVFl98etQSQsqLzXgX96bnWiNZd1YADgatqwy/qecbd6Kl5ZAPB5R4ynsgE8A1gU7Fbzh7dCEQYFfmA==
optionalDependencies:
"@tauri-apps/cli-darwin-arm64" "1.4.0"
"@tauri-apps/cli-darwin-x64" "1.4.0"
"@tauri-apps/cli-linux-arm-gnueabihf" "1.4.0"
"@tauri-apps/cli-linux-arm64-gnu" "1.4.0"
"@tauri-apps/cli-linux-arm64-musl" "1.4.0"
"@tauri-apps/cli-linux-x64-gnu" "1.4.0"
"@tauri-apps/cli-linux-x64-musl" "1.4.0"
"@tauri-apps/cli-win32-arm64-msvc" "1.4.0"
"@tauri-apps/cli-win32-ia32-msvc" "1.4.0"
"@tauri-apps/cli-win32-x64-msvc" "1.4.0"

0 comments on commit cbaf1ea

Please sign in to comment.