Hyprland-dotfiles/hypr/settings/modules/waybar/appslabel/module.sh

47 lines
1.0 KiB
Bash
Raw Normal View History

2023-12-18 14:33:29 -05:00
#!/bin/bash
_getHeader "$name" "$author"
echo "Define the label of the Apps Starter"
# Define File
targetFile="$HOME/dotfiles/waybar/modules.json"
# Define Markers
startMarker="\/\/ START APPS LABEL"
endMarker="\/\/ END APPS LABEL"
# Define Replacement Template
customtemplate="\"format\": \"VALUE\","
# Select Value
customvalue=$(gum input --placeholder="Define the Apps label")
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
2023-12-18 22:32:25 -05:00
setsid $HOME/dotfiles/waybar/launch.sh 1>/dev/null 2>&1 &
2023-12-18 14:33:29 -05:00
_goBack
else
echo "ERROR: Marker not found."
sleep 2
_goBack
fi
else
echo "ERROR: Define a value."
sleep 2
_goBack
fi