Skip to content

Commit

Permalink
Merge pull request #195 from Mastermindzh/feature/4.4.0
Browse files Browse the repository at this point in the history
Feature/4.4.0
  • Loading branch information
Mastermindzh authored Jan 22, 2023
2 parents 115d8c6 + 3b316f2 commit d0f9a34
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 15 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ 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).

## 4.4.0

- Updated shortcut hint on the menubar to reflect the new `ctrl+=` shortcut.
- Reverted icon path to `icon.png` instead of the hardcoded linux path.
- Add support to autoHide the menubar and showing it with the `alt` key.
- Move the quit command from the system sub-menu to the main menu
- Added single click focus/show on the tray icon
- Doesn't work on all platforms. Nothing I can do about that unfortunately!
- Added a list of artists to automatically skip.
- I don't like the vast majority of dutch music so I added one of them to my list to test: [./docs/no-dutch-music.mp4](./docs/no-dutch-music.mp4)

## 4.3.1

- fix: App always requests a default-url-handler-scheme change on start
Expand Down
2 changes: 1 addition & 1 deletion build/electron-builder.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ linux:
Name: TIDAL Hi-Fi
GenericName: TIDAL Hi-Fi
Comment: The web version of listen.tidal.com running in electron with hifi support thanks to widevine.
Icon: /usr/share/icons/hicolor/0x0/apps/tidal-hifi.png
Icon: icon.png
StartupNotify: true
Terminal: false
Type: Application
Expand Down
Binary file added docs/no-dutch-music.mp4
Binary file not shown.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tidal-hifi",
"version": "4.3.1",
"version": "4.4.0",
"description": "Tidal on Electron with widevine(hifi) support",
"main": "src/main.js",
"scripts": {
Expand Down Expand Up @@ -50,4 +50,4 @@
"sass-lint-auto-fix": "^0.21.2"
},
"prettier": "@mastermindzh/prettier-config"
}
}
2 changes: 2 additions & 0 deletions src/constants/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ const settings = {
playBackControl: "playBackControl",
muteArtists: "muteArtists",
mutedArtists: "mutedArtists",
skipArtists: "skipArtists",
skippedArtists: "skippedArtists",
disableBackgroundThrottle: "disableBackgroundThrottle",
apiSettings: {
root: "apiSettings",
Expand Down
8 changes: 6 additions & 2 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ function setFlags() {
*
*/
function syncMenuBarWithStore() {
mainWindow.setMenuBarVisibility(store.get(settings.menuBar));
const fixedMenuBar = store.get(settings.menuBar);

mainWindow.autoHideMenuBar = !fixedMenuBar;
mainWindow.setMenuBarVisibility(fixedMenuBar);
}

/**
Expand Down Expand Up @@ -78,6 +81,7 @@ function createWindow(options = {}) {
height: store && store.get(settings.windowBounds.height),
icon,
backgroundColor: options.backgroundColor,
autoHideMenuBar: true,
webPreferences: {
preload: path.join(__dirname, "preload.js"),
plugins: true,
Expand Down Expand Up @@ -123,7 +127,7 @@ function registerHttpProtocols() {
protocol.registerHttpProtocol(PROTOCOL_PREFIX, (request, _callback) => {
mainWindow.loadURL(`${tidalUrl}/${request.url.substring(PROTOCOL_PREFIX.length + 3)}`);
});
if (!app.isDefaultProtocolClient(PROTOCOL_PREFIX)) {
if (!app.isDefaultProtocolClient(PROTOCOL_PREFIX)) {
app.setAsDefaultProtocolClient(PROTOCOL_PREFIX);
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/pages/settings/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ let trayIcon,
enableCustomHotkeys,
enableDiscord,
muteArtists,
skipArtists,
notifications,
playBackControl,
api,
port,
menuBar,
mutedArtists,
skippedArtists,
disableBackgroundThrottle,
singleInstance,
disableHardwareMediaKeys,
Expand All @@ -36,6 +38,8 @@ function refreshSettings() {
minimizeOnClose.checked = store.get(settings.minimizeOnClose);
muteArtists.checked = store.get(settings.muteArtists);
mutedArtists.value = store.get(settings.mutedArtists).join("\n");
skipArtists.checked = store.get(settings.skipArtists);
skippedArtists.value = store.get(settings.skippedArtists).join("\n");
singleInstance.checked = store.get(settings.singleInstance);
disableHardwareMediaKeys.checked = store.get(settings.flags.disableHardwareMediaKeys);
gpuRasterization.checked = store.get(settings.flags.gpuRasterization);
Expand Down Expand Up @@ -119,6 +123,8 @@ window.addEventListener("DOMContentLoaded", () => {
enableDiscord = get("enableDiscord");
muteArtists = get("muteArtists");
mutedArtists = get("mutedArtists");
skipArtists = get("skipArtists");
skippedArtists = get("skippedArtists");
disableBackgroundThrottle = get("disableBackgroundThrottle");
singleInstance = get("singleInstance");
disableHardwareMediaKeys = get("disableHardwareMediaKeys");
Expand All @@ -138,6 +144,8 @@ window.addEventListener("DOMContentLoaded", () => {
addInputListener(minimizeOnClose, settings.minimizeOnClose);
addInputListener(muteArtists, settings.muteArtists);
addTextAreaListener(mutedArtists, settings.mutedArtists);
addInputListener(skipArtists, settings.skipArtists);
addTextAreaListener(skippedArtists, settings.skippedArtists);
addInputListener(disableBackgroundThrottle, settings.disableBackgroundThrottle);
addInputListener(singleInstance, settings.singleInstance);
addInputListener(disableHardwareMediaKeys, settings.flags.disableHardwareMediaKeys);
Expand Down
18 changes: 15 additions & 3 deletions src/pages/settings/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,25 @@ <h4>Mute Artists automatically</h4>
</label>
</div>
<textarea id="mutedArtists" class="textarea" cols="40" rows="5" spellcheck="false"></textarea>
<div class="group__option">
<div class="group__description">
<h4>Skip Artists automatically</h4>
<p>The following list of artists (1 per line) will be skipped automatically.</p>
</div>
<label class="switch">
<input id="skipArtists" type="checkbox">
<span class="switch__slider"></span>
</label>
</div>
<textarea id="skippedArtists" class="textarea" cols="40" rows="5" spellcheck="false"></textarea>

</div>
<div class="group">
<p class="group__title">UI</p>
<div class="group__option">
<div class="group__description">
<h4>Menubar</h4>
<p>Show TIDAL Hi-Fi's menu bar.</p>
<h4>Fixed menubar</h4>
<p>Always show TIDAL Hi-Fi's menu bar.</p>
</div>
<label class="switch">
<input id="menuBar" type="checkbox">
Expand Down Expand Up @@ -255,4 +267,4 @@ <h4>Disable Background Throttling</h4>
</div>
</body>

</html>
</html>
24 changes: 18 additions & 6 deletions src/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const { downloadFile } = require("./scripts/download");
const statuses = require("./constants/statuses");
const hotkeys = require("./scripts/hotkeys");
const globalEvents = require("./constants/globalEvents");
const { skipArtists } = require("./constants/settings");
const notificationPath = `${app.getPath("userData")}/notification.jpg`;
const appName = "Tidal Hifi";
let currentSong = "";
Expand Down Expand Up @@ -327,8 +328,9 @@ function getTrackURL() {
setInterval(function () {
const title = elements.getText("title");
const artists = elements.getArtists();
muteArtistIfFoundInMutedArtistsList(); // doing this here so that nothing can possibly fail before we call this function

skipArtistsIfFoundInSkippedArtistsList(artists);
muteArtistIfFoundInMutedArtistsList(artists); // doing this here so that nothing can possibly fail before we call this function

const album = elements.getAlbumName();
const current = elements.getText("current");
const duration = elements.getText("duration");
Expand All @@ -344,12 +346,9 @@ setInterval(function () {
duration,
"app-name": appName,
};



const titleOrArtistChanged = currentSong !== songDashArtistTitle;


// update title, url and play info with new info
setTitle(songDashArtistTitle);
getTrackURL();
Expand Down Expand Up @@ -385,7 +384,7 @@ setInterval(function () {
/**
* Checks whether the current artist is included in the "muted artists" list and if so it will automatically mute the player
*/
function muteArtistIfFoundInMutedArtistsList() {
function muteArtistIfFoundInMutedArtistsList(artists) {
if (store.get(settings.muteArtists)) {
const mutedArtists = store.get(settings.mutedArtists);
if (mutedArtists.find((artist) => artist === artists) !== undefined) {
Expand All @@ -399,6 +398,19 @@ setInterval(function () {
}
}
}

/**
* automatically skip a song if the artists are found in the list of artists to skip
* @param {*} artists list of artists to skip
*/
function skipArtistsIfFoundInSkippedArtistsList(artists) {
if (store.get(skipArtists)) {
const skippedArtists = store.get(settings.skippedArtists);
if (skippedArtists.find((artist) => artist === artists) !== undefined) {
elements.click("next");
}
}
}
}, 1000);

if (process.platform === "linux" && store.get(settings.mpris)) {
Expand Down
3 changes: 2 additions & 1 deletion src/scripts/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const settingsMenuEntry = {
click() {
showSettingsWindow();
},
accelerator: "Control+/",
accelerator: "Control+=",
};

const quitMenuEntry = {
Expand Down Expand Up @@ -110,6 +110,7 @@ menuModule.getMenu = function (mainWindow) {
},
},
toggleWindow,
quitMenuEntry,
];

return Menu.buildFromTemplate(mainMenu);
Expand Down
2 changes: 2 additions & 0 deletions src/scripts/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ const store = new Store({
playBackControl: true,
muteArtists: false,
mutedArtists: ["TIDAL"],
skipArtists: false,
skippedArtists: [""],
disableBackgroundThrottle: true,
menuBar: true,
apiSettings: {
Expand Down
4 changes: 4 additions & 0 deletions src/scripts/tray.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ trayModule.addTray = function (mainWindow, options = { icon: "" }) {
const menu = getMenu(mainWindow);

tray.setContextMenu(menu);

tray.on("click", function () {
mainWindow.isVisible() ? mainWindow.focus() : mainWindow.show();
});
};

trayModule.refreshTray = function (mainWindow) {
Expand Down

0 comments on commit d0f9a34

Please sign in to comment.