Update Replacement Function

This commit is contained in:
Stephan Raabe
2023-12-19 16:48:01 +01:00
parent eee71d8b5f
commit f6ad27e30f
5 changed files with 34 additions and 81 deletions

View File

@@ -19,25 +19,10 @@ if [ ! -z $customvalue ]; then
# Replace in Template
customtext="${customtemplate/VALUE/"$customvalue"}"
# Ensure that markers are in target file
if grep -s "$startMarker" $targetFile && grep -s "$endMarker" $targetFile; then
# Write into File
sed -i '/'"$startMarker"'/,/'"$endMarker"'/ {
//!d
/'"$startMarker"'/a\
'"$customtext"'
}' $targetFile
# Reload Waybar
setsid $HOME/dotfiles/waybar/launch.sh 1>/dev/null 2>&1 &
_goBack
else
echo "ERROR: Marker not found."
sleep 2
_goBack
fi
_replaceInFile $startMarker $endMarker $customtext $targetFile
# Reload Waybar
setsid $HOME/dotfiles/waybar/launch.sh 1>/dev/null 2>&1 &
else
echo "ERROR: Define a value."
sleep 2