fix: screen sharing for slack, element-desktop

This commit is contained in:
teutat3s 2024-04-13 02:17:58 +02:00
parent f8c6042819
commit 4956dafd72
Signed by: teutat3s
GPG key ID: 4FA1D3FA524F22C1
5 changed files with 88 additions and 1 deletions

View file

@ -143,6 +143,22 @@
"type": "github"
}
},
"fork": {
"locked": {
"lastModified": 1712959986,
"narHash": "sha256-/4PhrnC+W5gWJAiRDf3tfLouxJc1UhSAnCpwKf1q1K4=",
"owner": "teutat3s",
"repo": "nixpkgs",
"rev": "2186dafc19798a5314d42c126b7520957e019cef",
"type": "github"
},
"original": {
"owner": "teutat3s",
"ref": "fix-element-desktop-screen-sharing-23.11",
"repo": "nixpkgs",
"type": "github"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
@ -303,6 +319,7 @@
"deploy-rs": "deploy-rs",
"flake-compat": "flake-compat",
"flake-parts": "flake-parts",
"fork": "fork",
"home-manager": "home-manager",
"master": "master",
"nix-darwin": "nix-darwin",

View file

@ -10,7 +10,7 @@
unstable.url = "github:nixos/nixpkgs/nixos-unstable";
master.url = "github:nixos/nixpkgs/master";
#fork.url = "github:teutat3s/nixpkgs/backport-droidcam";
fork.url = "github:teutat3s/nixpkgs/fix-element-desktop-screen-sharing-23.11";
flake-compat.url = "github:edolstra/flake-compat";
flake-compat.flake = false;

View file

@ -18,12 +18,16 @@
"slack"
];
};
fork = import inputs.fork {
system = prev.system;
};
master = import inputs.master {
system = prev.system;
};
in
{
direnv = unstable.direnv;
element-desktop = fork.element-desktop;
nixVersions = prev.nixVersions // {inherit (unstable.nixVersions) nix_2_20;};
nix-direnv = unstable.nix-direnv;
_1password = unstable._1password;
@ -37,6 +41,7 @@
(import ./mdbook-multilang.nix inputs)
(import ./nix-index.nix)
(import ./prr.nix)
(import ./slack.nix)
(import ./neovim-plugins.nix)
];
});

View file

@ -0,0 +1,56 @@
final: prev: {
element-desktop = prev.element-desktop.overrideAttrs (oldAttrs: rec {
installPhase =
let
libPath = prev.lib.makeLibraryPath [
prev.libnotify
];
executableName = "element-desktop";
desktopItem = prev.makeDesktopItem {
name = "element-desktop";
exec = "${executableName} %u";
icon = "element";
desktopName = "Element";
genericName = "Matrix Client";
comment = oldAttrs.meta.description;
categories = [ "Network" "InstantMessaging" "Chat" ];
startupWMClass = "element";
mimeTypes = [ "x-scheme-handler/element" ];
};
in
''
runHook preInstall
# resources
mkdir -p "$out/share/element"
ln -s '${prev.element-web}' "$out/share/element/webapp"
cp -r '.' "$out/share/element/electron"
cp -r './res/img' "$out/share/element"
rm -rf "$out/share/element/electron/node_modules"
cp -r './node_modules' "$out/share/element/electron"
cp $out/share/element/electron/lib/i18n/strings/en_EN.json $out/share/element/electron/lib/i18n/strings/en-us.json
ln -s $out/share/element/electron/lib/i18n/strings/en{-us,}.json
# icons
for icon in $out/share/element/electron/build/icons/*.png; do
mkdir -p "$out/share/icons/hicolor/$(basename $icon .png)/apps"
ln -s "$icon" "$out/share/icons/hicolor/$(basename $icon .png)/apps/element.png"
done
# desktop item
mkdir -p "$out/share"
ln -s "${desktopItem}/share/applications" "$out/share/applications"
# executable wrapper
# LD_PRELOAD workaround for sqlcipher not found: https://github.com/matrix-org/seshat/issues/102
makeWrapper '${prev.electron}/bin/electron' "$out/bin/element-desktop" \
--set LD_PRELOAD ${prev.sqlcipher}/lib/libsqlcipher.so \
--set LD_LIBRARY_PATH "${libPath}" \
--add-flags "$out/share/element/electron" \
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WebRTCPipeWireCapturer,WaylandWindowDecorations}}"
runHook postInstall
'';
});
}

9
overlays/slack.nix Normal file
View file

@ -0,0 +1,9 @@
final: prev: {
# https://askubuntu.com/questions/1490447/slack-with-webrtcpipewirecapture-wyaland-black-screen-sharing-but-works-on-chrom
slack = prev.slack.overrideAttrs (oldAttrs: rec {
postInstall = ''
sed -i -e 's/,"WebRTCPipeWireCapturer"/,"LebRTCPipeWireCapturer"/' $out/lib/slack/resources/app.asar
'';
});
}