Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux使用Electron版本不显示桌面歌词,为纯黑色背景 #266

Open
ruiwala opened this issue Jul 28, 2022 · 5 comments
Open

Linux使用Electron版本不显示桌面歌词,为纯黑色背景 #266

ruiwala opened this issue Jul 28, 2022 · 5 comments

Comments

@ruiwala
Copy link

ruiwala commented Jul 28, 2022

使用的版本来自AUR仓库:https://aur.archlinux.org/packages/yesplaymusicosd-electron-git
Manjaro Linux+Gnome42.3
截图 2022-07-28 22-20-12

@arenekosreal
Copy link

使用终端运行时发现打开歌词的时候带有这样一行输出:

(node:166478) electron: Failed to load URL: http://localhost:27232/osdlyrics.html with error: ERR_CONNECTION_REFUSED

应该与此有关

@Mirei124
Copy link

Mirei124 commented Nov 4, 2022

把27232改成41342就行

this.osdlyrics.loadURL('http://localhost:27232/osdlyrics.html');

@arenekosreal
Copy link

把27232改成41342就行

this.osdlyrics.loadURL('http://localhost:27232/osdlyrics.html');

image
感谢给出解决方案,虽然总比没有显示要好,但我很好奇这样真的是没问题的吗(

@Mirei124
Copy link

Mirei124 commented Nov 4, 2022

electron 的bug cant-succeed-in-making-transparent-window-in-electron-javascript
我用的arch+kde这样修改可以正常显示

diff --git a/src/background.js b/src/background.js
index 00bff0e..a6aca10 100644
--- a/src/background.js
+++ b/src/background.js
@@ -126,6 +126,11 @@ class Background {
         'HardwareMediaKeyHandling,MediaSessionService'
       );
     }
+
+    // display transparent window on linux
+    if (isLinux) {
+      app.commandLine.appendSwitch('use-gl', 'desktop');
+    }
   }
 
   async initDevtools() {
@@ -290,7 +295,7 @@ class Background {
       );
       if (!process.env.IS_TEST) this.osdlyrics.webContents.openDevTools();
     } else {
-      this.osdlyrics.loadURL('http://localhost:27232/osdlyrics.html');
+      this.osdlyrics.loadURL('http://localhost:41342/osdlyrics.html');
     }
   }
 
@@ -468,6 +473,9 @@ class Background {
         this.initDevtools();
       }
 
+      if (isLinux) {
+        await new Promise(r => setTimeout(r, 300));
+      }
       // create window
       this.createWindow();
       this.window.once('ready-to-show', () => {

@arenekosreal
Copy link

arenekosreal commented Nov 4, 2022

我觉得这个可以直接给这个项目提拉取请求了
在 AUR 上自己打包了一个 yesplaymusicosd-origin-git 的软件包,已合并上述修正,另外软件包源代码直接来自这个项目,和 yesplaymusicosd-electron-git 相比无额外更改。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants