Skip to content

Commit

Permalink
Merge pull request #333735 from eclairevoyant/vscode-desktop
Browse files Browse the repository at this point in the history
vscode: improve desktop file handling
  • Loading branch information
JohnRTitor committed Aug 11, 2024
2 parents 78d1fae + dead77e commit 04f4be3
Showing 1 changed file with 33 additions and 35 deletions.
68 changes: 33 additions & 35 deletions pkgs/applications/editors/vscode/generic.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{ stdenv
, lib
, copyDesktopItems
, makeDesktopItem
, unzip
, libsecret
Expand Down Expand Up @@ -122,38 +123,38 @@ in
inherit rev vscodeServer;
};

desktopItem = makeDesktopItem {
name = executableName;
desktopName = longName;
comment = "Code Editing. Redefined.";
genericName = "Text Editor";
exec = "${executableName} %F";
icon = "vs${executableName}";
startupNotify = true;
startupWMClass = shortName;
categories = [ "Utility" "TextEditor" "Development" "IDE" ];
mimeTypes = [ "text/plain" "inode/directory" ];
keywords = [ "vscode" ];
actions.new-empty-window = {
name = "New Empty Window";
exec = "${executableName} --new-window %F";
desktopItems = [
(makeDesktopItem {
name = executableName;
desktopName = longName;
comment = "Code Editing. Redefined.";
genericName = "Text Editor";
exec = "${executableName} %F";
icon = "vs${executableName}";
};
};

urlHandlerDesktopItem = makeDesktopItem {
name = executableName + "-url-handler";
desktopName = longName + " - URL Handler";
comment = "Code Editing. Redefined.";
genericName = "Text Editor";
exec = executableName + " --open-url %U";
icon = "vs${executableName}";
startupNotify = true;
categories = [ "Utility" "TextEditor" "Development" "IDE" ];
mimeTypes = [ "x-scheme-handler/vs${executableName}" ];
keywords = [ "vscode" ];
noDisplay = true;
};
startupNotify = true;
startupWMClass = shortName;
categories = [ "Utility" "TextEditor" "Development" "IDE" ];
keywords = [ "vscode" ];
actions.new-empty-window = {
name = "New Empty Window";
exec = "${executableName} --new-window %F";
icon = "vs${executableName}";
};
})
(makeDesktopItem {
name = executableName + "-url-handler";
desktopName = longName + " - URL Handler";
comment = "Code Editing. Redefined.";
genericName = "Text Editor";
exec = executableName + " --open-url %U";
icon = "vs${executableName}";
startupNotify = true;
categories = [ "Utility" "TextEditor" "Development" "IDE" ];
mimeTypes = [ "x-scheme-handler/vs${executableName}" ];
keywords = [ "vscode" ];
noDisplay = true;
})
];

buildInputs = [ libsecret libXScrnSaver libxshmfence ]
++ lib.optionals (!stdenv.isDarwin) [ alsa-lib at-spi2-atk libkrb5 mesa nss nspr systemd xorg.libxkbfile ];
Expand All @@ -164,6 +165,7 @@ in
++ lib.optionals stdenv.isLinux [
autoPatchelfHook
asar
copyDesktopItems
# override doesn't preserve splicing https://github.com/NixOS/nixpkgs/issues/132651
(buildPackages.wrapGAppsHook3.override { inherit (buildPackages) makeWrapper; })
];
Expand All @@ -184,10 +186,6 @@ in
ln -s "$out/lib/vscode/bin/${sourceExecutableName}" "$out/bin/${executableName}"
mkdir -p "$out/share/applications"
ln -s "$desktopItem/share/applications/${executableName}.desktop" "$out/share/applications/${executableName}.desktop"
ln -s "$urlHandlerDesktopItem/share/applications/${executableName}-url-handler.desktop" "$out/share/applications/${executableName}-url-handler.desktop"
# These are named vscode.png, vscode-insiders.png, etc to match the name in upstream *.deb packages.
mkdir -p "$out/share/pixmaps"
cp "$out/lib/vscode/resources/app/resources/linux/code.png" "$out/share/pixmaps/vs${executableName}.png"
Expand Down

0 comments on commit 04f4be3

Please sign in to comment.