dotfiles/bin/initDesktop

86 lines
2.2 KiB
Plaintext
Raw Normal View History

2020-08-01 11:21:48 +00:00
#!/bin/bash
# Set up my desktop/laptop with all default setttings that I want.
#
# uses salt-call masterless configuration.
DOTFILES_REPO="$HOME/.dotfiles"
DOTFILES_REMOTE="https://git.rre.nu:443/jonas/dotfiles.git"
### NO Changes below this line
set -aeo pipefail
2020-08-01 12:06:50 +00:00
function asktobreak(){
printf "Do you want to run this step (y/n)"
while read -r -n 1 -s answer; do
if [[ $answer == [YyNn] ]];then
[[ $answer == [Yy] ]] && return_value=1
[[ $answer == [Nn] ]] && return_value=0
break;
fi
done
return $return_value
}
2020-08-01 11:21:48 +00:00
function new_log(){
# script output
2020-08-01 11:45:28 +00:00
printf "\n**** [$*] ***\n"
2020-08-01 11:21:48 +00:00
}
function log(){
2020-08-01 11:45:28 +00:00
printf "$*\n"
2020-08-01 11:21:48 +00:00
}
function gnome_key_bindings(){
2020-08-01 12:06:50 +00:00
new_log "Setting my default gnome bindings"
if asktobreak; then
return
fi
2020-08-01 11:21:48 +00:00
local KEY_PATH="/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings"
local CMD="gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:$KEY_PATH"
gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings "['$KEY_PATH/custom0/']"
# Open Terminator
$CMD/custom0/ name "Open Terminator"
$CMD/custom0/ command "terminator"
$CMD/custom0/ binding "<Primary><Alt>Return"
}
function setup_dotfiles(){
local dotf="/usr/bin/git --git-dir="$DOTFILES_REPO" --work-tree=$HOME"
new_log "Setting up dotf (dotfiles)"
2020-08-01 12:06:50 +00:00
if asktobreak;then
return
fi
2020-08-01 11:21:48 +00:00
log "creating git repo in $DOTFILES_REPO"
mkdir "$HOME/.dotfiles"
git init --bare "$DOTFILES_REPO"
$dotf config --local status.showUntrackedFiles no
log "adding remote repo ($DOTFILES_REMOTE)"
$dotf remote add origin "$DOTFILES_REMOTE"
2020-08-01 11:45:28 +00:00
if [[ -f "$HOME/.bashrc" ]];then
2020-08-01 11:21:48 +00:00
log "renaming local .bashrc to .bashrc.bak"
mv "$HOME/.bashrc" "$HOME/.bashrc.bak"
fi
2020-08-01 11:43:02 +00:00
log "fetching dotfiles"
$dotf fetch origin
$dotf checkout master
2020-08-01 11:21:48 +00:00
}
2020-08-01 12:06:50 +00:00
function do_salt_call(){
local salt="sudo salt-call --local --file-root $HOME/salt/states --pillar-root $HOME/salt/pillars"
2020-08-01 12:06:50 +00:00
new_log "Running salt high state"
if asktobreak;then
return
fi
2020-08-01 12:55:12 +00:00
$salt state.apply pillar="{username: $USER}"
2020-08-01 12:06:50 +00:00
}
2020-08-01 12:08:17 +00:00
2020-08-01 11:21:48 +00:00
setup_dotfiles
2020-08-01 12:08:17 +00:00
do_salt_call
2020-08-01 12:55:12 +00:00
gnome_key_bindings
2020-08-01 13:02:50 +00:00
printf "\n DONE!!!!!!!\n"