hyprland-dotfiles/hypr/settings/modules/waybar/workspaces/module.sh

42 lines
865 B
Bash
Raw Normal View History

2023-12-18 19:33:29 +00:00
#!/bin/bash
_getHeader "$name" "$author"
# Define File
targetFile="$HOME/dotfiles/waybar/modules.json"
# Define Markers
startMarker="\/\/ START WORKSPACE"
endMarker="\/\/ END WORKSPACES"
# Define Replacement Template
customtemplate="\"*\": VALUE"
# Select Value
customvalue=$(gum choose 5 6 7 8 9 10)
2023-12-20 10:58:05 +00:00
if [ ! -z $customvalue ] ;then
2023-12-18 19:33:29 +00:00
# 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-19 03:32:25 +00:00
setsid $HOME/dotfiles/waybar/launch.sh 1>/dev/null 2>&1 &
2023-12-18 19:33:29 +00:00
_goBack
else
echo "ERROR: Marker not found."
sleep 2
_goBack
fi
2023-12-20 10:58:05 +00:00
else
_goBack
fi