dotfiles/.local/bin/toggle-opacity

25 lines
829 B
Bash
Executable file

#!/bin/bash
# Path to alacritty config file
CONFIG_FILE="$HOME/.config/alacritty/alacritty.toml"
# Check if config file exists
if [ ! -f "$CONFIG_FILE" ]; then
echo "Error: Config file not found at $CONFIG_FILE"
exit 1
fi
# Check if opacity line exists (commented or not)
if grep -q "^opacity = 0.85" "$CONFIG_FILE"; then
# Line is uncommented, comment it out
sed -i 's/^opacity = 0.85/# opacity = 0.85/' "$CONFIG_FILE"
echo "Opacity disabled (line commented out)"
elif grep -q "^# opacity = 0.85" "$CONFIG_FILE"; then
# Line is commented, uncomment it
sed -i 's/^# opacity = 0.85/opacity = 0.85/' "$CONFIG_FILE"
echo "Opacity enabled (line uncommented)"
else
# Line doesn't exist, add it uncommented
echo "opacity = 0.85" >> "$CONFIG_FILE"
echo "Opacity line added and enabled"
fi