Skip to content

Commit 56ba527

Browse files
authored
add audio cue for when a terminal command fails (#174621)
1 parent c7a040a commit 56ba527

3 files changed

Lines changed: 19 additions & 2 deletions

File tree

src/vs/platform/audioCues/browser/audioCueService.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,12 @@ export class AudioCue {
294294
settingsKey: 'audioCues.taskFailed'
295295
});
296296

297+
public static readonly terminalCommandFailed = AudioCue.register({
298+
name: localize('audioCues.terminalCommandFailed', 'Terminal Command Failed'),
299+
sound: Sound.taskFailed,
300+
settingsKey: 'audioCues.terminalCommandFailed'
301+
});
302+
297303
public static readonly terminalBell = AudioCue.register({
298304
name: localize('audioCues.terminalBell', 'Terminal Bell'),
299305
sound: Sound.terminalBell,

src/vs/workbench/contrib/audioCues/browser/audioCues.contribution.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration).regis
8989
'description': localize('audioCues.taskFailed', "Plays a sound when a task fails (non-zero exit code)."),
9090
...audioCueFeatureBase,
9191
},
92+
'audioCues.terminalCommandFailed': {
93+
'description': localize('audioCues.terminalCommandFailed', "Plays a sound when a terminal command fails (non-zero exit code)."),
94+
...audioCueFeatureBase,
95+
},
9296
'audioCues.terminalQuickFix': {
9397
'description': localize('audioCues.terminalQuickFix', "Plays a sound when terminal Quick Fixes are available."),
9498
...audioCueFeatureBase,

src/vs/workbench/contrib/terminal/browser/xterm/decorationAddon.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { ITerminalCommand } from 'vs/workbench/contrib/terminal/common/terminal'
2626
import { TERMINAL_COMMAND_DECORATION_DEFAULT_BACKGROUND_COLOR, TERMINAL_COMMAND_DECORATION_ERROR_BACKGROUND_COLOR, TERMINAL_COMMAND_DECORATION_SUCCESS_BACKGROUND_COLOR } from 'vs/workbench/contrib/terminal/common/terminalColorRegistry';
2727
import { ILifecycleService } from 'vs/workbench/services/lifecycle/common/lifecycle';
2828
import { IDecoration, ITerminalAddon, Terminal } from 'xterm';
29+
import { AudioCue, IAudioCueService } from 'vs/platform/audioCues/browser/audioCueService';
2930

3031
interface IDisposableDecoration { decoration: IDecoration; disposables: IDisposable[]; exitCode?: number; markProperties?: IMarkProperties }
3132

@@ -51,7 +52,8 @@ export class DecorationAddon extends Disposable implements ITerminalAddon {
5152
@IQuickInputService private readonly _quickInputService: IQuickInputService,
5253
@ILifecycleService lifecycleService: ILifecycleService,
5354
@ICommandService private readonly _commandService: ICommandService,
54-
@IInstantiationService instantiationService: IInstantiationService
55+
@IInstantiationService instantiationService: IInstantiationService,
56+
@IAudioCueService private readonly _audioCueService: IAudioCueService
5557
) {
5658
super();
5759
this._register(toDisposable(() => this._dispose()));
@@ -217,7 +219,12 @@ export class DecorationAddon extends Disposable implements ITerminalAddon {
217219
for (const command of capability.commands) {
218220
this.registerCommandDecoration(command);
219221
}
220-
commandDetectionListeners.push(capability.onCommandFinished(command => this.registerCommandDecoration(command)));
222+
commandDetectionListeners.push(capability.onCommandFinished(command => {
223+
this.registerCommandDecoration(command);
224+
if (command.exitCode) {
225+
this._audioCueService.playAudioCue(AudioCue.terminalCommandFailed);
226+
}
227+
}));
221228
// Command invalidated
222229
commandDetectionListeners.push(capability.onCommandInvalidated(commands => {
223230
for (const command of commands) {

0 commit comments

Comments
 (0)