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

Add URL handler support for Linux desktops #56727

Merged
merged 1 commit into from
Sep 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions build/gulpfile.vscode.linux.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ function prepareDebPackage(arch) {
.pipe(replace('@@ICON@@', product.applicationName))
.pipe(rename('usr/share/applications/' + product.applicationName + '.desktop'));

const desktopUrlHandler = gulp.src('resources/linux/code-url-handler.desktop', { base: '.' })
.pipe(replace('@@NAME_LONG@@', product.nameLong))
.pipe(replace('@@NAME_SHORT@@', product.nameShort))
.pipe(replace('@@NAME@@', product.applicationName))
.pipe(replace('@@ICON@@', product.applicationName))
.pipe(rename('usr/share/applications/' + product.applicationName + '-url-handler.desktop'));

const appdata = gulp.src('resources/linux/code.appdata.xml', { base: '.' })
.pipe(replace('@@NAME_LONG@@', product.nameLong))
.pipe(replace('@@NAME@@', product.applicationName))
Expand Down Expand Up @@ -78,7 +85,7 @@ function prepareDebPackage(arch) {
.pipe(replace('@@UPDATEURL@@', product.updateUrl || '@@UPDATEURL@@'))
.pipe(rename('DEBIAN/postinst'));

const all = es.merge(control, postinst, postrm, prerm, desktop, appdata, icon, code);
const all = es.merge(control, postinst, postrm, prerm, desktop, desktopUrlHandler, appdata, icon, code);

return all.pipe(vfs.dest(destination));
};
Expand Down Expand Up @@ -113,6 +120,13 @@ function prepareRpmPackage(arch) {
.pipe(replace('@@ICON@@', product.applicationName))
.pipe(rename('BUILD/usr/share/applications/' + product.applicationName + '.desktop'));

const desktopUrlHandler = gulp.src('resources/linux/code-url-handler.desktop', { base: '.' })
.pipe(replace('@@NAME_LONG@@', product.nameLong))
.pipe(replace('@@NAME_SHORT@@', product.nameShort))
.pipe(replace('@@NAME@@', product.applicationName))
.pipe(replace('@@ICON@@', product.applicationName))
.pipe(rename('BUILD/usr/share/applications/' + product.applicationName + '-url-handler.desktop'));

const appdata = gulp.src('resources/linux/code.appdata.xml', { base: '.' })
.pipe(replace('@@NAME_LONG@@', product.nameLong))
.pipe(replace('@@NAME@@', product.applicationName))
Expand Down Expand Up @@ -142,7 +156,7 @@ function prepareRpmPackage(arch) {
const specIcon = gulp.src('resources/linux/rpm/code.xpm', { base: '.' })
.pipe(rename('SOURCES/' + product.applicationName + '.xpm'));

const all = es.merge(code, desktop, appdata, icon, spec, specIcon);
const all = es.merge(code, desktop, desktopUrlHandler, appdata, icon, spec, specIcon);

return all.pipe(vfs.dest(getRpmBuildPath(rpmArch)));
};
Expand Down
13 changes: 13 additions & 0 deletions resources/linux/code-url-handler.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Desktop Entry]
Name=@@NAME_LONG@@ - URL Handler
Comment=Code Editing. Redefined.
GenericName=Text Editor
Exec=/usr/share/@@NAME@@/@@NAME@@ --open-url %U
Icon=@@ICON@@
Type=Application
NoDisplay=true
StartupNotify=true
StartupWMClass=@@NAME_SHORT@@
Copy link

@eclemens eclemens Oct 30, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes the icon to appear twice on Gnome Shell side panel. If I have it as pinned as favorite and click on it, it appears as if it was another application. If this line is commented off the error disappears.

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm for some reason unable to find documentation on the logic Gnome and other desktop environments use to group windows. I guess it uses the WM_CLASS, and it groups it to the URL handler desktop despite it being NoDisplay... Guess removing StartupWMClass makes sense? Why not go ahead and make a PR?

Categories=Utility;TextEditor;Development;IDE;
MimeType=x-scheme-handler/vscode
Keywords=vscode;
1 change: 1 addition & 0 deletions resources/linux/debian/postinst.template
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ update-alternatives --install /usr/bin/editor editor /usr/bin/@@NAME@@ 0
# Install the desktop entry
if hash desktop-file-install 2>/dev/null; then
desktop-file-install /usr/share/applications/@@NAME@@.desktop
desktop-file-install /usr/share/applications/@@NAME@@-url-handler.desktop
fi

if [ "@@NAME@@" != "code-oss" ]; then
Expand Down
2 changes: 2 additions & 0 deletions resources/linux/rpm/code.spec.template
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ mkdir -p %{buildroot}/usr/share/applications
mkdir -p %{buildroot}/usr/share/pixmaps
cp -r usr/share/@@NAME@@/* %{buildroot}/usr/share/@@NAME@@
cp -r usr/share/applications/@@NAME@@.desktop %{buildroot}/usr/share/applications
cp -r usr/share/applications/@@NAME@@-url-handler.desktop %{buildroot}/usr/share/applications
cp -r usr/share/pixmaps/@@NAME@@.png %{buildroot}/usr/share/pixmaps

%post
Expand Down Expand Up @@ -51,4 +52,5 @@ fi

/usr/share/@@NAME@@/
/usr/share/applications/@@NAME@@.desktop
/usr/share/applications/@@NAME@@-url-handler.desktop
/usr/share/pixmaps/@@NAME@@.png