Merge pull request #265 from Mastermindzh/feature/5.6.0

Feature/5.6.0
This commit is contained in:
Rick van Lieshout 2023-08-12 15:42:27 +02:00 committed by GitHub
commit dc87b20ab8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 307 additions and 143 deletions

View File

@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [5.6.0]
- Added support for Wayland (on by default) fixes [#262](https://github.com/Mastermindzh/tidal-hifi/issues/262) and [#157](https://github.com/Mastermindzh/tidal-hifi/issues/157)
- Made it clear in the readme that this tidal-hifi client supports High & Max audio settings. fixes [#261](https://github.com/Mastermindzh/tidal-hifi/issues/261)
- Added app suspension inhibitors when music is playing. fixes [#257](https://github.com/Mastermindzh/tidal-hifi/issues/257)
- Fixed bug with theme files from user directory trying to load: "an error occurred reading the theme file"
- Fixed: config flags not being set correctly
- [DEV]:
- Logger is now static and will automatically call either ipcRenderer or ipcMain
## 5.5.0 ## 5.5.0
- ListenBrainz integration added (thanks @Mar0xy) - ListenBrainz integration added (thanks @Mar0xy)
@ -22,7 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- SPKChaosPhoenix updated the beautiful Tokyo Night theme: - SPKChaosPhoenix updated the beautiful Tokyo Night theme:
![](./docs/images/tokyo-night.png) ![tidal with the tokyo night theme applied](./docs/images/tokyo-night.png)
## 5.2.0 ## 5.2.0

View File

@ -2,7 +2,7 @@
![GitHub release](https://img.shields.io/github/release/Mastermindzh/tidal-hifi.svg) [![github builds](https://github.com/mastermindzh/tidal-hifi/actions/workflows/build.yml/badge.svg)](https://github.com/Mastermindzh/tidal-hifi/actions) [![Build Status](https://ci.mastermindzh.tech/api/badges/Mastermindzh/tidal-hifi/status.svg)](https://ci.mastermindzh.tech/Mastermindzh/tidal-hifi) [![Discord logo](./docs/images/discord.png)](https://discord.gg/yhNwf4v4He) ![GitHub release](https://img.shields.io/github/release/Mastermindzh/tidal-hifi.svg) [![github builds](https://github.com/mastermindzh/tidal-hifi/actions/workflows/build.yml/badge.svg)](https://github.com/Mastermindzh/tidal-hifi/actions) [![Build Status](https://ci.mastermindzh.tech/api/badges/Mastermindzh/tidal-hifi/status.svg)](https://ci.mastermindzh.tech/Mastermindzh/tidal-hifi) [![Discord logo](./docs/images/discord.png)](https://discord.gg/yhNwf4v4He)
The web version of [listen.tidal.com](https://listen.tidal.com) running in electron with hifi support thanks to widevine. The web version of [listen.tidal.com](https://listen.tidal.com) running in electron with hifi (High & Max) support thanks to widevine.
![tidal-hifi preview](./docs/images/preview.png) ![tidal-hifi preview](./docs/images/preview.png)
@ -25,9 +25,9 @@ The web version of [listen.tidal.com](https://listen.tidal.com) running in elect
- [Nix](#nix) - [Nix](#nix)
- [Using source](#using-source) - [Using source](#using-source)
- [Integrations](#integrations) - [Integrations](#integrations)
- [Known bugs](#known-bugs) - [Known bugs](#known-bugs)
- [last.fm doesn't work out of the box. Use rescrobbler as a workaround](#lastfm-doesnt-work-out-of-the-box-use-rescrobbler-as-a-workaround) - [last.fm doesn't work out of the box. Use rescrobbler as a workaround](#lastfm-doesnt-work-out-of-the-box-use-rescrobbler-as-a-workaround)
- [DRM not working on Windows](#drm-not-working-on-windows) - [DRM not working on Windows](#drm-not-working-on-windows)
- [Special thanks to](#special-thanks-to) - [Special thanks to](#special-thanks-to)
- [Donations](#donations) - [Donations](#donations)
- [Images](#images) - [Images](#images)
@ -38,17 +38,19 @@ The web version of [listen.tidal.com](https://listen.tidal.com) running in elect
## Features ## Features
- HiFi playback - HiFi playback (High & Max settings)
- Notifications - Notifications
- Custom [theming](./docs/theming.md) - Custom [theming](./docs/theming.md)
- Custom hotkeys ([source](https://defkey.com/tidal-desktop-shortcuts)) - Custom hotkeys ([source](https://defkey.com/tidal-desktop-shortcuts))
- Songwhip.com integration (hotkey `ctrl + w`) - [Settings feature](./docs/images/settings.png) to disable certain functionality. (`ctrl+=` or `ctrl+0`)
- API for status and playback - API for status and playback
- Disabled audio & visual ads, unlocked lyrics, suggested track, track info, and unlimited skips thanks to uBlockOrigin custom filters ([source](https://github.com/uBlockOrigin/uAssets/issues/17495)) - Disabled audio & visual ads, unlocked lyrics, suggested track, track info, and unlimited skips thanks to uBlockOrigin custom filters ([source](https://github.com/uBlockOrigin/uAssets/issues/17495))
- Custom [integrations](#integrations)
- [Settings feature](./docs/images/settings.png) to disable certain functionality. (`ctrl+=` or `ctrl+0`)
- AlbumArt in integrations ([best-effort](https://github.com/Mastermindzh/tidal-hifi/pull/88#pullrequestreview-840814847)) - AlbumArt in integrations ([best-effort](https://github.com/Mastermindzh/tidal-hifi/pull/88#pullrequestreview-840814847))
- [ListenBrainz](https://listenbrainz.org/?redirect=false) integration - Custom [integrations](#integrations)
- [ListenBrainz](https://listenbrainz.org/?redirect=false) integration
- Songwhip.com integration (hotkey `ctrl + w`)
- Discord RPC integration (showing "now listening", "Browsing", etc)
- MPRIS integration
## Contributions ## Contributions
@ -59,8 +61,8 @@ To contribute you can use the standard GitHub features (issues, prs, etc) or joi
## Why did I create tidal-hifi? ## Why did I create tidal-hifi?
I moved from Spotify over to Tidal and found Linux support to be lacking. I moved from Spotify over to Tidal and found Linux support to be lacking.
When I started this project there weren't any Linux apps that offered Tidal's "hifi" options nor any scripts to control it. When I started this project there weren't any Linux apps that offered Tidal's "hifi" options nor any scripts to control it.
I made this app to support the highest quality audio available on the Linux platform. It used to be "hifi" but now is ["High & Max"](https://tidal.com/sound-quality).
### Why not extend existing projects? ### Why not extend existing projects?
@ -139,24 +141,20 @@ You can find these in the settings menu (`ctrl + =` by default) under the "integ
![integrations menu, showing a list of integrations](./docs/images/integrations.png) ![integrations menu, showing a list of integrations](./docs/images/integrations.png)
It currently includes: Integrations with other projects that are not included natively:
- MPRIS - MPRIS media player controls/status
- Discord - Shows what you're listening to on Discord.
Not included:
- [i3 blocks config](https://github.com/Mastermindzh/dotfiles/commit/9714b2fa1d670108ce811d5511fd3b7a43180647) - My dotfiles where I use this app to fetch currently playing music (direct commit) - [i3 blocks config](https://github.com/Mastermindzh/dotfiles/commit/9714b2fa1d670108ce811d5511fd3b7a43180647) - My dotfiles where I use this app to fetch currently playing music (direct commit)
- [neptune](https://github.com/uwu/neptune) third party plugins & theming
### Known bugs ## Known bugs
#### last.fm doesn't work out of the box. Use rescrobbler as a workaround ### last.fm doesn't work out of the box. Use rescrobbler as a workaround
The last.fm login doesn't work, as is evident from the following issue: [Last.fm login doesn't work](https://github.com/Mastermindzh/tidal-hifi/issues/4). The last.fm login doesn't work, as is evident from the following issue: [Last.fm login doesn't work](https://github.com/Mastermindzh/tidal-hifi/issues/4).
However, in that same issue you can read about a workaround using [rescrobbler](https://github.com/InputUsername/rescrobbled). However, in that same issue you can read about a workaround using [rescrobbler](https://github.com/InputUsername/rescrobbled).
For now, that will be the default workaround. For now, that will be the default workaround.
#### DRM not working on Windows ### DRM not working on Windows
Most Windows users run into DRM issues when trying to use tidal-hifi. Most Windows users run into DRM issues when trying to use tidal-hifi.
Nothing I can do about that I'm afraid... Tidal is working on removing/changing DRM so when they finish with that we can give it another shot. Nothing I can do about that I'm afraid... Tidal is working on removing/changing DRM so when they finish with that we can give it another shot.

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "tidal-hifi", "name": "tidal-hifi",
"version": "5.5.0", "version": "5.6.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "tidal-hifi", "name": "tidal-hifi",
"version": "5.5.0", "version": "5.6.0",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@electron/remote": "^2.0.10", "@electron/remote": "^2.0.10",

View File

@ -1,6 +1,6 @@
{ {
"name": "tidal-hifi", "name": "tidal-hifi",
"version": "5.5.0", "version": "5.6.0",
"description": "Tidal on Electron with widevine(hifi) support", "description": "Tidal on Electron with widevine(hifi) support",
"main": "ts-dist/main.js", "main": "ts-dist/main.js",
"scripts": { "scripts": {
@ -72,4 +72,4 @@
"typescript": "^5.1.6" "typescript": "^5.1.6"
}, },
"prettier": "@mastermindzh/prettier-config" "prettier": "@mastermindzh/prettier-config"
} }

View File

@ -1,4 +1,9 @@
export const flags: { [key: string]: { flag: string; value?: string }[] } = { export const flags: { [key: string]: { flag: string; value?: string }[] } = {
gpuRasterization: [{ flag: "enable-gpu-rasterization", value: undefined }], gpuRasterization: [{ flag: "enable-gpu-rasterization", value: undefined }],
disableHardwareMediaKeys: [{ flag: "disable-features", value: "HardwareMediaKeyHandling" }], disableHardwareMediaKeys: [{ flag: "disable-features", value: "HardwareMediaKeyHandling" }],
enableWaylandSupport: [
{ flag: "enable-features", value: "UseOzonePlatform" },
{ flag: "ozone-platform-hint", value: "auto" },
{ flag: "enable-features", value: "WaylandWindowDecorations" },
],
}; };

View File

@ -30,6 +30,7 @@ export const settings = {
root: "flags", root: "flags",
disableHardwareMediaKeys: "flags.disableHardwareMediaKeys", disableHardwareMediaKeys: "flags.disableHardwareMediaKeys",
gpuRasterization: "flags.gpuRasterization", gpuRasterization: "flags.gpuRasterization",
enableWaylandSupport: "flags.enableWaylandSupport",
}, },
menuBar: "menuBar", menuBar: "menuBar",
minimizeOnClose: "minimizeOnClose", minimizeOnClose: "minimizeOnClose",

View File

@ -0,0 +1,41 @@
import { App } from "electron";
import { flags } from "../../constants/flags";
import { settings } from "../../constants/settings";
import { settingsStore } from "../../scripts/settings";
import { Logger } from "../logger";
/**
* Set default Electron flags
*/
export function setDefaultFlags(app: App) {
setFlag(app, "disable-seccomp-filter-sandbox");
}
/**
* Set Tidal's managed flags from the user settings
* @param app
*/
export function setManagedFlagsFromSettings(app: App) {
const flagsFromSettings = settingsStore.get(settings.flags.root);
if (flagsFromSettings) {
for (const [key, value] of Object.entries(flagsFromSettings)) {
if (value) {
flags[key].forEach((flag) => {
Logger.log(`enabling command line option ${flag.flag} with value ${flag.value}`);
setFlag(app, flag.flag, flag.value);
});
}
}
}
}
/**
* Set a single flag for Electron
* @param app app to set it on
* @param flag flag name
* @param value value to be set for the flag
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function setFlag(app: App, flag: string, value?: any) {
app.commandLine.appendSwitch(flag, value);
}

View File

@ -0,0 +1,65 @@
import { PowerSaveBlocker, powerSaveBlocker } from "electron";
import { Logger } from "../logger";
/**
* Start blocking idle/screen timeouts
* @param blocker optional instance of the powerSaveBlocker to use
* @returns id of current block
*/
export const acquireInhibitor = (blocker?: PowerSaveBlocker): number => {
const currentBlocker = blocker ?? powerSaveBlocker;
const blockId = currentBlocker.start("prevent-app-suspension");
Logger.log(`Started preventing app suspension with id: ${blockId}`);
return blockId;
};
/**
* Check whether there is a blocker active for the current id, if not start it.
* @param id id of inhibitor you want to check activity against
* @param blocker optional instance of the powerSaveBlocker to use
*/
export const acquireInhibitorIfInactive = (id: number, blocker?: PowerSaveBlocker): number => {
const currentBlocker = blocker ?? powerSaveBlocker;
if (!isInhibitorActive(id, currentBlocker)) {
return acquireInhibitor();
}
return id;
};
/**
* stop blocking idle/screen timeouts
* @param id id of inhibitor you want to check activity against
* @param blocker optional instance of the powerSaveBlocker to use
*/
export const releaseInhibitor = (id: number, blocker?: PowerSaveBlocker) => {
try {
const currentBlocker = blocker ?? powerSaveBlocker;
currentBlocker.stop(id);
Logger.log(`Released inhibitor with id: ${id}`);
} catch (error) {
Logger.log("Releasing inhibitor failed");
}
};
/**
* stop blocking idle/screen timeouts if a inhibitor is active
* @param id id of inhibitor you want to check activity against
* @param blocker optional instance of the powerSaveBlocker to use
*/
export const releaseInhibitorIfActive = (id: number, blocker?: PowerSaveBlocker) => {
const currentBlocker = blocker ?? powerSaveBlocker;
if (isInhibitorActive(id, currentBlocker)) {
releaseInhibitor(id, currentBlocker);
}
};
/**
* check whether the inhibitor is active
* @param id id of inhibitor you want to check activity against
* @param blocker optional instance of the powerSaveBlocker to use
*/
export const isInhibitorActive = (id: number, blocker?: PowerSaveBlocker) => {
const currentBlocker = blocker ?? powerSaveBlocker;
return currentBlocker.isStarted(id);
};

View File

@ -1,5 +1,4 @@
import axios from "axios"; import axios from "axios";
import { ipcRenderer } from "electron";
import Store from "electron-store"; import Store from "electron-store";
import { settings } from "../../constants/settings"; import { settings } from "../../constants/settings";
import { MediaStatus } from "../../models/mediaStatus"; import { MediaStatus } from "../../models/mediaStatus";
@ -125,8 +124,7 @@ export class ListenBrainz {
} }
} }
} catch (error) { } catch (error) {
const logger = new Logger(ipcRenderer); Logger.log(JSON.stringify(error));
logger.log(JSON.stringify(error));
} }
} }
} }

View File

@ -1,32 +1,52 @@
import { IpcMain, IpcRenderer } from "electron"; import { IpcMain, ipcMain, IpcMainEvent, ipcRenderer } from "electron";
import { globalEvents } from "../constants/globalEvents"; import { globalEvents } from "../constants/globalEvents";
export class Logger { export class Logger {
/**
*
* @param ipcRenderer renderer IPC client so we can send messages to the main thread
*/
constructor(private ipcRenderer: IpcRenderer) {}
/** /**
* Subscribe to watch for logs from the IPC client * Subscribe to watch for logs from the IPC client
* @param ipcMain main thread IPC client so we can subscribe to events * @param ipcMain main thread IPC client so we can subscribe to events
*/ */
public static watch(ipcMain: IpcMain) { public static watch(ipcMain: IpcMain) {
ipcMain.on(globalEvents.log, (event, content, object) => { ipcMain.on(
console.log(content, JSON.stringify(object, null, 2)); globalEvents.log,
}); (event: IpcMainEvent | { content: string; message: string }, message) => {
const { content, object } = message ?? event;
this.logToSTDOut(content, object);
}
);
} }
/** /**
* Log content to STDOut * Log content to STDOut
* @param content * @param content
* @param object js(on) object that will be prettyPrinted * @param object js(on) object that will be prettyPrinted
*/ */
public log(content: string, object: object = {}) { public static log(content: string, object: object = {}) {
if (this.ipcRenderer) { if (ipcRenderer) {
this.ipcRenderer.send(globalEvents.log, { content, object }); ipcRenderer.send(globalEvents.log, { content, object });
} else {
ipcMain.emit(globalEvents.log, { content, object });
} }
console.log(`${content} \n ${JSON.stringify(object, null, 2)}`); }
/**
* Log content to STDOut and use the provided alert function to alert
* @param content
* @param object js(on) object that will be prettyPrinted
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
public static alert(content: string, object: any = {}, alert?: (msg: string) => void) {
Logger.log(content, object);
if (alert) {
alert(`${content} \n\nwith details: \n${JSON.stringify(object, null, 2)}`);
}
}
/**
* Log to STDOut
* @param content
* @param object
*/
private static logToSTDOut(content: string, object = {}) {
console.log(content, Object.keys(object).length > 0 ? JSON.stringify(object, null, 2) : "");
} }
} }

View File

@ -1,7 +1,7 @@
import { enable, initialize } from "@electron/remote/main"; import { enable, initialize } from "@electron/remote/main";
import { import {
BrowserWindow,
app, app,
BrowserWindow,
components, components,
globalShortcut, globalShortcut,
ipcMain, ipcMain,
@ -9,9 +9,18 @@ import {
session, session,
} from "electron"; } from "electron";
import path from "path"; import path from "path";
import { flags } from "./constants/flags";
import { globalEvents } from "./constants/globalEvents"; import { globalEvents } from "./constants/globalEvents";
import { mediaKeys } from "./constants/mediaKeys"; import { mediaKeys } from "./constants/mediaKeys";
import { settings } from "./constants/settings";
import { setDefaultFlags, setManagedFlagsFromSettings } from "./features/flags/flags";
import {
acquireInhibitorIfInactive,
releaseInhibitorIfActive,
} from "./features/idleInhibitor/idleInhibitor";
import { Logger } from "./features/logger";
import { Songwhip } from "./features/songwhip/songwhip";
import { MediaInfo } from "./models/mediaInfo";
import { MediaStatus } from "./models/mediaStatus";
import { initRPC, rpc, unRPC } from "./scripts/discord"; import { initRPC, rpc, unRPC } from "./scripts/discord";
import { startExpress } from "./scripts/express"; import { startExpress } from "./scripts/express";
import { updateMediaInfo } from "./scripts/mediaInfo"; import { updateMediaInfo } from "./scripts/mediaInfo";
@ -20,15 +29,12 @@ import {
closeSettingsWindow, closeSettingsWindow,
createSettingsWindow, createSettingsWindow,
hideSettingsWindow, hideSettingsWindow,
showSettingsWindow,
settingsStore, settingsStore,
showSettingsWindow,
} from "./scripts/settings"; } from "./scripts/settings";
import { settings } from "./constants/settings";
import { addTray, refreshTray } from "./scripts/tray"; import { addTray, refreshTray } from "./scripts/tray";
import { MediaInfo } from "./models/mediaInfo";
import { Songwhip } from "./features/songwhip/songwhip";
import { Logger } from "./features/logger";
const tidalUrl = "https://listen.tidal.com"; const tidalUrl = "https://listen.tidal.com";
let mainInhibitorId = -1;
initialize(); initialize();
@ -36,26 +42,8 @@ let mainWindow: BrowserWindow;
const icon = path.join(__dirname, "../assets/icon.png"); const icon = path.join(__dirname, "../assets/icon.png");
const PROTOCOL_PREFIX = "tidal"; const PROTOCOL_PREFIX = "tidal";
setFlags(); setDefaultFlags(app);
setManagedFlagsFromSettings(app);
function setFlags() {
const flagsFromSettings = settingsStore.get(settings.flags.root);
if (flagsFromSettings) {
for (const [key, value] of Object.entries(flags)) {
if (value) {
flags[key].forEach((flag) => {
console.log(`enabling command line switch ${flag.flag} with value ${flag.value}`);
app.commandLine.appendSwitch(flag.flag, flag.value);
});
}
}
}
/**
* Fix Display Compositor issue.
*/
app.commandLine.appendSwitch("disable-seccomp-filter-sandbox");
}
/** /**
* Update the menuBarVisibility according to the store value * Update the menuBarVisibility according to the store value
@ -90,8 +78,8 @@ function createWindow(options = { x: 0, y: 0, backgroundColor: "white" }) {
mainWindow = new BrowserWindow({ mainWindow = new BrowserWindow({
x: options.x, x: options.x,
y: options.y, y: options.y,
width: settingsStore && settingsStore.get(settings.windowBounds.width), width: settingsStore?.get(settings.windowBounds.width),
height: settingsStore && settingsStore.get(settings.windowBounds.height), height: settingsStore?.get(settings.windowBounds.height),
icon, icon,
backgroundColor: options.backgroundColor, backgroundColor: options.backgroundColor,
autoHideMenuBar: true, autoHideMenuBar: true,
@ -124,6 +112,7 @@ function createWindow(options = { x: 0, y: 0, backgroundColor: "white" }) {
}); });
// Emitted when the window is closed. // Emitted when the window is closed.
mainWindow.on("closed", function () { mainWindow.on("closed", function () {
releaseInhibitorIfActive(mainInhibitorId);
closeSettingsWindow(); closeSettingsWindow();
app.quit(); app.quit();
}); });
@ -196,6 +185,12 @@ app.on("browser-window-created", (_, window) => {
// IPC // IPC
ipcMain.on(globalEvents.updateInfo, (_event, arg: MediaInfo) => { ipcMain.on(globalEvents.updateInfo, (_event, arg: MediaInfo) => {
updateMediaInfo(arg); updateMediaInfo(arg);
if (arg.status === MediaStatus.playing) {
mainInhibitorId = acquireInhibitorIfInactive(mainInhibitorId);
} else {
releaseInhibitorIfActive(mainInhibitorId);
mainInhibitorId = -1;
}
}); });
ipcMain.on(globalEvents.hideSettings, () => { ipcMain.on(globalEvents.hideSettings, () => {
@ -224,7 +219,7 @@ ipcMain.on(globalEvents.error, (event) => {
}); });
ipcMain.handle(globalEvents.whip, async (event, url) => { ipcMain.handle(globalEvents.whip, async (event, url) => {
return await Songwhip.whip(url); return Songwhip.whip(url);
}); });
Logger.watch(ipcMain); Logger.watch(ipcMain);

View File

@ -3,6 +3,7 @@ import { ipcRenderer, shell } from "electron";
import fs from "fs"; import fs from "fs";
import { globalEvents } from "../../constants/globalEvents"; import { globalEvents } from "../../constants/globalEvents";
import { settings } from "../../constants/settings"; import { settings } from "../../constants/settings";
import { Logger } from "../../features/logger";
import { settingsStore } from "./../../scripts/settings"; import { settingsStore } from "./../../scripts/settings";
import { getOptions, getOptionsHeader, getThemeListFromDirectory } from "./theming"; import { getOptions, getOptionsHeader, getThemeListFromDirectory } from "./theming";
@ -28,7 +29,8 @@ let adBlock: HTMLInputElement,
updateFrequency: HTMLInputElement, updateFrequency: HTMLInputElement,
enableListenBrainz: HTMLInputElement, enableListenBrainz: HTMLInputElement,
ListenBrainzAPI: HTMLInputElement, ListenBrainzAPI: HTMLInputElement,
ListenBrainzToken: HTMLInputElement; ListenBrainzToken: HTMLInputElement,
enableWaylandSupport: HTMLInputElement;
function getThemeFiles() { function getThemeFiles() {
const selectElement = document.getElementById("themesList") as HTMLSelectElement; const selectElement = document.getElementById("themesList") as HTMLSelectElement;
@ -71,29 +73,34 @@ function handleFileUploads() {
* Sync the UI forms with the current settings * Sync the UI forms with the current settings
*/ */
function refreshSettings() { function refreshSettings() {
adBlock.checked = settingsStore.get(settings.adBlock); try {
api.checked = settingsStore.get(settings.api); adBlock.checked = settingsStore.get(settings.adBlock);
customCSS.value = settingsStore.get<string, string[]>(settings.customCSS).join("\n"); api.checked = settingsStore.get(settings.api);
disableBackgroundThrottle.checked = settingsStore.get(settings.disableBackgroundThrottle); customCSS.value = settingsStore.get<string, string[]>(settings.customCSS).join("\n");
disableHardwareMediaKeys.checked = settingsStore.get(settings.flags.disableHardwareMediaKeys); disableBackgroundThrottle.checked = settingsStore.get(settings.disableBackgroundThrottle);
enableCustomHotkeys.checked = settingsStore.get(settings.enableCustomHotkeys); disableHardwareMediaKeys.checked = settingsStore.get(settings.flags.disableHardwareMediaKeys);
enableDiscord.checked = settingsStore.get(settings.enableDiscord); enableCustomHotkeys.checked = settingsStore.get(settings.enableCustomHotkeys);
gpuRasterization.checked = settingsStore.get(settings.flags.gpuRasterization); enableDiscord.checked = settingsStore.get(settings.enableDiscord);
menuBar.checked = settingsStore.get(settings.menuBar); enableWaylandSupport.checked = settingsStore.get(settings.flags.enableWaylandSupport);
minimizeOnClose.checked = settingsStore.get(settings.minimizeOnClose); gpuRasterization.checked = settingsStore.get(settings.flags.gpuRasterization);
mpris.checked = settingsStore.get(settings.mpris); menuBar.checked = settingsStore.get(settings.menuBar);
notifications.checked = settingsStore.get(settings.notifications); minimizeOnClose.checked = settingsStore.get(settings.minimizeOnClose);
playBackControl.checked = settingsStore.get(settings.playBackControl); mpris.checked = settingsStore.get(settings.mpris);
port.value = settingsStore.get(settings.apiSettings.port); notifications.checked = settingsStore.get(settings.notifications);
singleInstance.checked = settingsStore.get(settings.singleInstance); playBackControl.checked = settingsStore.get(settings.playBackControl);
skipArtists.checked = settingsStore.get(settings.skipArtists); port.value = settingsStore.get(settings.apiSettings.port);
theme.value = settingsStore.get(settings.theme); singleInstance.checked = settingsStore.get(settings.singleInstance);
skippedArtists.value = settingsStore.get<string, string[]>(settings.skippedArtists).join("\n"); skipArtists.checked = settingsStore.get(settings.skipArtists);
trayIcon.checked = settingsStore.get(settings.trayIcon); theme.value = settingsStore.get(settings.theme);
updateFrequency.value = settingsStore.get(settings.updateFrequency); skippedArtists.value = settingsStore.get<string, string[]>(settings.skippedArtists).join("\n");
enableListenBrainz.checked = settingsStore.get(settings.ListenBrainz.enabled); trayIcon.checked = settingsStore.get(settings.trayIcon);
ListenBrainzAPI.value = settingsStore.get(settings.ListenBrainz.api); updateFrequency.value = settingsStore.get(settings.updateFrequency);
ListenBrainzToken.value = settingsStore.get(settings.ListenBrainz.token); enableListenBrainz.checked = settingsStore.get(settings.ListenBrainz.enabled);
ListenBrainzAPI.value = settingsStore.get(settings.ListenBrainz.api);
ListenBrainzToken.value = settingsStore.get(settings.ListenBrainz.token);
} catch (error) {
Logger.log("Refreshing settings failed.", error);
}
} }
/** /**
@ -146,7 +153,9 @@ window.addEventListener("DOMContentLoaded", () => {
} }
// Live update the view for ListenBrainz input, hide if disabled/show if enabled // Live update the view for ListenBrainz input, hide if disabled/show if enabled
if (source.value === "on" && source.id === "enableListenBrainz") { if (source.value === "on" && source.id === "enableListenBrainz") {
source.checked ? document.getElementById("listenbrainz__options").removeAttribute("hidden") : document.getElementById("listenbrainz__options").setAttribute("hidden", "true"); source.checked
? document.getElementById("listenbrainz__options").removeAttribute("hidden")
: document.getElementById("listenbrainz__options").setAttribute("hidden", "true");
} }
ipcRenderer.send(globalEvents.storeChanged); ipcRenderer.send(globalEvents.storeChanged);
}); });
@ -181,6 +190,7 @@ window.addEventListener("DOMContentLoaded", () => {
disableHardwareMediaKeys = get("disableHardwareMediaKeys"); disableHardwareMediaKeys = get("disableHardwareMediaKeys");
enableCustomHotkeys = get("enableCustomHotkeys"); enableCustomHotkeys = get("enableCustomHotkeys");
enableDiscord = get("enableDiscord"); enableDiscord = get("enableDiscord");
enableWaylandSupport = get("enableWaylandSupport");
gpuRasterization = get("gpuRasterization"); gpuRasterization = get("gpuRasterization");
menuBar = get("menuBar"); menuBar = get("menuBar");
minimizeOnClose = get("minimizeOnClose"); minimizeOnClose = get("minimizeOnClose");
@ -199,7 +209,9 @@ window.addEventListener("DOMContentLoaded", () => {
ListenBrainzToken = get("ListenBrainzToken"); ListenBrainzToken = get("ListenBrainzToken");
refreshSettings(); refreshSettings();
enableListenBrainz.checked ? document.getElementById("listenbrainz__options").removeAttribute("hidden") : document.getElementById("listenbrainz__options").setAttribute("hidden", "true"); enableListenBrainz.checked
? document.getElementById("listenbrainz__options").removeAttribute("hidden")
: document.getElementById("listenbrainz__options").setAttribute("hidden", "true");
addInputListener(adBlock, settings.adBlock); addInputListener(adBlock, settings.adBlock);
addInputListener(api, settings.api); addInputListener(api, settings.api);
@ -208,6 +220,7 @@ window.addEventListener("DOMContentLoaded", () => {
addInputListener(disableHardwareMediaKeys, settings.flags.disableHardwareMediaKeys); addInputListener(disableHardwareMediaKeys, settings.flags.disableHardwareMediaKeys);
addInputListener(enableCustomHotkeys, settings.enableCustomHotkeys); addInputListener(enableCustomHotkeys, settings.enableCustomHotkeys);
addInputListener(enableDiscord, settings.enableDiscord); addInputListener(enableDiscord, settings.enableDiscord);
addInputListener(enableWaylandSupport, settings.flags.enableWaylandSupport);
addInputListener(gpuRasterization, settings.flags.gpuRasterization); addInputListener(gpuRasterization, settings.flags.gpuRasterization);
addInputListener(menuBar, settings.menuBar); addInputListener(menuBar, settings.menuBar);
addInputListener(minimizeOnClose, settings.minimizeOnClose); addInputListener(minimizeOnClose, settings.minimizeOnClose);

View File

@ -258,44 +258,57 @@
<input id="updateFrequency" type="number" class="text-input" name="updateFrequency" /> <input id="updateFrequency" type="number" class="text-input" name="updateFrequency" />
</div> </div>
</div> </div>
<div class="group"> </div>
<p class="group__title">Flags</p> <div class="group">
<div class="group__option"> <p class="group__title">Flags</p>
<div class="group__description"> <div class="group__option">
<h4>Disable hardware built-in media keys</h4> <div class="group__description">
<p> <h4>Disable hardware built-in media keys</h4>
Also prevents certain desktop environments from recognizing the chrome MPRIS <p>
client separately from the custom MPRIS client. Also prevents certain desktop environments from recognizing the chrome MPRIS
</p> client separately from the custom MPRIS client.
</div> </p>
<label class="switch">
<input id="disableHardwareMediaKeys" type="checkbox" />
<span class="switch__slider"></span>
</label>
</div>
<div class="group__option">
<div class="group__description">
<h4>Enable GPU rasterization</h4>
<p>Move a part of the rendering to the GPU for increased performance.</p>
</div>
<label class="switch">
<input id="gpuRasterization" type="checkbox" />
<span class="switch__slider"></span>
</label>
</div>
<div class="group__option">
<div class="group__description">
<h4>Disable Background Throttling</h4>
<p>
Makes app more responsive while in the background, at the cost of performance.
</p>
</div>
<label class="switch">
<input id="disableBackgroundThrottle" type="checkbox" />
<span class="switch__slider"></span>
</label>
</div> </div>
<label class="switch">
<input id="disableHardwareMediaKeys" type="checkbox" />
<span class="switch__slider"></span>
</label>
</div> </div>
<div class="group__option">
<div class="group__description">
<h4>Enable GPU rasterization</h4>
<p>Move a part of the rendering to the GPU for increased performance.</p>
</div>
<label class="switch">
<input id="gpuRasterization" type="checkbox" />
<span class="switch__slider"></span>
</label>
</div>
<div class="group__option">
<div class="group__description">
<h4>Disable Background Throttling</h4>
<p>
Makes app more responsive while in the background, at the cost of performance.
</p>
</div>
<label class="switch">
<input id="disableBackgroundThrottle" type="checkbox" />
<span class="switch__slider"></span>
</label>
</div>
<div class="group__option">
<div class="group__description">
<h4>Wayland support</h4>
<p>
Adds a couple of Electron flags to help Tidal-hifi run smoothly on the Wayland window system.
</p>
</div>
<label class="switch">
<input id="enableWaylandSupport" type="checkbox" />
<span class="switch__slider"></span>
</label>
</div>
</div>
</section> </section>
<section id="theming-section" class="tabs__section"> <section id="theming-section" class="tabs__section">

View File

@ -1,4 +1,5 @@
import fs from "fs"; import fs from "fs";
import { Logger } from "../../features/logger";
const cssFilter = (file: string) => file.endsWith(".css"); const cssFilter = (file: string) => file.endsWith(".css");
const sort = (a: string, b: string) => a.toLowerCase().localeCompare(b.toLowerCase()); const sort = (a: string, b: string) => a.toLowerCase().localeCompare(b.toLowerCase());
@ -36,7 +37,7 @@ export const getThemeListFromDirectory = (directory: string): string[] => {
makeUserThemesDirectory(directory); makeUserThemesDirectory(directory);
return fs.readdirSync(directory).filter(cssFilter).sort(sort); return fs.readdirSync(directory).filter(cssFilter).sort(sort);
} catch (err) { } catch (err) {
console.error(err); Logger.log(`Failed to get files from ${directory}`, err);
return []; return [];
} }
}; };
@ -49,6 +50,6 @@ export const makeUserThemesDirectory = (directory: string) => {
try { try {
fs.mkdirSync(directory, { recursive: true }); fs.mkdirSync(directory, { recursive: true });
} catch (err) { } catch (err) {
console.error(err); Logger.log(`Failed to make user theme directory: ${directory}`, err);
} }
}; };

View File

@ -4,19 +4,20 @@ import fs from "fs";
import Player from "mpris-service"; import Player from "mpris-service";
import { globalEvents } from "./constants/globalEvents"; import { globalEvents } from "./constants/globalEvents";
import { settings } from "./constants/settings"; import { settings } from "./constants/settings";
import { Songwhip } from "./features/songwhip/songwhip";
import { import {
ListenBrainz, ListenBrainz,
ListenBrainzConstants, ListenBrainzConstants,
ListenBrainzStore, ListenBrainzStore,
} from "./features/listenbrainz/listenbrainz"; } from "./features/listenbrainz/listenbrainz";
import { StoreData } from "./features/listenbrainz/models/storeData";
import { Logger } from "./features/logger";
import { Songwhip } from "./features/songwhip/songwhip";
import { MediaStatus } from "./models/mediaStatus";
import { Options } from "./models/options"; import { Options } from "./models/options";
import { downloadFile } from "./scripts/download"; import { downloadFile } from "./scripts/download";
import { addHotkey } from "./scripts/hotkeys"; import { addHotkey } from "./scripts/hotkeys";
import { settingsStore } from "./scripts/settings"; import { settingsStore } from "./scripts/settings";
import { setTitle } from "./scripts/window-functions"; import { setTitle } from "./scripts/window-functions";
import { StoreData } from "./features/listenbrainz/models/storeData";
import { MediaStatus } from "./models/mediaStatus";
const notificationPath = `${app.getPath("userData")}/notification.jpg`; const notificationPath = `${app.getPath("userData")}/notification.jpg`;
const appName = "Tidal Hifi"; const appName = "Tidal Hifi";
@ -157,12 +158,14 @@ const elements = {
function addCustomCss() { function addCustomCss() {
window.addEventListener("DOMContentLoaded", () => { window.addEventListener("DOMContentLoaded", () => {
const selectedTheme = settingsStore.get(settings.theme); const selectedTheme = settingsStore.get<string, string>(settings.theme);
if (selectedTheme !== "none") { if (selectedTheme !== "none") {
const themeFile = `${process.resourcesPath}/${selectedTheme}`; const userThemePath = `${app.getPath("userData")}/themes/${selectedTheme}`;
const resourcesThemePath = `${process.resourcesPath}/${selectedTheme}`;
const themeFile = fs.existsSync(userThemePath) ? userThemePath : resourcesThemePath;
fs.readFile(themeFile, "utf-8", (err, data) => { fs.readFile(themeFile, "utf-8", (err, data) => {
if (err) { if (err) {
alert("An error ocurred reading the theme file."); Logger.alert("An error ocurred reading the theme file.", err, alert);
return; return;
} }

View File

@ -24,8 +24,9 @@ export const settingsStore = new Store({
token: "", token: "",
}, },
flags: { flags: {
gpuRasterization: true,
disableHardwareMediaKeys: false, disableHardwareMediaKeys: false,
enableWaylandSupport: true,
gpuRasterization: true,
}, },
menuBar: true, menuBar: true,
minimizeOnClose: false, minimizeOnClose: false,