added asktobreak and salt

This commit is contained in:
Jonas Forsberg 2020-08-01 14:06:50 +02:00
parent 64d0510af6
commit a6142a9564
No known key found for this signature in database
GPG Key ID: F2E9818C70350CC9

View File

@ -10,6 +10,17 @@ DOTFILES_REMOTE="https://git.rre.nu:443/jonas/dotfiles.git"
set -aeo pipefail set -aeo pipefail
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
}
function new_log(){ function new_log(){
# script output # script output
printf "\n**** [$*] ***\n" printf "\n**** [$*] ***\n"
@ -20,6 +31,10 @@ function log(){
} }
function gnome_key_bindings(){ function gnome_key_bindings(){
new_log "Setting my default gnome bindings"
if asktobreak; then
return
fi
local KEY_PATH="/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings" 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" 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/']" gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings "['$KEY_PATH/custom0/']"
@ -33,7 +48,9 @@ function gnome_key_bindings(){
function setup_dotfiles(){ function setup_dotfiles(){
local dotf="/usr/bin/git --git-dir="$DOTFILES_REPO" --work-tree=$HOME" local dotf="/usr/bin/git --git-dir="$DOTFILES_REPO" --work-tree=$HOME"
new_log "Setting up dotf (dotfiles)" new_log "Setting up dotf (dotfiles)"
if asktobreak;then
return
fi
log "creating git repo in $DOTFILES_REPO" log "creating git repo in $DOTFILES_REPO"
mkdir "$HOME/.dotfiles" mkdir "$HOME/.dotfiles"
git init --bare "$DOTFILES_REPO" git init --bare "$DOTFILES_REPO"
@ -52,4 +69,12 @@ function setup_dotfiles(){
$dotf checkout master $dotf checkout master
} }
function do_salt_call(){
alias salt='sudo salt-call --local --file-root "$HOME/salt/states" --pillar-root "$HOME/salt/pillars" "$@"'
new_log "Running salt high state"
if asktobreak;then
return
fi
salt state.apply
}
setup_dotfiles setup_dotfiles