summarylogtreecommitdiffstats
path: root/piper-voices-pl-pl.install
blob: 05ffb247929b9c54d6090d5efe3a88e2519b55be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Define the lines to be added or removed
LANG_LINE='GenericLanguage   "pl" "pl_PL" "utf-8"'
VOICE_LINE='AddVoice "pl" "MALE1" "pl/pl_PL/darkman/medium/pl_PL-darkman-medium"'

post_install() {
  # Check if the piper-generic.conf file exists
  if [ -f /etc/speech-dispatcher/modules/piper-generic.conf ]; then
    # Add the lines only if they do not already exist
    if ! grep -Fxq "$LANG_LINE" /etc/speech-dispatcher/modules/piper-generic.conf; then
      echo "$LANG_LINE" >> /etc/speech-dispatcher/modules/piper-generic.conf
    fi
    if ! grep -Fxq "$VOICE_LINE" /etc/speech-dispatcher/modules/piper-generic.conf; then
      echo "$VOICE_LINE" >> /etc/speech-dispatcher/modules/piper-generic.conf
    fi
  fi
}

post_remove() {
  # Check if the piper-generic.conf file exists
  if [ -f /etc/speech-dispatcher/modules/piper-generic.conf ]; then
    # Remove the lines if they exist
    sed -i "/^$LANG_LINE$/d" /etc/speech-dispatcher/modules/piper-generic.conf
    sed -i "/^$VOICE_LINE$/d" /etc/speech-dispatcher/modules/piper-generic.conf
  fi
}