Skip to content

Commit

Permalink
fixed bitbar, cleaned up building docs
Browse files Browse the repository at this point in the history
  • Loading branch information
infeeeee committed Jul 9, 2019
1 parent fa97ace commit e6a6172
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 11 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
35 changes: 30 additions & 5 deletions kimai2-cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -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])
})
Expand All @@ -361,18 +361,37 @@ 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
*
* @param {array} arr Items to list
* @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) {
Expand Down Expand Up @@ -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()
}


Expand Down Expand Up @@ -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) }
Expand Down
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down Expand Up @@ -38,8 +38,7 @@
"pkg": {
"targets": [
"node10-linux",
"node10-macos",
"node10-win"
"node10-macos"
]
}
}
3 changes: 3 additions & 0 deletions settings.ini.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
kimaiurl=https://demo.kimai.org
username=anna_admin
password=apipassword

[bitbar]
kimaipath=/path/to/kimai2-cmd-macos

0 comments on commit e6a6172

Please sign in to comment.