dotfiles

A steaming hot pile of sh...ell scripts and configuration files.
git clone https://kaka.farm/~git/dotfiles
Log | Files | Refs

toggle-gsetting.sh (584B)


      1 #!/bin/sh
      2 
      3 if [ -z "$(command -v gsettings)" ]; then
      4     printf "No \"gsettings\" command!\n";
      5     exit 1;
      6 fi
      7 
      8 name="$1"
      9 schema="$2"
     10 key="$3"
     11 
     12 current_value="$(gsettings get $schema $key)"
     13 
     14 if [ "$current_value" = "true" ]; then
     15     printf "%s set to false\n" "$name"
     16     gsettings set "$schema" "$key" false
     17 elif [ "$current_value" = "false" ]; then
     18     printf "%s set to true\n" "$name"
     19     gsettings set "$schema" "$key" true
     20 else
     21     printf "Something's wrong! %s not changed.  Not a valid %s value: %s\n" \
     22            "$name" \
     23            "$key" \
     24            "$current_value"
     25 fi