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 option to pass additional arguments #47

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
10 changes: 6 additions & 4 deletions src/AutoLaunchLinux.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@ module.exports =
# :appName - {String}
# :appPath - {String}
# :isHiddenOnLaunch - {Boolean}
# :extraArgs - {Sting}
# Returns a Promise
enable: ({appName, appPath, isHiddenOnLaunch}) ->
enable: ({appName, appPath, isHiddenOnLaunch, extraArgs}) ->
hiddenArg = if isHiddenOnLaunch then ' --hidden' else ''
args = if extraArgs? then (hiddenArg + ' ' + extraArgs) else hiddenArg

data = """[Desktop Entry]
Type=Application
Version=1.0
Name=#{appName}
Comment=#{appName}startup script
Exec=#{appPath}#{hiddenArg}
Comment=#{appName} startup script
Exec=#{appPath}#{args}
StartupNotify=false
Terminal=false"""

Expand Down Expand Up @@ -48,4 +50,4 @@ module.exports =

# appName - {String}
# Returns a {String}
getFilePath: (appName) -> "#{@getDirectory()}#{appName}.desktop"
getFilePath: (appName) -> "#{@getDirectory()}#{appName}.desktop"
6 changes: 4 additions & 2 deletions src/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ module.exports = class AutoLaunch
# to add Login Item
# :name - {String}
# :path - (Optional) {String}
constructor: ({name, isHidden, mac, path}) ->
# :extraArgs - (Optional) {String}
constructor: ({name, isHidden, mac, extraArgs, path}) ->
throw new Error 'You must specify a name' unless name?

@opts =
appName: name
isHiddenOnLaunch: if isHidden? then isHidden else false
extraArgs: if extraArgs? then extraArgs else ''
mac: mac ? {}

versions = process?.versions
Expand Down Expand Up @@ -89,4 +91,4 @@ module.exports = class AutoLaunch
if /darwin/.test process.platform
# Remove ".app" from the appName if it exists
if @opts.appName.indexOf('.app', @opts.appName.length - '.app'.length) isnt -1
@opts.appName = @opts.appName.substr(0, @opts.appName.length - '.app'.length)
@opts.appName = @opts.appName.substr(0, @opts.appName.length - '.app'.length)