#!/usr/bin/env bash ## CONSTANTS BASEDIR=$(dirname $0) ## FUNCTIONS function assert_debian13 { test -f /etc/debian_version && grep --quiet ^13\. /etc/debian_version || echo "assert: Debian 13 missing!" } function assert_gnome_desktop { [[ $XDG_SESSION_DESKTOP == "gnome" ]] || echo "assert: Gnome Shell missing!" } function install_ghostty { if ! command -v ghostty >/dev/null; then curl -sS https://debian.griffo.io/EA0F721D231FDD3A0A17B9AC7808B4DD62C41256.asc | sudo gpg --dearmor --yes -o /etc/apt/trusted.gpg.d/debian.griffo.io.gpg echo "deb https://debian.griffo.io/apt $(lsb_release -sc 2>/dev/null) main" | sudo tee /etc/apt/sources.list.d/debian.griffo.io.list sudo apt-get update && sudo apt-get install -y ghostty else echo Ghostty already installed! fi if ! systemctl is-enabled --user --quiet app-com.mitchellh.ghostty; then systemctl enable --user app-com.mitchellh.ghostty.service else echo "Ghostty service already enabled!" fi } function install_homebrew { bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" } function raise_error { message=${1:-an undefined error has occured!} code=${2:-1} echo "error ${code}: ${message}" >&2 exit "${code}" } function set_alternative { local key command path_to_command path_to_key key=$1 [[ -f /etc/alternatives/$key ]] || raise_error "alternative <${key}> not found!" 11 path_to_key=$(readlink "/etc/alternatives/$key") command=$2 path_to_command=$(command -v "${command}") if [[ "${path_to_key}" != "${path_to_command}" ]]; then echo "$key: $path_to_key != $path_to_command" sudo -vp 'sudo for update-alternatives: ' sudo update-alternatives --install "/usr/bin/${key}" "${key}" "${path_to_command}" 100 sudo update-alternatives --set "${key}" "${path_to_command}" else echo "alternative ${key} => ${command}" fi } function configure_default { # CAPS LOCK means ESC() gsettings set org.gnome.desktop.input-sources xkb-options "['caps:escape']" set_alternative editor nvim set_alternative vi nvim set_alternative vim nvim [[ ! -f $HOME/.vimrc ]] && cp "$BASEDIR/resources/vimrc" "$HOME/.vimrc" || echo vimrc defined! [[ ! -f $HOME/.config/nvim/init.vim ]] && cp "$BASEDIR/resources/init.vim" "$HOME/.config/nvim/init.vim" || echo nvim init.vim defined! [[ ! -f $HOME/.config/nvim-vanilla/init.vim ]] && cp "$BASEDIR/resources/init.vim" "$HOME/.config/nvim-vanilla/init.vim" || echo nvim-vanilla init.vim defined! } function install_neovim { local shellrc alias_expr shellrc="$HOME/.bashrc" if ! grep -q nvim-vanilla "$shellrc"; then alias_expr="alias nvim-vanilla='NVIM_APPNAME=nvim-vanilla nvim'" echo "$alias_expr" >>"$shellrc" eval "$alias_expr" echo 'nvim-vanilla created!' else echo 'nvim-vanilla ready!' fi } ## MAIN set -Eue assert_debian13 assert_gnome_desktop echo "MIAOU-DESKTOP installation..." install_ghostty # install_homebrew install_neovim configure_default echo SUCCESS