dotfiles/.local/bin/i3-config-builder

40 lines
807 B
Plaintext
Raw Normal View History

2022-05-27 21:07:07 +02:00
#!/bin/bash
function i3setup() {
local file dir cfg path patterns=(
"config.vars"
"config.pre-main"
"config.main"
"config.post-main"
)
dir="$HOME/.config/i3"
cfg="$dir/config"
echo "Building i3 config... 🔨"
rm "$cfg" 2>/dev/null
for pattern in "${patterns[@]}"; do
while IFS= read -r path; do
[ -z "$path" ] && continue
file="${path##*/}"
echo "WRITE : '$file'."
{
echo "# >>>$file"
cat "$path" >>"$cfg"
echo "# <<<$file"
echo
} >>"$cfg"
done <<<"$(find "$dir" -maxdepth 1 -type f -name "$pattern*" | sort -n)"
done
echo
echo "Restarting i3... 🔄"
i3 restart
echo
}
i3setup