From 54c7c1e98d33c6fee2d35ec0ca2c667e3e09075c Mon Sep 17 00:00:00 2001 From: Fabian Stiewitz Date: Tue, 17 Jun 2014 12:40:10 +0200 Subject: [PATCH] :penguin: Install Atom.desktop when installing to /usr/local --- build/tasks/install-task.coffee | 16 ++++++++++++++++ build/tasks/mkdeb-task.coffee | 4 +++- resources/linux/Atom.desktop.in | 4 ++-- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/build/tasks/install-task.coffee b/build/tasks/install-task.coffee index 9c7617684..54fecd8fc 100644 --- a/build/tasks/install-task.coffee +++ b/build/tasks/install-task.coffee @@ -1,8 +1,14 @@ fs = require 'fs' path = require 'path' +_ = require 'underscore-plus' fs = require 'fs-plus' runas = null +fillTemplate = (filePath, data) -> + template = _.template(String(fs.readFileSync(filePath + '.in'))) + filled = template(data) + fs.writeFileSync(filePath, filled) + module.exports = (grunt) -> {cp, mkdir, rm} = require('./task-helpers')(grunt) @@ -25,12 +31,22 @@ module.exports = (grunt) -> binDir = path.join(installDir, 'bin') shareDir = path.join(installDir, 'share', 'atom') + iconName = path.join(shareDir,'resources','app','resources','atom.png') + desktopFile = path.join('resources', 'linux', 'Atom.desktop') + mkdir binDir cp 'atom.sh', path.join(binDir, 'atom') rm shareDir mkdir path.dirname(shareDir) cp shellAppDir, shareDir + # Create Atom.desktop if installation in '/usr/local' + applicationsDir = path.join('/usr','share','applications') + if installDir is '/usr/local' and fs.isDirectorySync(applicationsDir) + {description} = grunt.file.readJSON('package.json') + fillTemplate(desktopFile, {description, installDir, iconName}) + cp desktopFile, path.join(applicationsDir,'Atom.desktop') + # Create relative symbol link for apm. process.chdir(binDir) rm('apm') diff --git a/build/tasks/mkdeb-task.coffee b/build/tasks/mkdeb-task.coffee index 72c41252c..090168446 100644 --- a/build/tasks/mkdeb-task.coffee +++ b/build/tasks/mkdeb-task.coffee @@ -23,7 +23,9 @@ module.exports = (grunt) -> {name, version, description} = grunt.file.readJSON('package.json') section = 'devel' maintainer = 'GitHub ' - data = {name, version, description, section, arch, maintainer} + installDir = '/usr' + iconName = 'atom' + data = {name, version, description, section, arch, maintainer, installDir, iconName} control = path.join('resources', 'linux', 'debian', 'control') fillTemplate(control, data) diff --git a/resources/linux/Atom.desktop.in b/resources/linux/Atom.desktop.in index e88ed122f..0694c0cfb 100644 --- a/resources/linux/Atom.desktop.in +++ b/resources/linux/Atom.desktop.in @@ -1,8 +1,8 @@ [Desktop Entry] Name=Atom Comment=<%= description %> -Exec=/usr/share/atom/atom %U -Icon=atom +Exec=<%= installDir %>/share/atom/atom %U +Icon=<%= iconName %> Type=Application StartupNotify=true Categories=GNOME;GTK;Utility;TextEditor;