Web浏览器将打开vScode(Ubuntu和Live Server)

发布于 2025-01-30 04:09:48 字数 371 浏览 6 评论 0 原文

I am trying to configure Visual Studio Code (in Ubuntu 22.04) and Live Server extension (Ritwick Dey).
When I run Live Server, it opens a new window of my web browser (Firefox) that it attaches with VSCode as a new window.
I want the Live server to open a Firefox BUT non attached with VSCode. And, if Firefox is already open, it opens the page in a new tab.
Is it possible ? Is there any workaround ?
Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧梦荧光笔 2025-02-06 04:09:48

瞧,我找到了一个解决方案。

我从卸载Firefox开始,然后安装了开发者版本(optional)。

为了创建图标,我创建了一个文件 .local/share/applications/firefox_dev.desktop ,我添加了:

[Desktop Entry] 
Name=Firefox Developer Edition 
GenericName=Firefox Developer Edition 
Exec=/opt/firefox/firefox %u --class firefox 
terminal=false 
Icon=/opt/firefox/browser/chrome/icons/default/default128.png 
Type=Application 
Categories=Application;Network;X-Developer; 
Comment=Firefox Developer Edition 
StartupWMClass=firefox 

然后我将启动添加到码头中。

然后,我将Firefox设置为默认浏览器。

然后,我启动了VSCODE和LILVE服务器...这添加了一个新的 .local/share/applications/userApp-firefox开发人员版-***。桌面 file。我停止了服务器并关闭VSCODE。

在此文件中,我通过以下方式替换了代码:

[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
NoDisplay=true
Exec=/opt/firefox/firefox-bin %u --class firefox
Name=Firefox Developer Edition
Comment=Firefox Developer Edition

现在:

  • 我在Ubuntu Sidebar中显示了正确的图标,
  • 当我启动Firefox时,它不会在码头中打开/创建新图标,
  • 当我在VSCODE中启动Live Server时,它将在浏览器...
  • ...并且,如果浏览器打开,则会创建一个新的选项卡,而不是新窗口。

++

Voila, I found a solution.

I started by uninstalling Firefox, and I installed the Developer Edition (optional).

To create the icon, I created a file .local/share/applications/firefox_dev.desktop, in which I added:

[Desktop Entry] 
Name=Firefox Developer Edition 
GenericName=Firefox Developer Edition 
Exec=/opt/firefox/firefox %u --class firefox 
terminal=false 
Icon=/opt/firefox/browser/chrome/icons/default/default128.png 
Type=Application 
Categories=Application;Network;X-Developer; 
Comment=Firefox Developer Edition 
StartupWMClass=firefox 

Then I added the launch to the dock.

Then I set Firefox as my default browser.

Then I launched VSCode and Liver Server... This added a new .local/share/applications/userapp-Firefox Developer Edition-***.desktop file. I stopped the server and closed VSCode.

In this file I replaced the code by:

[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
NoDisplay=true
Exec=/opt/firefox/firefox-bin %u --class firefox
Name=Firefox Developer Edition
Comment=Firefox Developer Edition

Now :

  • I have the correct icon showing in the Ubuntu sidebar,
  • when I launch Firefox it doesn't open/create a new icon in the dock,
  • when I launch Live Server in VSCode it launches in the browser...
  • ...and, if the browser is open, it creates a new tab, not a new window.

++

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文