samedi 16 octobre 2021

Conditional `if` statement with strings in shell script to configure two computers differently (Ubuntu/Gnome vs Debian/XCFE)

I want to check the current distro in .profile because I have two computers. In one I have Ubuntu with Gnome, and in another I have Debian with XFCE. In either case I want to have different configurations, but I can't manage to even get the following code working in Ubuntu:


if [[ awk '{gsub(/ /, "", $1); print $1=$1}' /etc/issue == "Ubuntu" ]]; then
            gsettings set org.gnome.mutter overlay-key ''
            gsettings set org.gnome.shell.extensions.dash-to-dock hot-keys false
fi

I get:


bash: .bashrc:223: conditional binary operator expected
bash: .bashrc:223: syntax error near `$1=$1}''
bash: .bashrc:223: `if [[ awk '{gsub(/ /, "", $1); print $1=$1}' /etc/issue == "Ubuntu" ]]; then'

But as far as I can tell, the conditional is rightly specified... Any clues any one?

Aucun commentaire:

Enregistrer un commentaire