Update Replacement Function
This commit is contained in:
parent
eee71d8b5f
commit
f6ad27e30f
|
@ -1,4 +1,4 @@
|
||||||
# ML4W dotfiles 2.7 BETA 1
|
# ML4W dotfiles 2.7 BETA 2
|
||||||
|
|
||||||
This is my configuration of Hyprland (Wayland) and Qtile (Xorg & Wayland) for Arch. This package includes an installation script to install and setup the required components.
|
This is my configuration of Hyprland (Wayland) and Qtile (Xorg & Wayland) for Arch. This package includes an installation script to install and setup the required components.
|
||||||
|
|
||||||
|
|
|
@ -193,6 +193,21 @@ _writeConf() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# _replaceInFile $startMarket $endMarker $customtext $targetFile
|
||||||
|
_replaceInFile() {
|
||||||
|
if grep -s "$1" $4 && grep -s "$2" $4 ;then
|
||||||
|
sed -i '/'"$1"'/,/'"$2"'/ {
|
||||||
|
//!d
|
||||||
|
/'"$1"'/a\
|
||||||
|
'"$3"'
|
||||||
|
}' $4
|
||||||
|
else
|
||||||
|
echo "ERROR: $1 and/or $2 not found in $4"
|
||||||
|
sleep 2
|
||||||
|
_goBack
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Return the version of the hyprland-settings script
|
# Return the version of the hyprland-settings script
|
||||||
_getVersion() {
|
_getVersion() {
|
||||||
echo $version
|
echo $version
|
||||||
|
|
|
@ -19,26 +19,11 @@ customvalue=$(gum input --placeholder="Define the Apps label")
|
||||||
if [ ! -z $customvalue ]; then
|
if [ ! -z $customvalue ]; then
|
||||||
# Replace in Template
|
# Replace in Template
|
||||||
customtext="${customtemplate/VALUE/"$customvalue"}"
|
customtext="${customtemplate/VALUE/"$customvalue"}"
|
||||||
|
_replaceInFile $startMarker $endMarker $customtext $targetFile
|
||||||
# Ensure that markers are in target file
|
|
||||||
if grep -s "$startMarker" $targetFile && grep -s "$endMarker" $targetFile; then
|
# Reload Waybar
|
||||||
|
setsid $HOME/dotfiles/waybar/launch.sh 1>/dev/null 2>&1 &
|
||||||
# Write into File
|
_goBack
|
||||||
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
|
|
||||||
else
|
else
|
||||||
echo "ERROR: Define a value."
|
echo "ERROR: Define a value."
|
||||||
sleep 2
|
sleep 2
|
||||||
|
|
|
@ -26,55 +26,23 @@ customtemplate="VALUE\"bluetooth\","
|
||||||
customvalue=$(gum choose "SHOW" "HIDE")
|
customvalue=$(gum choose "SHOW" "HIDE")
|
||||||
|
|
||||||
if [ ! -z $customvalue ]; then
|
if [ ! -z $customvalue ]; then
|
||||||
|
|
||||||
if [ "$customvalue" == "SHOW" ] ;then
|
if [ "$customvalue" == "SHOW" ] ;then
|
||||||
customvalue=""
|
customvalue=""
|
||||||
else
|
else
|
||||||
customvalue="//"
|
customvalue="//"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Replace in Template
|
# Replace in Template
|
||||||
customtext="${customtemplate/VALUE/"$customvalue"}"
|
customtext="${customtemplate/VALUE/"$customvalue"}"
|
||||||
|
|
||||||
# Ensure that markers are in target file
|
_replaceInFile $startMarker $endMarker $customtext $targetFile1
|
||||||
if grep -s "$startMarker" $targetFile1 && grep -s "$endMarker" $targetFile1 && grep -s "$startMarker" $targetFile2 && grep -s "$endMarker" $targetFile2 && grep -s "$startMarker" $targetFile3 && grep -s "$endMarker" $targetFile3 && grep -s "$startMarker" $targetFile4 && grep -s "$endMarker" $targetFile4; then
|
_replaceInFile $startMarker $endMarker $customtext $targetFile2
|
||||||
|
_replaceInFile $startMarker $endMarker $customtext $targetFile3
|
||||||
# Write into File
|
_replaceInFile $startMarker $endMarker $customtext $targetFile4
|
||||||
sed -i '/'"$startMarker"'/,/'"$endMarker"'/ {
|
|
||||||
//!d
|
# Reload Waybar
|
||||||
/'"$startMarker"'/a\
|
setsid $HOME/dotfiles/waybar/launch.sh 1>/dev/null 2>&1 &
|
||||||
'"$customtext"'
|
_goBack
|
||||||
}' $targetFile1
|
|
||||||
|
|
||||||
# Write into File
|
|
||||||
sed -i '/'"$startMarker"'/,/'"$endMarker"'/ {
|
|
||||||
//!d
|
|
||||||
/'"$startMarker"'/a\
|
|
||||||
'"$customtext"'
|
|
||||||
}' $targetFile2
|
|
||||||
|
|
||||||
# Write into File
|
|
||||||
sed -i '/'"$startMarker"'/,/'"$endMarker"'/ {
|
|
||||||
//!d
|
|
||||||
/'"$startMarker"'/a\
|
|
||||||
'"$customtext"'
|
|
||||||
}' $targetFile3
|
|
||||||
|
|
||||||
# Write into File
|
|
||||||
sed -i '/'"$startMarker"'/,/'"$endMarker"'/ {
|
|
||||||
//!d
|
|
||||||
/'"$startMarker"'/a\
|
|
||||||
'"$customtext"'
|
|
||||||
}' $targetFile4
|
|
||||||
|
|
||||||
# Reload Waybar
|
|
||||||
setsid $HOME/dotfiles/waybar/launch.sh 1>/dev/null 2>&1 &
|
|
||||||
_goBack
|
|
||||||
|
|
||||||
else
|
|
||||||
echo "ERROR: Marker not found."
|
|
||||||
sleep 2
|
|
||||||
_goBack
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
echo "ERROR: Define a value."
|
echo "ERROR: Define a value."
|
||||||
sleep 2
|
sleep 2
|
||||||
|
|
|
@ -19,25 +19,10 @@ if [ ! -z $customvalue ]; then
|
||||||
# Replace in Template
|
# Replace in Template
|
||||||
customtext="${customtemplate/VALUE/"$customvalue"}"
|
customtext="${customtemplate/VALUE/"$customvalue"}"
|
||||||
|
|
||||||
# Ensure that markers are in target file
|
_replaceInFile $startMarker $endMarker $customtext $targetFile
|
||||||
if grep -s "$startMarker" $targetFile && grep -s "$endMarker" $targetFile; then
|
|
||||||
|
# Reload Waybar
|
||||||
# Write into File
|
setsid $HOME/dotfiles/waybar/launch.sh 1>/dev/null 2>&1 &
|
||||||
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
|
|
||||||
else
|
else
|
||||||
echo "ERROR: Define a value."
|
echo "ERROR: Define a value."
|
||||||
sleep 2
|
sleep 2
|
||||||
|
|
Loading…
Reference in New Issue
Block a user