@@ -26,6 +26,40 @@ electron.app.commandLine.appendSwitch("remote-allow-origins", "http://localhost:
2626if ( process . platform === "linux" ) {
2727 // Zygote causes sandbox initialization failures on some Linux configurations
2828 electron . app . commandLine . appendSwitch ( "no-zygote" ) ;
29+
30+ // Match tidal-hifi's .desktop StartupWMClass so GNOME/KDE shows the correct dock icon
31+ // --class works for X11, CHROME_DESKTOP sets the Wayland app_id
32+ electron . app . commandLine . appendSwitch ( "class" , "tidal-hifi" ) ;
33+ electron . app . name = "tidal-hifi" ;
34+ process . env . CHROME_DESKTOP = "tidal-hifi.desktop" ;
35+
36+ // tidal-hifi settings access for Linux integration
37+ ipcHandle ( "__Luna.getTidalHifiSetting" , async ( _ , key : string ) => {
38+ try {
39+ const configPath = path . join ( electron . app . getPath ( "userData" ) , "config.json" ) ;
40+ const config = JSON . parse ( await readFile ( configPath , "utf8" ) ) ;
41+ // Support nested keys like "discord.showSong"
42+ return key . split ( "." ) . reduce ( ( obj , k ) => obj ?. [ k ] , config ) ;
43+ } catch {
44+ return undefined ;
45+ }
46+ } ) ;
47+
48+ // tidal-hifi theme file reading
49+ ipcHandle ( "__Luna.getTidalHifiThemeCSS" , async ( _ , themeName : string ) => {
50+ if ( ! themeName || themeName === "none" ) return undefined ;
51+ const userPath = path . join ( electron . app . getPath ( "userData" ) , "themes" , themeName ) ;
52+ const resourcesPath = path . join ( process . resourcesPath , themeName ) ;
53+ try {
54+ return await readFile ( userPath , "utf8" ) ;
55+ } catch {
56+ try {
57+ return await readFile ( resourcesPath , "utf8" ) ;
58+ } catch {
59+ return undefined ;
60+ }
61+ }
62+ } ) ;
2963}
3064
3165const bundleFile = async ( url : string ) : Promise < [ Buffer , ResponseInit ] > => {
@@ -54,7 +88,7 @@ const lunaBundle = bundleFile("https://luna/luna.mjs").then(([content]) => conte
5488ipcHandle ( "__Luna.renderJs" , ( ) => lunaBundle ) ;
5589
5690// #region HTTPS Handler
57- const tidalMainHosts = new Set ( [ "listen.tidal.com" , "tidal.com" , "desktop.tidal.com" ] ) ;
91+ const tidalMainHosts = new Set ( [ "listen.tidal.com" , "tidal.com" , "desktop.tidal.com" , "stage.tidal.com" ] ) ;
5892let httpsHandlerActive = false ;
5993
6094const httpsHandler = async ( req : Request ) : Promise < Response > => {
@@ -150,12 +184,7 @@ const ProxiedBrowserWindow = new Proxy(electron.BrowserWindow, {
150184 // Ensure smoothScrolling is always enabled
151185 options . webPreferences . smoothScrolling = true ;
152186
153- // explicitly set icon before load on linux
154187 const platformIsLinux = process . platform === "linux" ;
155- const iconPath = path . join ( tidalAppPath , "assets/icon.png" ) ;
156- if ( platformIsLinux ) {
157- options . icon = iconPath ;
158- }
159188
160189 // Check if this is the main Tidal window
161190 // tidal-hifi does not set the title, rely on dev tools instead.
@@ -190,7 +219,6 @@ const ProxiedBrowserWindow = new Proxy(electron.BrowserWindow, {
190219
191220 globalThis . luna . sendToRender = window . webContents . send ;
192221
193-
194222 // Linux (tidal-hifi): Handle OAuth login in a popup window
195223 if ( platformIsLinux ) {
196224 let loginWindow : electron . BrowserWindow | null = null ;
@@ -265,14 +293,6 @@ const ProxiedBrowserWindow = new Proxy(electron.BrowserWindow, {
265293 } ) ;
266294 } ) ;
267295
268- // if we are on linux and this is the main tidal window,
269- // set the icon again after load (potential KDE quirk)
270- if ( platformIsLinux && isTidalWindow ) {
271- window . webContents . once ( "did-finish-load" , ( ) => {
272- window . setIcon ( iconPath ) ;
273- } ) ;
274- }
275-
276296 // #region Open from link
277297 // MacOS
278298 electron . app . setAsDefaultProtocolClient ( "tidaLuna" ) ;
@@ -353,9 +373,11 @@ electron.Menu.buildFromTemplate = (template) => {
353373 template . push ( {
354374 role : "toggleDevTools" ,
355375 visible : false ,
376+ accelerator : "F12" ,
356377 } ) ;
357378 return originalBuildFromTemplate ( template ) ;
358379} ;
380+
359381// #endregion
360382
361383// #region Start app
@@ -371,3 +393,4 @@ ipcHandle("__Luna.preloadErr", async (_, err: Error) => {
371393 console . error ( err ) ;
372394 electron . dialog . showErrorBox ( "TidaLuna" , err . message ) ;
373395} ) ;
396+
0 commit comments