Sway stuff and setup scripts overhaul
This commit is contained in:
parent
b5f99b9d7d
commit
432e36183a
5
de/sway/dm_entry
Normal file
5
de/sway/dm_entry
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
[Desktop Entry]
|
||||||
|
Name=Sway
|
||||||
|
Comment=SirCmpwn's Wayland window manager
|
||||||
|
Exec=sway-lytedev
|
||||||
|
Type=Application
|
78
scripts/setup_helpers.bash
Normal file
78
scripts/setup_helpers.bash
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
dfp=$(cd "$(dirname "${BASH_SOURCE[0]}" )/.." && pwd)
|
||||||
|
source "${dfp}/shell/bash/bashrc"
|
||||||
|
|
||||||
|
USER_DISAGREE_CODE=120
|
||||||
|
NO_AGREEMENT_CODE=121
|
||||||
|
|
||||||
|
_dotfiles_setup_check_agreement() {
|
||||||
|
local -r lock_file="$1"
|
||||||
|
|
||||||
|
# Let user know that this script will delete their current configuration and
|
||||||
|
# that they should read this script before running. We'll use a lock file so
|
||||||
|
# the user only needs to agree once.
|
||||||
|
if [ -f "$lock_file" ]; then
|
||||||
|
# User agreed already - do nothing
|
||||||
|
echo -e "\nLinking files...\n"
|
||||||
|
else
|
||||||
|
echo -e "\nRunning this script may delete existing personal configuration files."
|
||||||
|
echo "Please view this script's source, fully understand it, and backup any"
|
||||||
|
echo "files before continuing."
|
||||||
|
echo -e "\nSeriously. Like... entire directories. Just gone. Completely.\n"
|
||||||
|
read -r -p "Are you sure you want to continue? [y/N] " response
|
||||||
|
response=${response,,} # to lower case
|
||||||
|
if [[ $response =~ ^(yes|y)$ ]]; then
|
||||||
|
echo "agreed" > "$lock_file"
|
||||||
|
else
|
||||||
|
return "${USER_DISAGREE_CODE}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
export -f _dotfiles_setup_check_agreement
|
||||||
|
|
||||||
|
_dotfiles_setup_link_files() {
|
||||||
|
local links=("$@")
|
||||||
|
|
||||||
|
source_file=""
|
||||||
|
for i in "${links[@]}"; do
|
||||||
|
if [ -n "$source_file" ]; then
|
||||||
|
if [ -L "$i" ]; then # if symlink exists, delete it
|
||||||
|
rm -rf "$i"
|
||||||
|
fi
|
||||||
|
if [ -f "$i" ]; then # if file exists, delete it
|
||||||
|
rm -rf "$i"
|
||||||
|
fi
|
||||||
|
if [ -d "$i" ]; then # if directory exists, delete it
|
||||||
|
rm -rf "$i"
|
||||||
|
fi
|
||||||
|
# check if the directory that will contain the link exists
|
||||||
|
DIR_TO_LINK=$(dirname "$i")
|
||||||
|
if [ -d "$DIR_TO_LINK" ]; then
|
||||||
|
:
|
||||||
|
else
|
||||||
|
mkdir -p "$DIR_TO_LINK"
|
||||||
|
fi
|
||||||
|
ln -s "$source_file" "$i"
|
||||||
|
echo -e " Linking (from/to):\n ~/$(realpath --relative-to="$HOME" "$source_file")\n $i"
|
||||||
|
source_file=""
|
||||||
|
else
|
||||||
|
source_file="$i"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo -e "\nDone.\n"
|
||||||
|
}
|
||||||
|
export -f _dotfiles_setup_link_files
|
||||||
|
|
||||||
|
_dotfiles_setup_run_setup() {
|
||||||
|
local -r lock_file="$1" && shift
|
||||||
|
|
||||||
|
if _dotfiles_setup_check_agreement "$lock_file"; then
|
||||||
|
_dotfiles_setup_link_files "$@"
|
||||||
|
else
|
||||||
|
echo "Quitting due to lack of user agreement."
|
||||||
|
return "${NO_AGREEMENT_CODE}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
export -f _dotfiles_setup_run_setup
|
68
setup
68
setup
|
@ -1,34 +1,10 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
if [[ -z "$XDG_CONFIG_HOME" ]]; then
|
# TODO: ascii art header
|
||||||
export XDG_CONFIG_HOME="$HOME/.config"
|
|
||||||
fi
|
|
||||||
|
|
||||||
dfp=$(cd "$(dirname "${BASH_SOURCE[0]}" )/" && pwd)
|
dfp=$(cd "$(dirname "${BASH_SOURCE[0]}" )/" && pwd)
|
||||||
|
source "${dfp}/scripts/setup_helpers.bash"
|
||||||
|
|
||||||
ALERT_AGREEMENT_FILE="$dfp/.agreed-to-erasing-files.lock"
|
|
||||||
|
|
||||||
# Let user know that this script will delete their current configuration and
|
|
||||||
# that they should read this script before running. We'll use a lock file so
|
|
||||||
# the user only needs to agree once.
|
|
||||||
if [ -f "$ALERT_AGREEMENT_FILE" ]; then
|
|
||||||
# User agreed already - do nothing
|
|
||||||
echo "Linking..."
|
|
||||||
else
|
|
||||||
echo "Running this script may delete existing personal configuration files."
|
|
||||||
echo "Please view this script's source, fully understand it, and backup any"
|
|
||||||
echo "files before continuing."
|
|
||||||
echo "Seriously. Like... entire directories. Just gone."
|
|
||||||
read -r -p "Are you sure you want to continue? [y/N] " response
|
|
||||||
response=${response,,} # to lower case
|
|
||||||
if [[ $response =~ ^(yes|y)$ ]]; then
|
|
||||||
echo "agreed" > "$ALERT_AGREEMENT_FILE"
|
|
||||||
else
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# TODO: make sure we have an even number, here
|
|
||||||
links=(
|
links=(
|
||||||
# desktop environment files
|
# desktop environment files
|
||||||
"$dfp/de/sway/config" "$XDG_CONFIG_HOME/sway/config"
|
"$dfp/de/sway/config" "$XDG_CONFIG_HOME/sway/config"
|
||||||
|
@ -98,31 +74,17 @@ links=(
|
||||||
"$dfp/shell/user-dirs" "$XDG_CONFIG_HOME/user-dirs.dirs"
|
"$dfp/shell/user-dirs" "$XDG_CONFIG_HOME/user-dirs.dirs"
|
||||||
)
|
)
|
||||||
|
|
||||||
source=""
|
_dotfiles_setup_run_setup "$dfp/.agreed-to-erasing-files.lock" "${links[@]}"
|
||||||
for i in "${links[@]}"; do
|
|
||||||
if [ -n "$source" ]; then
|
|
||||||
if [ -L "$i" ]; then # if symlink exists, delete it
|
|
||||||
rm -rf "$i"
|
|
||||||
fi
|
|
||||||
if [ -f "$i" ]; then # if file exists, delete it
|
|
||||||
rm -rf "$i"
|
|
||||||
fi
|
|
||||||
if [ -d "$i" ]; then # if directory exists, delete it
|
|
||||||
rm -rf "$i"
|
|
||||||
fi
|
|
||||||
# check if the directory that will contain the link exists
|
|
||||||
DIR_TO_LINK=$(dirname "$i")
|
|
||||||
if [ -d "$DIR_TO_LINK" ]; then
|
|
||||||
:
|
|
||||||
else
|
|
||||||
mkdir -p "$DIR_TO_LINK"
|
|
||||||
fi
|
|
||||||
ln -s "$source" "$i"
|
|
||||||
echo "Linked $(basename $source) to $i."
|
|
||||||
source=""
|
|
||||||
else
|
|
||||||
source="$i"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "Done."
|
echo -n -e "Do you want to run the sudo_setup script for changes to /etc"
|
||||||
|
echo -n -e "\nand other root directories?"
|
||||||
|
read -r -p " [y/N] " response
|
||||||
|
response=${response,,} # to lower case
|
||||||
|
if [[ $response =~ ^(yes|y)$ ]]; then
|
||||||
|
"$dfp/sudo_setup"
|
||||||
|
else
|
||||||
|
::
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "Dotfiles Installed! Running 'exec bash'...\n"
|
||||||
|
exec bash
|
||||||
|
|
|
@ -1,22 +1,22 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# bashrc is executed when a bash process starts
|
# these are all paths used across many of the dotfiles and should be assumed to
|
||||||
|
# be loaded and properly set by every script - this means you are responsible
|
||||||
# these are all paths used across all the dotfiles and should be assumed to be
|
# for making sure they're loaded!
|
||||||
# loaded and properly set by every script - this means you are responsible for
|
|
||||||
# making sure they're loaded!
|
|
||||||
export XDG_CONFIG_HOME="$HOME/.config"
|
export XDG_CONFIG_HOME="$HOME/.config"
|
||||||
export DOTFILES_PATH="$XDG_CONFIG_HOME/dotfiles"
|
export DOTFILES_PATH="$XDG_CONFIG_HOME/dotfiles"
|
||||||
NICE_HOME="$HOME"
|
NICE_HOME="$HOME"
|
||||||
|
|
||||||
|
# TODO: better logic for auto-detecting alternative home directories?
|
||||||
|
# 1. check dirname(basename $HOME)) matches username
|
||||||
|
# 2. check /home/$username
|
||||||
[[ $(basename "${HOME}") = "usr" ]] && NICE_HOME="$(realpath "$HOME/..")"
|
[[ $(basename "${HOME}") = "usr" ]] && NICE_HOME="$(realpath "$HOME/..")"
|
||||||
[[ $(basename "${HOME}") = ".home" ]] && NICE_HOME="$(realpath "$HOME/..")"
|
[[ $(basename "${HOME}") = ".home" ]] && NICE_HOME="$(realpath "$HOME/..")"
|
||||||
|
# TODO: nice home explicitly definable on a per-device (env) basis
|
||||||
|
|
||||||
export NICE_HOME
|
export NICE_HOME
|
||||||
export NOTES_DIR="$NICE_HOME/doc/notes"
|
export NOTES_DIR="$NICE_HOME/doc/notes"
|
||||||
|
|
||||||
# TODO: nice home on a per-device basis
|
|
||||||
|
|
||||||
# set our PATH
|
# set our PATH
|
||||||
source "$DOTFILES_PATH/shell/bash/paths"
|
source "$DOTFILES_PATH/shell/bash/paths"
|
||||||
|
|
||||||
|
@ -27,10 +27,10 @@ source "$DOTFILES_PATH/shell/bash/aliases"
|
||||||
source "$DOTFILES_PATH/shell/bash/autocompletions"
|
source "$DOTFILES_PATH/shell/bash/autocompletions"
|
||||||
|
|
||||||
# load our key binds
|
# load our key binds
|
||||||
bind -f "$DOTFILES_PATH/shell/inputrc"
|
case $- in
|
||||||
|
*i*) bind -f "$DOTFILES_PATH/shell/inputrc";;
|
||||||
# less tab size of 2 spaces
|
*) ;;
|
||||||
LESS="-x2"
|
esac
|
||||||
|
|
||||||
# stop parsing on a non-interactive shell
|
# stop parsing on a non-interactive shell
|
||||||
[ -z "$PS1" ] && return
|
[ -z "$PS1" ] && return
|
||||||
|
@ -59,9 +59,26 @@ source "$DOTFILES_PATH/shell/bash/prompt"
|
||||||
shopt -s histverify
|
shopt -s histverify
|
||||||
|
|
||||||
# prevents some Java GUI apps from not working or rendering properly due to
|
# prevents some Java GUI apps from not working or rendering properly due to
|
||||||
# using bspwm
|
# using wacky window managers
|
||||||
export _JAVA_AWT_WM_NONREPARENTING=1
|
export _JAVA_AWT_WM_NONREPARENTING=1
|
||||||
|
|
||||||
|
LS_COLORS='ow=01;36;40'
|
||||||
|
export LS_COLORS
|
||||||
|
|
||||||
|
# less tab size of 2 spaces
|
||||||
|
LESS="-x2"
|
||||||
|
export LESS
|
||||||
|
|
||||||
|
# set our EDITOR to neovim if we've got it
|
||||||
|
export EDITOR="vim"
|
||||||
|
if command -v nvim >/dev/null 2>&1; then
|
||||||
|
alias vim="nvim"
|
||||||
|
alias ovim="\\vim"
|
||||||
|
export EDITOR="nvim"
|
||||||
|
fi
|
||||||
|
|
||||||
|
export BROWSER="firefox-developer-edition"
|
||||||
|
|
||||||
# load a per-device config last so anything can be overridden
|
# load a per-device config last so anything can be overridden
|
||||||
if [ -a "$HOME/.env_bashrc" ]; then
|
if [ -a "$HOME/.env_bashrc" ]; then
|
||||||
source "$HOME/.env_bashrc"
|
source "$HOME/.env_bashrc"
|
||||||
|
@ -72,22 +89,9 @@ fi
|
||||||
# directory where they keep the stuff they actually care about
|
# directory where they keep the stuff they actually care about
|
||||||
# we only do this if the user is opening a shell at $HOME
|
# we only do this if the user is opening a shell at $HOME
|
||||||
if [ "$PWD" = "$HOME" ]; then
|
if [ "$PWD" = "$HOME" ]; then
|
||||||
cd "$NICE_HOME"
|
cd "$NICE_HOME" || cd || return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
_make_paths
|
_make_paths
|
||||||
|
|
||||||
LS_COLORS='ow=01;36;40'
|
|
||||||
export LS_COLORS
|
|
||||||
|
|
||||||
# set our EDITOR to neovim if we've got it
|
|
||||||
export EDITOR="vim"
|
|
||||||
if command -v nvim >/dev/null 2>&1; then
|
|
||||||
alias vim="nvim"
|
|
||||||
alias ovim="\\vim"
|
|
||||||
export EDITOR="nvim"
|
|
||||||
fi
|
|
||||||
|
|
||||||
export BROWSER="firefox"
|
|
||||||
|
|
||||||
[ -f ~/.fzf.bash ] && source ~/.fzf.bash
|
[ -f ~/.fzf.bash ] && source ~/.fzf.bash
|
||||||
|
|
21
sudo_setup
Executable file
21
sudo_setup
Executable file
|
@ -0,0 +1,21 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# TODO: ascii art header
|
||||||
|
|
||||||
|
if [[ $UID -ne 0 ]]; then
|
||||||
|
echo "Re-running with 'sudo -E'..."
|
||||||
|
sudo -E "$0" "$@"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
dfp=$(cd "$(dirname "${BASH_SOURCE[0]}" )/" && pwd)
|
||||||
|
source "${dfp}/scripts/setup_helpers.bash"
|
||||||
|
|
||||||
|
links=(
|
||||||
|
# display manager configuration files
|
||||||
|
"$dfp/de/sway/sway-init" "/usr/bin/sway-lytedev"
|
||||||
|
"$dfp/de/sway/dm_entry" "/usr/share/wayland-sessions/sway-lytedev.desktop"
|
||||||
|
)
|
||||||
|
|
||||||
|
_dotfiles_setup_run_setup "$dfp/.agreed-to-erasing-root-files.lock" "${links[@]}"
|
||||||
|
|
Reference in a new issue