Skip to content

Commit

Permalink
Merge pull request #437 from canonical/fix/quick-sound-workaround
Browse files Browse the repository at this point in the history
fix: Don't crash if `canberra-gtk-play` doesn't exist
  • Loading branch information
spydon authored Feb 16, 2024
2 parents 64bcffa + 8feccc0 commit 4553552
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/ubuntu_provision/lib/src/services/sound_service.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
import 'dart:io';

import 'package:ubuntu_logger/ubuntu_logger.dart';

final _log = Logger('sound_service');

/// A service for playing sounds.
class SoundService {
Future<void> play(String id) async {
await Process.run('canberra-gtk-play', ['--id=$id']);
try {
await Process.run('canberra-gtk-play', ['--id=$id']);
} on ProcessException catch (_) {
_log.error(
'Error playing sound with id: $id (most likely missing canberra-gtk-play)',
);
}
}
}

0 comments on commit 4553552

Please sign in to comment.