fix Vesktop being registered as html mime handler
This is actually a bug in xdg-settings that was already fixed years ago, but Ubuntu still ships 7 (!!!!!) years out of date xdg-utils. Please just switch to Fedora what are we doing man
This commit is contained in:
@@ -15,6 +15,7 @@ import { createWindows, mainWin } from "./mainWindow";
|
|||||||
import { registerMediaPermissionsHandler } from "./mediaPermissions";
|
import { registerMediaPermissionsHandler } from "./mediaPermissions";
|
||||||
import { registerScreenShareHandler } from "./screenShare";
|
import { registerScreenShareHandler } from "./screenShare";
|
||||||
import { Settings, State } from "./settings";
|
import { Settings, State } from "./settings";
|
||||||
|
import { setAsDefaultProtocolClient } from "./utils/setAsDefaultProtocolClient";
|
||||||
import { isDeckGameMode } from "./utils/steamOS";
|
import { isDeckGameMode } from "./utils/steamOS";
|
||||||
|
|
||||||
if (!IS_DEV) {
|
if (!IS_DEV) {
|
||||||
@@ -31,7 +32,7 @@ const isLinux = process.platform === "linux";
|
|||||||
export let enableHardwareAcceleration = true;
|
export let enableHardwareAcceleration = true;
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
app.setAsDefaultProtocolClient("discord");
|
setAsDefaultProtocolClient("discord");
|
||||||
|
|
||||||
const { disableSmoothScroll, hardwareAcceleration, hardwareVideoAcceleration } = Settings.store;
|
const { disableSmoothScroll, hardwareAcceleration, hardwareVideoAcceleration } = Settings.store;
|
||||||
|
|
||||||
|
|||||||
29
src/main/utils/setAsDefaultProtocolClient.ts
Normal file
29
src/main/utils/setAsDefaultProtocolClient.ts
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Vesktop, a desktop app aiming to give you a snappier Discord Experience
|
||||||
|
* Copyright (c) 2025 Vendicated and Vesktop contributors
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { execFile } from "child_process";
|
||||||
|
import { app } from "electron";
|
||||||
|
|
||||||
|
export async function setAsDefaultProtocolClient(protocol: string) {
|
||||||
|
if (process.platform !== "linux") {
|
||||||
|
return app.setAsDefaultProtocolClient(protocol);
|
||||||
|
}
|
||||||
|
|
||||||
|
// electron setAsDefaultProtocolClient uses xdg-settings instead of xdg-mime.
|
||||||
|
// xdg-settings had a bug where it would also register the app as a handler for text/html,
|
||||||
|
// aka become your browser. This bug was fixed years ago (xdg-utils 1.2.0) but Ubuntu ships
|
||||||
|
// 7 (YES, SEVEN) years out of date xdg-utils which STILL has the bug.
|
||||||
|
// FIXME: remove this workaround when Ubuntu updates their xdg-utils or electron switches to xdg-mime.
|
||||||
|
|
||||||
|
const { CHROME_DESKTOP } = process.env;
|
||||||
|
if (!CHROME_DESKTOP) return false;
|
||||||
|
|
||||||
|
return new Promise<boolean>(resolve => {
|
||||||
|
execFile("xdg-mime", ["default", CHROME_DESKTOP, `x-scheme-handler/${protocol}`], err => {
|
||||||
|
resolve(err == null);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user