Skip to content

Commit

Permalink
Added a separate advanced options settings panel with flags
Browse files Browse the repository at this point in the history
  - Added gpu-rasterization flag

config setting `disableHardwareMediaKeys` moved to `flags.disableHardwareMediaKeys`, it will be migrated automatically
  • Loading branch information
Mastermindzh committed May 7, 2022
1 parent 3965ada commit 374f3da
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 32 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ 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/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 3.1.0

- Added a separate advanced options settings panel with flags
- Added gpu-rasterization flag
- config setting `disableHardwareMediaKeys` moved to `flags.disableHardwareMediaKeys`, it will be migrated automatically

## 3.0.0

- Updated to Electron 15
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": "tidal-hifi",
"version": "3.0.0",
"version": "3.1.0",
"description": "Tidal on Electron with widevine(hifi) support",
"main": "src/main.js",
"scripts": {
Expand Down
6 changes: 6 additions & 0 deletions src/constants/flags.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const flags = {
gpuRasterization: [{ flag: "enable-gpu-rasterization", value: undefined }],
disableHardwareMediaKeys: [{ flag: "disable-features", value: "HardwareMediaKeyHandling" }],
};

module.exports = flags;
4 changes: 4 additions & 0 deletions src/constants/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ const settings = {
},
singleInstance: "singleInstance",
disableHardwareMediaKeys: "disableHardwareMediaKeys",
flags: {
disableHardwareMediaKeys: "flags.disableHardwareMediaKeys",
gpuRasterization: "flags.gpuRasterization",
},
mpris: "mpris",
enableCustomHotkeys: "enableCustomHotkeys",
trayIcon: "trayIcon",
Expand Down
28 changes: 19 additions & 9 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,30 @@ const mediaKeys = require("./constants/mediaKeys");
const mediaInfoModule = require("./scripts/mediaInfo");
const discordModule = require("./scripts/discord");
const globalEvents = require("./constants/globalEvents");
const flagValues = require("./constants/flags");

let mainWindow;
let icon = path.join(__dirname, "../assets/icon.png");

/**
* Fix Display Compositor issue.
*/
app.commandLine.appendSwitch("disable-seccomp-filter-sandbox");
setFlags();

function setFlags() {
const flags = store.get().flags;
if (flags) {
for (const [key, value] of Object.entries(flags)) {
if (value) {
flagValues[key].forEach((flag) => {
console.log(`enabling command line switch ${flag.flag} with value ${flag.value}`);
app.commandLine.appendSwitch(flag.flag, flag.value);
});
}
}
}

/**
* Disable media keys when requested
*/
if (store.get(settings.disableHardwareMediaKeys)) {
app.commandLine.appendSwitch("disable-features", "HardwareMediaKeyHandling");
/**
* Fix Display Compositor issue.
*/
app.commandLine.appendSwitch("disable-seccomp-filter-sandbox");
}

/**
Expand Down
10 changes: 7 additions & 3 deletions src/pages/settings/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ let trayIcon,
menuBar,
mutedArtists,
singleInstance,
disableHardwareMediaKeys;
disableHardwareMediaKeys,
gpuRasterization;

const { store, settings } = require("./../../scripts/settings");
const { ipcRenderer } = require("electron");
Expand All @@ -35,7 +36,8 @@ function refreshSettings() {
muteArtists.checked = store.get(settings.muteArtists);
mutedArtists.value = store.get(settings.mutedArtists).join("\n");
singleInstance.checked = store.get(settings.singleInstance);
disableHardwareMediaKeys.checked = store.get(settings.disableHardwareMediaKeys);
disableHardwareMediaKeys.checked = store.get(settings.flags.disableHardwareMediaKeys);
gpuRasterization.checked = store.get(settings.flags.gpuRasterization);
}

/**
Expand Down Expand Up @@ -117,6 +119,7 @@ window.addEventListener("DOMContentLoaded", () => {
mutedArtists = get("mutedArtists");
singleInstance = get("singleInstance");
disableHardwareMediaKeys = get("disableHardwareMediaKeys");
gpuRasterization = get("gpuRasterization");

refreshSettings();

Expand All @@ -133,5 +136,6 @@ window.addEventListener("DOMContentLoaded", () => {
addInputListener(muteArtists, settings.muteArtists);
addTextAreaListener(mutedArtists, settings.mutedArtists);
addInputListener(singleInstance, settings.singleInstance);
addInputListener(disableHardwareMediaKeys, settings.disableHardwareMediaKeys);
addInputListener(disableHardwareMediaKeys, settings.flags.gpuRasterization);
addInputListener(gpuRasterization, settings.flags.gpuRasterization);
});
58 changes: 39 additions & 19 deletions src/pages/settings/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ <h1 class="title">Settings</h1>
<input type="radio" name="tabset" id="integrations" />
<label for="integrations">Integrations</label>

<!-- advanced tab -->
<input type="radio" name="tabset" id="advanced" />
<label for="advanced">Advanced</label>
<!-- about tab -->
<input type="radio" name="tabset" id="about" />
<label for="about">About</label>
Expand Down Expand Up @@ -122,17 +125,6 @@ <h4>Single instance</h4>
<span class="slider round"></span>
</label>
</div>
<div class="option">
<h4>Disable hardware media keys</h4>
<p>
Disable built-in media keys. <br />
Also prevents certain desktop environments from recognizing the chrome MPRIS client separetely from the custom MPRIS client.
</p>
<label class="switch">
<input id="disableHardwareMediaKeys" type="checkbox">
<span class="slider round"></span>
</label>
</div>
</div>
</section>
<section id="api" class="tab-panel">
Expand Down Expand Up @@ -196,16 +188,44 @@ <h4>Discord RPC</h4>
</div>
</div>
</section>
<section id="about" class="tab-panel">
<div class="section">
<img alt="tidal icon" style="width: 100px; height: auto; display: block; margin: 0 auto; margin-bottom: 20px; margin-top: 20px;" src = "./icon.png">
<p style="max-width: 350px; display:block; margin: 0 auto; text-align: center;">
<a id="openExternal" style="text-decoration: underline; cursor: pointer;" data-url="https://github.com/Mastermindzh/tidal-hifi">Tidal-hifi</a> is made by <a id="openExternal" data-url="https://www.rickvanlieshout.com" style="text-decoration: underline; cursor: pointer;">Rick van Lieshout</a>.<br />
It uses <a style="text-decoration: underline; cursor: pointer;" id="openExternal" data-url="https://castlabs.com/">Castlabs'</a> versions of Electron for widevine support.
</p>

<section id="advanced" class="tab-panel">
<div class="section">
<h3>Flags</h3>
<div class="option">
<h4>Disable hardware media keys</h4>
<p>
Disable built-in media keys. <br />
Also prevents certain desktop environments from recognizing the chrome MPRIS client separetely from the custom MPRIS client.
</p>
<label class="switch">
<input id="disableHardwareMediaKeys" type="checkbox">
<span class="slider round"></span>
</label>
</div>
</section>
<div class="option">
<h4>Enable GPU rasterization</h4>
<p>
Move a part of the rendering to the GPU for increased performance.
</p>
<label class="switch">
<input id="gpuRasterization" type="checkbox">
<span class="slider round"></span>
</label>
</div>
</div>
</section>

<!-- about -->
<section id="about" class="tab-panel">
<div class="section">
<img alt="tidal icon" style="width: 100px; height: auto; display: block; margin: 0 auto; margin-bottom: 20px; margin-top: 20px;" src = "./icon.png">
<p style="max-width: 350px; display:block; margin: 0 auto; text-align: center;">
<a id="openExternal" style="text-decoration: underline; cursor: pointer;" data-url="https://github.com/Mastermindzh/tidal-hifi">Tidal-hifi</a> is made by <a id="openExternal" data-url="https://www.rickvanlieshout.com" style="text-decoration: underline; cursor: pointer;">Rick van Lieshout</a>.<br />
It uses <a style="text-decoration: underline; cursor: pointer;" id="openExternal" data-url="https://castlabs.com/">Castlabs'</a> versions of Electron for widevine support.
</p>
</div>
</section>

<small>Some settings require a restart of Tidal-hifi. To do so, click the button below:</small>
<button id="restart" style ="width: 100%">Restart Tidal-hifi</button>
Expand Down
13 changes: 13 additions & 0 deletions src/scripts/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ const store = new Store({
enableCustomHotkeys: false,
enableDiscord: false,
windowBounds: { width: 800, height: 600 },
flags: {
gpuRasterization: true,
disableHardwareMediaKeys: false,
},
},
migrations: {
"3.1.0": (migrationStore) => {
console.log("running migrations for 3.1.0");
migrationStore.set(
settings.flags.disableHardwareMediaKeys,
migrationStore.get("disableHardwareMediaKeys") ?? false
);
},
},
});

Expand Down

2 comments on commit 374f3da

@htdhnsdjetsr
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really approve this change! Thanks for adding this!

@Mastermindzh
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem @licentiapoetica,

Enjoy the app!

Please sign in to comment.