Skip to content

Commit

Permalink
feat: Added ability to keep a static window title.
Browse files Browse the repository at this point in the history
  • Loading branch information
darkiox committed Oct 21, 2024
1 parent 91156e5 commit cb8667b
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/constants/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export const settings = {
skippedArtists: "skippedArtists",
theme: "theme",
trayIcon: "trayIcon",
staticWindowTitle: "staticWindowTitle",
updateFrequency: "updateFrequency",
windowBounds: {
root: "windowBounds",
Expand Down
4 changes: 4 additions & 0 deletions src/pages/settings/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ let adBlock: HTMLInputElement,
skippedArtists: HTMLInputElement,
theme: HTMLSelectElement,
trayIcon: HTMLInputElement,
staticWindowTitle: HTMLInputElement,
updateFrequency: HTMLInputElement,
enableListenBrainz: HTMLInputElement,
ListenBrainzAPI: HTMLInputElement,
Expand Down Expand Up @@ -143,6 +144,7 @@ function refreshSettings() {
theme.value = settingsStore.get(settings.theme);
skippedArtists.value = settingsStore.get<string, string[]>(settings.skippedArtists).join("\n");
trayIcon.checked = settingsStore.get(settings.trayIcon);
staticWindowTitle.checked = settingsStore.get(settings.staticWindowTitle);
updateFrequency.value = settingsStore.get(settings.updateFrequency);
enableListenBrainz.checked = settingsStore.get(settings.ListenBrainz.enabled);
ListenBrainzAPI.value = settingsStore.get(settings.ListenBrainz.api);
Expand Down Expand Up @@ -259,6 +261,7 @@ window.addEventListener("DOMContentLoaded", () => {
port = get("port");
theme = get<HTMLSelectElement>("themesList");
trayIcon = get("trayIcon");
staticWindowTitle = get("staticWindowTitle");
skipArtists = get("skipArtists");
skippedArtists = get("skippedArtists");
singleInstance = get("singleInstance");
Expand Down Expand Up @@ -298,6 +301,7 @@ window.addEventListener("DOMContentLoaded", () => {
addInputListener(singleInstance, settings.singleInstance);
addSelectListener(theme, settings.theme);
addInputListener(trayIcon, settings.trayIcon);
addInputListener(staticWindowTitle, settings.staticWindowTitle);
addInputListener(updateFrequency, settings.updateFrequency);
addInputListener(
enableListenBrainz,
Expand Down
10 changes: 10 additions & 0 deletions src/pages/settings/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,16 @@ <h4>Tray icon</h4>
<span class="switch__slider"></span>
</label>
</div>
<div class="group__option">
<div class="group__description">
<h4>Static Window Title</h4>
<p>Makes the window title "TIDAL Hi-Fi" instead of changing to the currently playing song.</p>
</div>
<label class="switch">
<input id="staticWindowTitle" type="checkbox" />
<span class="switch__slider"></span>
</label>
</div>
<div class="group__option">
<div class="group__description">
<h4>Minimize on Close</h4>
Expand Down
4 changes: 3 additions & 1 deletion src/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ setInterval(function () {
const artistsArray = elements.getArtistsArray();
const artistsString = elements.getArtistsString(artistsArray);
const songDashArtistTitle = `${title} - ${artistsString}`;
const staticTitle = "TIDAL Hi-Fi"
const titleOrArtistsChanged = currentSong !== songDashArtistTitle;
const current = elements.getText("current");
const currentStatus = getCurrentlyPlayingStatus();
Expand Down Expand Up @@ -594,7 +595,8 @@ setInterval(function () {
};

// update title, url and play info with new info
setTitle(songDashArtistTitle);
if(settingsStore.get(settings.staticWindowTitle)) setTitle(staticTitle)
else setTitle(songDashArtistTitle);
getTrackURL();
currentSong = songDashArtistTitle;
currentPlayStatus = currentStatus;
Expand Down
9 changes: 5 additions & 4 deletions src/scripts/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export const settingsStore = new Store({
skippedArtists: [""],
theme: "none",
trayIcon: true,
staticWindowTitle: false,
updateFrequency: 500,
windowBounds: { width: 800, height: 600 },
},
Expand Down Expand Up @@ -127,7 +128,7 @@ const settingsModule = {
settingsWindow,
};

export const createSettingsWindow = function () {
export const createSettingsWindow = function() {
settingsWindow = new BrowserWindow({
width: 650,
height: 700,
Expand Down Expand Up @@ -159,7 +160,7 @@ export const createSettingsWindow = function () {
settingsModule.settingsWindow = settingsWindow;
};

export const showSettingsWindow = function (tab = "general") {
export const showSettingsWindow = function(tab = "general") {
if (!settingsWindow) {
console.log("Settings window is not initialized. Attempting to create it.");
createSettingsWindow();
Expand All @@ -170,11 +171,11 @@ export const showSettingsWindow = function (tab = "general") {
settingsWindow.webContents.send("refreshData");
settingsWindow.show();
};
export const hideSettingsWindow = function () {
export const hideSettingsWindow = function() {
settingsWindow.hide();
};

export const closeSettingsWindow = function () {
export const closeSettingsWindow = function() {
settingsWindow = null;
};

Expand Down

0 comments on commit cb8667b

Please sign in to comment.