From e6a6172f6ce2d1ffae0502901abde9f13e58f3ad Mon Sep 17 00:00:00 2001 From: infeeeee Date: Tue, 9 Jul 2019 19:27:33 +0200 Subject: [PATCH] fixed bitbar, cleaned up building docs --- README.md | 6 ++++-- kimai2-cmd.js | 35 ++++++++++++++++++++++++++++++----- package.json | 7 +++---- settings.ini.example | 3 +++ 4 files changed, 40 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index d498a92..a4e74df 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,8 @@ You can create your settings.ini file manually, by downloading, renaming and edi On the windows installer version settings.ini location: `C:\Users\Username\AppData\Roaming\kimai2-cmd\settings.ini` +Integration settings are not asked during first run, you have to change them manually in settings.ini. If you don't use an integration, you can safely ignore its settings. + ## Developement version ### Installation @@ -144,10 +146,10 @@ npm run build-current ``` -Build x64 executables to linux, mac, win (not really working for unknown reason) +Build x64 executables for linux, mac on linux or on mac ``` -npm run build +npm run build-nix ``` About building for other platforms see pkg's documentation, or open an issue and I can build it for you. diff --git a/kimai2-cmd.js b/kimai2-cmd.js index 93acea1..8e0518d 100644 --- a/kimai2-cmd.js +++ b/kimai2-cmd.js @@ -351,7 +351,7 @@ function kimaiList(settings, endpoint, print = false, options = false) { callKimaiApi('GET', endpoint, settings.serversettings, { qs: filter }) .then(jsonList => { if (print) { - printList(jsonList, endpoint, { verbose: verbose, printId: printId }) + printList(jsonList, endpoint, { verbose: verbose, printId: printId, kimaipath: settings.bitbar.kimaipath }) } resolve([settings, jsonList]) }) @@ -361,6 +361,21 @@ function kimaiList(settings, endpoint, print = false, options = false) { }) } +/** + * Check if it's a mac. On mac bitbar requires the full path. + * + * @param {path} exepath Path to executable + */ +function argosCheckDarwin(exepath) { + if (platform == "darwin") { + return exepath + } else { + return 'kimai' + } +} + + + /** * Prints list to terminal * @@ -368,11 +383,15 @@ function kimaiList(settings, endpoint, print = false, options = false) { * @param {string} endpoint for selecting display layout * @param {object} options * options.printId: print ids with list + * options.kimaipath: path to kimai on mac for bitbar * options.verbose */ function printList(arr, endpoint, options = false) { const verbose = options.verbose || false const printId = options.printId || false + const kimaiExe = argosCheckDarwin(options.kimaipath) + + if (verbose) { console.log() if (arr.length > 1) { @@ -427,19 +446,22 @@ function printList(arr, endpoint, options = false) { } else if (printId) { console.log(element.id + ':', element.project.name, '|', element.activity.name) - } else if (program.argos || program.argosbutton) { + } else if (program.argos) { if (endpoint == 'timesheets/recent') { - console.log('--' + element.project.name + ',', element.activity.name, '|', 'bash="kimai restart', element.id, '" terminal=false refresh=true') + console.log('--' + element.project.name + ',', element.activity.name, '|', 'bash=' + kimaiExe + ' param1=restart param2=' + element.id + ' terminal=false refresh=true') } else if (endpoint == 'timesheets/active') { let dur = moment.duration(moment().diff(moment(element.begin))) - console.log(dur.hours() + ':' + dur.minutes(), element.project.name + ',', element.activity.name, '|', 'bash="kimai stop', element.id, '" terminal=false refresh=true') + console.log(dur.hours() + ':' + dur.minutes(), element.project.name + ',', element.activity.name, '|', 'bash=' + kimaiExe + ' param1=stop param2=' + element.id + ' terminal=false refresh=true') } + } else if (program.argosbutton) { + let dur = moment.duration(moment().diff(moment(element.begin))) + console.log(dur.hours() + ':' + dur.minutes(), element.project.name + ',', element.activity.name, '| length=10') } else { console.log(element.project.name, '|', element.activity.name) + console.log() } } } - console.log() } @@ -604,6 +626,9 @@ function uiAskForSettings(verbose = false) { .then(answers => { let settings = {} settings.serversettings = answers + settings.bitbar = { + kimaipath: process.execPath + } const thePath = iniFullPath() if (verbose) { console.log('Trying to save settings to: '.thePath) } diff --git a/package.json b/package.json index 8fbaf28..0b7ef9a 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,12 @@ { "name": "kimai2-cmd", - "version": "0.2.0", + "version": "0.2.1", "description": "Command line client for Kimai2", "main": "kimai2-cmd.js", "bin": "kimai2-cmd.js", "scripts": { "start": "node kimai2-cmd.js", - "build": "pkg --out-path builds package.json", + "build-nix": "pkg --out-path builds package.json", "build-current": "pkg --targets node10 --out-path builds kimai2-cmd.js" }, "keywords": [ @@ -38,8 +38,7 @@ "pkg": { "targets": [ "node10-linux", - "node10-macos", - "node10-win" + "node10-macos" ] } } diff --git a/settings.ini.example b/settings.ini.example index 2d8b5fb..7a3226e 100644 --- a/settings.ini.example +++ b/settings.ini.example @@ -2,3 +2,6 @@ kimaiurl=https://demo.kimai.org username=anna_admin password=apipassword + +[bitbar] +kimaipath=/path/to/kimai2-cmd-macos \ No newline at end of file