fg_black="$(tput setaf 0)" fg_red="$(tput setaf 1)" fg_green="$(tput setaf 2)" fg_yellow="$(tput setaf 3)" fg_blue="$(tput setaf 4)" fg_magenta="$(tput setaf 5)" fg_cyan="$(tput setaf 6)" fg_white="$(tput setaf 7)" reset="$(tput sgr0)" scriptdir=$PWD # -------- NOTES # see all keys # `gsettings list-keys org.gnome.shell.keybindings ` # # then do something like: # `gsettings set org.gnome.shell.keybindings screenshot '["disabled"]'` cecho() { local text="$1" local color="$2" # Ensure the color variable exists and is valid if [[ -z "$color" || -z "${!color}" ]]; then echo "Error: Invalid color variable" return 1 fi local fg_color="${!color}" # Print the colored string echo -e "${fg_color}${text}${reset}" } cecho "Installing gnome-specific packages" fg_cyan sudo apt install -y gnome-tweaks gsettings set org.gnome.desktop.interface gtk-theme Tokyonight-Dark gsettings set org.gnome.shell.extensions.user-theme name Tokyonight-Dark gsettings set org.gnome.desktop.interface icon-theme kora gsettings set org.gnome.desktop.default-applications.terminal exec ‘kitty’ # better alt tab functionality cecho "Making alt-tab better :)" fg_cyan gsettings set org.gnome.desktop.wm.keybindings switch-windows "['Tab']" gsettings set org.gnome.desktop.wm.keybindings switch-windows-backward "['Tab']" gsettings set org.gnome.desktop.wm.keybindings switch-applications "[]" gsettings set org.gnome.desktop.wm.keybindings switch-applications-backward "[]" gsettings set org.gnome.shell.keybindings screenshot "['Print']" gsettings set org.gnome.shell.keybindings screenshot-window "['Print']" gsettings set org.gnome.shell.keybindings show-screenshot-ui "['S']" if $is_macbook; then cecho "Swapping left Super & left Control" fg_cyan bash options/toggle-gnome-macbook-keyboard.sh 1 fi cecho "Turning off hot corner" fg_cyan gsettings set org.gnome.desktop.interface enable-hot-corners false gsettings set org.gnome.mutter edge-tiling false sudo apt install -y pipx # adds ~/.local/bin to PATH pipx ensurepath # https://github.com/essembeh/gnome-extensions-cli pipx install gnome-extensions-cli --system-site-packages # install gnome extensions gext install dash-to-dock@micxgx.gmail.com user-theme@gnome-shell-extensions.gcampax.github.com emoji-copy@felipeftn tiling-assistant@leleat-on-github Vitals@CoreCoding.com # enable gnome extensions gext enable dash-to-dock@micxgx.gmail.com user-theme@gnome-shell-extensions.gcampax.github.com emoji-copy@felipeftn tiling-assistant@leleat-on-github Vitals@CoreCoding.com # wobbly windows # gext install compiz-windows-effect@hermes83.github.com # gext enable compiz-windows-effect@hermes83.github.com # custom keyboard shortcuts # "name|command|binding" keybindings=( "Terminal|kitty|Return" "wallpaper|~/.utils/wallpaper.sh|Launch7" "browser|librewolf|Shift" ) # Get the current list of custom keybindings current_keybindings=$(gsettings get org.gnome.settings-daemon.plugins.media-keys custom-keybindings) current_keybindings=$(echo "$current_keybindings" | sed "s/^\[\(.*\)\]$/\1/") if [ "$current_keybindings" == "@as []" ]; then echo "Current keybinds are empty" next_index=0 else # Get the highest index currently used existing_indices=$(echo "$current_keybindings" | tr ',' '\n' | grep -o 'custom[0-9]\+' | sed 's/custom//' | sort -n) if [ -z "$existing_indices" ]; then next_index=0 else last_index=$(echo "$existing_indices" | tail -n 1) next_index=$((last_index + 1)) fi # Store new paths to update the keybinding list new_keybinding_paths=() # Get all existing bindings for comparison (just the binding part) existing_bindings=() for keybinding in $(echo "$current_keybindings" | tr ',' '\n'); do binding_path=$(echo "$keybinding" | sed "s/^'//;s/'$//") binding_command=$(gsettings get org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:$binding_path binding) existing_bindings+=("$(echo $binding_command | sed "s/^'//;s/'$//")") # Remove quotes done fi # Loop over keybindings and add them for entry in "${keybindings[@]}"; do IFS='|' read -r name command binding <<< "$entry" # Check if the binding already exists if [ "$current_keybindings" == "@as []" ]; then echo "Current keybinds are empty" else if [[ " ${existing_bindings[@]} " =~ " $binding " ]]; then # If binding exists, prompt user to overwrite echo "Keybinding '$binding' already exists for another action." read -p "Do you want to overwrite it? (y/n): " overwrite if [[ "$overwrite" != "y" && "$overwrite" != "Y" ]]; then echo "Skipping '$binding'." continue fi fi fi # Define the new keybinding path new_path="/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom$next_index/" new_keybinding_paths+=("'$new_path'") # Wrap paths in single quotes # Set individual keybinding settings gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:"$new_path" name "$name" gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:"$new_path" command "$command" gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:"$new_path" binding "$binding" echo "Added keybinding: $name ($binding) -> $command" next_index=$((next_index + 1)) done # Now merge old and new keybindings properly # First, join the keybinding paths with commas, ensuring proper quoting if [ "$current_keybindings" == "@as []" ]; then echo "Current keybinds are empty" all_keybindings="" else all_keybindings="$current_keybindings" fi for path in "${new_keybinding_paths[@]}"; do # Add each new keybinding path to the list, ensuring proper formatting if [ -z "$all_keybindings" ]; then all_keybindings="$path" else all_keybindings="$all_keybindings,$path" fi done # Ensure the list is properly wrapped in square brackets all_keybindings="[$all_keybindings]" # Update the system keybinding list gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings "$all_keybindings" echo "Keybindings updated successfully!"