diff --git a/index.coffee b/index.coffee index 12cfb181a41e5b04fc1302bcbc803b0e0f291d5f..f7e9f02e88222488da315eeebfe08fb7639f575b 100644 --- a/index.coffee +++ b/index.coffee @@ -55,18 +55,10 @@ module.exports = #------------------------------------------------------------------------------- open: ({path}) -> - if @config.get 'singleInstance' - exec "pkill GitKraken; sleep .1 && open -Fb #{@id} --args -p '#{path}'" #, @timeout + if atom.config.get 'gitkraken.singleInstance' + @execGitKrakenSingle path else - projects = {} - try - projects = require @tmp - execSync "ps #{projects[path]} | grep -q GitKraken && - open -b #{@id} --args -p '#{path}'" - catch - pid = execSync "open -nb #{@id} --args -p '#{path}' & echo $!" - projects[path] = (parseInt pid) + 1 - writeFile @tmp, JSON.stringify projects + projects = @execGitKrakenMulti path window.addEventListener 'beforeunload', -> exec "kill #{projects[path]}" @@ -76,3 +68,31 @@ module.exports = @subs.dispose() window.removeEventListener 'beforeunload' unlink @tmp + +#------------------------------------------------------------------------------- + execGitKrakenSingle: (path) -> + if process.platform == 'darwin' + exec "pkill GitKraken; sleep .1 && open -Fb #{@id} --args -p '#{path}'" #, @timeout + else if process.platform == 'linux' + exec "killall gitkraken; sleep .1 && gitkraken --args -p '#{path}' &> /dev/null &" + +#------------------------------------------------------------------------------- + execGitKrakenMulti: (path) -> + projects = {} + try + projects = require @tmp + if process.platform == 'darwin' + execSync "ps #{projects[path]} | grep -q GitKraken && open -b #{@id} --args -p '#{path}'" + else if process.platform == 'linux' + execSync "ps #{projects[path]} | grep -q gitkraken" + catch + if process.platform == 'darwin' + pid = execSync "open -nb #{@id} --args -p '#{path}' & echo $!" + else if process.platform == 'linux' + proc = exec "nohup gitkraken --args -p '#{path}' &>/dev/null &" + pid = proc.pid + + projects[path] = (parseInt pid) + 1 + writeFile @tmp, JSON.stringify projects + + projects diff --git a/package.json b/package.json index 6e8f9c1c2e416777f91cafb02e87cd202a80c238..0d12aab22da0f6bdb62a83f84efb97a7e6abe717 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,8 @@ "private": true, "license": "MIT", "os": [ - "darwin" + "darwin", + "linux" ], "dependencies": { "sub-atom": "^1.1.0"