Skip to content

Commit

Permalink
Refactor speech-dispatcher restart, fix restarting in flatpak
Browse files Browse the repository at this point in the history
  • Loading branch information
Elleo committed Nov 26, 2023
1 parent 03205de commit bc3439f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion appimage/AppImageBuilder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ AppDir:
id: com.mikeasoft.pied
name: Pied
icon: pied
version: 0.1.2
version: 0.1.11
exec: pied
exec_args: $@
apt:
Expand Down
27 changes: 15 additions & 12 deletions lib/voice_selector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,18 @@ class _VoiceSelectorState extends State<VoiceSelector> {
});
}

void restartSD() {
if (isFlatpak()) {
Process.runSync("flatpak-spawn", [
"--host",
"killall",
"speech-dispatcher"
]);
} else {
Process.runSync("killall", ["speech-dispatcher"]);
}
}

void getCurrentVoice() async {
File modelConf = File(
path.join(getHome()!, ".config/speech-dispatcher/modules/piper.conf"));
Expand Down Expand Up @@ -112,7 +124,7 @@ class _VoiceSelectorState extends State<VoiceSelector> {
File sdConfig = File(path.join(confDir.path, "speechd.conf"));
sdConfig.createSync();
sdConfig.writeAsString(sdConfigTemplate);
Process.runSync("killall", ["speech-dispatcher"]);
restartSD();
Timer(const Duration(seconds: 2), () {
confirmConfigChange(originalConfigDir);
});
Expand All @@ -128,7 +140,7 @@ class _VoiceSelectorState extends State<VoiceSelector> {
setState(() {
currentVoice = "";
});
Process.runSync("killall", ["speech-dispatcher"]);
restartSD();
Timer(const Duration(seconds: 2), () {
showDialog<void>(
context: context,
Expand Down Expand Up @@ -314,16 +326,7 @@ class _VoiceSelectorState extends State<VoiceSelector> {
configString.replaceAll(
"LANGUAGE", voice.value[1]);
modelConf.writeAsString(configString);
if (isFlatpak()) {
Process.runSync("flatpak-spawn", [
"--host",
"killall",
"speech-dispatcher"
]);
} else {
Process.runSync("killall",
["speech-dispatcher"]);
}
restartSD();
setState(() {
currentVoice = voice.value[3];
});
Expand Down

0 comments on commit bc3439f

Please sign in to comment.