diff --git a/extension.ts b/extension.ts index 6d2703b..b678f2c 100644 --- a/extension.ts +++ b/extension.ts @@ -41,6 +41,10 @@ export function activate(ctx: vscode.ExtensionContext) { wakatime.promptForDebug(); })); + ctx.subscriptions.push(vscode.commands.registerCommand('wakatime.status_bar_icon', function (args) { + wakatime.promptStatusBarIcon(); + })); + // add to a list of disposables which are disposed when this extension // is deactivated again. ctx.subscriptions.push(wakatime); @@ -69,7 +73,12 @@ export class WakaTime { this.dependencies = new Dependencies(this.options); this.dependencies.checkAndInstall(function() { this.statusBar.text = '$(clock) WakaTime Initialized'; - this.statusBar.show(); + this.options.getSetting('settings', 'status_bar_icon', function(err, val) { + if (val && val.trim() !== 'false') + this.statusBar.hide(); + else + this.statusBar.show(); + }.bind(this)); }.bind(this)); this._setupEventListeners(); @@ -155,6 +164,31 @@ export class WakaTime { }.bind(this)); } + public promptStatusBarIcon(): void { + this.options.getSetting('settings', 'status_bar_icon', function(err, defaultVal) { + if (!defaultVal || defaultVal.trim() !== 'false') + defaultVal = 'true'; + let items:string[] = ['true', 'false']; + let promptOptions = { + placeHolder: 'true or false (Currently ' + defaultVal + ')', + value: defaultVal, + ignoreFocusOut: true, + }; + vscode.window.showQuickPick(items, promptOptions).then(function(newVal) { + if (newVal == null) + return; + this.options.setSetting('settings', 'status_bar_icon', newVal); + if (newVal === 'true') { + this.statusBar.show(); + logger.debug('Status bar icon enabled'); + } else { + this.statusBar.hide(); + logger.debug('Status bar icon disabled'); + } + }.bind(this)); + }.bind(this)); + } + private _checkApiKey() { this.hasApiKey(function(hasApiKey) { if (!hasApiKey) this.promptForApiKey(); diff --git a/package.json b/package.json index 477dece..b159dfc 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,10 @@ { "command": "wakatime.debug", "title": "WakaTime Debug" + }, + { + "command": "wakatime.status_bar_icon", + "title": "WakaTime Status Bar Icon" } ] },