From 8f838900682d8825f21ab3eff34117a66c026660 Mon Sep 17 00:00:00 2001 From: Segev Finer Date: Sat, 18 Aug 2018 04:47:54 +0300 Subject: [PATCH] Add URL handler support for Linux desktops Fixes #48528 --- build/gulpfile.vscode.linux.js | 18 ++++++++++++++++-- resources/linux/code-url-handler.desktop | 13 +++++++++++++ resources/linux/debian/postinst.template | 1 + resources/linux/rpm/code.spec.template | 2 ++ 4 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 resources/linux/code-url-handler.desktop diff --git a/build/gulpfile.vscode.linux.js b/build/gulpfile.vscode.linux.js index 49f2cad8ad735..c96ed40bf0910 100644 --- a/build/gulpfile.vscode.linux.js +++ b/build/gulpfile.vscode.linux.js @@ -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)) @@ -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)); }; @@ -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)) @@ -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))); }; diff --git a/resources/linux/code-url-handler.desktop b/resources/linux/code-url-handler.desktop new file mode 100644 index 0000000000000..773807a7e4607 --- /dev/null +++ b/resources/linux/code-url-handler.desktop @@ -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@@ +Categories=Utility;TextEditor;Development;IDE; +MimeType=x-scheme-handler/vscode +Keywords=vscode; diff --git a/resources/linux/debian/postinst.template b/resources/linux/debian/postinst.template index c4fbfcac16ee8..2c4a1fdd1d6fa 100755 --- a/resources/linux/debian/postinst.template +++ b/resources/linux/debian/postinst.template @@ -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 diff --git a/resources/linux/rpm/code.spec.template b/resources/linux/rpm/code.spec.template index cf594670da755..71e016614e200 100644 --- a/resources/linux/rpm/code.spec.template +++ b/resources/linux/rpm/code.spec.template @@ -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 @@ -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