Move some scripts to external repo
This commit is contained in:
parent
6a658b2f7c
commit
1e34655bac
6 changed files with 102 additions and 325 deletions
168
.bin/autoinstall
168
.bin/autoinstall
|
@ -1,168 +0,0 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
_autoinstall_base () {
|
||||
_autoinstall_file "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" \
|
||||
"$HOME/.config/vim/autoload/plug.vim" \
|
||||
&& [ -x "$(command -v vim)" ] && yes | vim +'PlugInstall --sync' +qa --not-a-term
|
||||
|
||||
_autoinstall_git "https://github.com/wbthomason/packer.nvim" \
|
||||
"$HOME/.local/share/nvim/site/pack/packer/start/packer.nvim" \
|
||||
&& [ -x "$(command -v nvim)" ] && nvim --headless -c 'autocmd User PackerComplete quitall' -c 'PackerSync'
|
||||
|
||||
[ ! -x "$(command -v starship)" ] \
|
||||
&& curl -sS "https://starship.rs/install.sh" | BIN_DIR="$HOME/.local/bin" FORCE=1 sh
|
||||
|
||||
[ ! -x "$(command -v "git-fire")" ] \
|
||||
&& _autoinstall_exe \
|
||||
"https://raw.githubusercontent.com/qw3rtman/git-fire/master/git-fire" \
|
||||
"$HOME/.local/bin/git-fire"
|
||||
|
||||
[ ! -x "$(command -v "yadm")" ] \
|
||||
&& _autoinstall_exe \
|
||||
"https://github.com/TheLocehiliosan/yadm/raw/master/yadm" \
|
||||
"$HOME/.local/bin/yadm" \
|
||||
|
||||
[ ! -x "$(command -v "eza")" ] \
|
||||
&& _autoinstall_exe \
|
||||
"https://github.com/eza-community/eza/releases/download/v0.17.0/eza_x86_64-unknown-linux-gnu.tar.gz" \
|
||||
"$HOME/.local/bin/eza" \
|
||||
"tar xzO"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
_autoinstall_graphical () {
|
||||
_autoinstall_file \
|
||||
"https://raw.githubusercontent.com/dracula/alacritty/master/dracula.toml" \
|
||||
"$HOME/.config/alacritty/dracula.toml"
|
||||
|
||||
_autoinstall_file \
|
||||
"https://raw.githubusercontent.com/dracula/duckduckgo/master/monkeyscript.user.js" \
|
||||
"$HOME/.local/share/qutebrowser/greasemonkey/ddg-dracula.user.js"
|
||||
|
||||
_autoinstall_git \
|
||||
"https://github.com/dracula/qutebrowser.git" \
|
||||
"$HOME/.config/qutebrowser/dracula"
|
||||
|
||||
_autoinstall_git \
|
||||
"https://github.com/dracula/gtk.git" \
|
||||
"$HOME/.themes/Dracula"
|
||||
|
||||
_autoinstall_archive \
|
||||
"https://github.com/dracula/gtk/releases/download/v3.0/Dracula-cursors.tar.xz" \
|
||||
"$HOME/.icons/Dracula-cursors.tar.xz"
|
||||
|
||||
_autoinstall_archive \
|
||||
"$(curl -fsSL 'https://data.services.jetbrains.com/products?code=TBA&release.type=release&fields=releases' | jq -r '.[0].releases[0].downloads.linux.link')" \
|
||||
"$HOME/.local/bin/jetbrains-toolbox.tar.gz" \
|
||||
&& mv -f "$HOME/.local/bin/jetbrains-toolbox-"*"/jetbrains-toolbox" "$HOME/.local/bin/" \
|
||||
&& rm -rf "$HOME/.local/bin/jetbrains-toolbox-"*
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
_autoinstall_ssh () {
|
||||
_autoinstall_text \
|
||||
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCkmWZmum4cVeDy5+9N1HdUzfnjEHSJ900ucD8F0wAy4MV1cdPYnZ4u5PFv5XMfmvA9SJ+VFsr0lhYlr+GQBG9aCCAdMJVVmEz3SccT6dp6ZYywT158RNshzfCe9ylWKK80+W7XnDXhdkec7aK+BQn5wOER3A3mUqRR0JDXWga9jyakH1K6OwXmQOO419bJWs2uCT1ZEgndHxKJEt2pEvoSz7z8p1SS2zyro+R3YtvL9WiDo3+0yPFYficNDr7s39yF5IJE+KTqAlCn5R2+kJ54lRmzB8oNS2jGwK2Q6wtph4AmfnlJTMODG2U2RjUltH2MIDXIYe2epATWL8qhkI4LTr38C7QR3DeJQsel/yTWdYqGakvU6Ge/xkbsaWOrSDTV3bPgKHzlL+dIKaGpV+5usZN4fpOLOb/nmYy3ekLpobzxza7rBRT2CxXS72DoPFaRE1ye7SxhcsLBNwre9YQFE4VvUZwJYkWz2V7eqGrk8VYnmQmT/bnUnMnVwMpeDc7pFKAFndIUxifoOj77c98Tdy3ncdS7SOd7+zRbLG+7k0UU1k89o1+tfREAddUJYR4RvB6g0kCyjpwOf1Pt4zhJR3y/zpsCCc5UnzK9X2kEo/8TSyvTr+GBiFVp5yLYgwCPJSNna33YX7+c3oLRM1QGgtqZk9qnGX9hgP8qpF8Akw== openpgp:0xAB920993" \
|
||||
"$HOME/.ssh/authorized_keys"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
_autoinstall_all () {
|
||||
_autoinstall_base
|
||||
_autoinstall_graphical
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# $1: URL
|
||||
# $2: path
|
||||
_autoinstall_git () {
|
||||
if [ ! -d "$2" ]
|
||||
then
|
||||
echo "Installing repo $1 to $2"
|
||||
mkdir -p "$2"
|
||||
git clone --depth=1 "$1" "$2" >/dev/null 2>&1
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
# $1: URL
|
||||
# $2: path
|
||||
# $3: curl pipe
|
||||
_autoinstall_file () {
|
||||
if [ ! -f "$2" ]
|
||||
then
|
||||
echo "Installing file $1 to $2"
|
||||
file_path=$(dirname "$2")
|
||||
mkdir -p "$file_path"
|
||||
cd "$file_path" || exit
|
||||
curl -fsSL "$1" | eval "${3:-cat}" > "$2"
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
# $1: text
|
||||
# $2: path
|
||||
_autoinstall_text() {
|
||||
if [ ! -f "$2" ]
|
||||
then
|
||||
echo "Installing text to $2"
|
||||
file_path=$(dirname "$2")
|
||||
mkdir -p "$file_path"
|
||||
cd "$file_path" || exit
|
||||
echo "$1" > "$2"
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
# $1: URL
|
||||
# $2: path
|
||||
# $3: curl pipe
|
||||
_autoinstall_exe () {
|
||||
_autoinstall_file "$1" "$2" "$3" && chmod +x "$2"
|
||||
}
|
||||
|
||||
# $1: URL
|
||||
# $2: path
|
||||
_autoinstall_archive () {
|
||||
if [ ! -f "$2" ]
|
||||
then
|
||||
echo "Installing archive $1 to $2"
|
||||
file_path=$(dirname "$2")
|
||||
mkdir -p "$file_path"
|
||||
cd "$file_path" || exit
|
||||
curl -fsSLo "$2" "$1"
|
||||
tar xaf "$2"
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
# $1: template
|
||||
# $2: path
|
||||
_autoinstall_env () {
|
||||
if [ -x "$(command -v envsubst)" ]
|
||||
then
|
||||
envsubst < "$1.tpl" > "$1"
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
action="${1:-base}"
|
||||
case $action in
|
||||
all) _autoinstall_all ;;
|
||||
base) _autoinstall_base ;;
|
||||
ssh) _autoinstall_ssh ;;
|
||||
graphical) _autoinstall_graphical ;;
|
||||
git) _autoinstall_git "$2" "$3" ;;
|
||||
file) _autoinstall_file "$2" "$3" ;;
|
||||
archive) _autoinstall_archive "$2" "$3" ;;
|
||||
env) _autoinstall_env "$2" ;;
|
||||
*) echo "'$action' is not a valid action." ;;
|
||||
esac
|
|
@ -1,138 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
hostname=$(cat /proc/sys/kernel/hostname)
|
||||
|
||||
_systemctl () {
|
||||
systemctl --user "${@:2}" "autostart@$1.service"
|
||||
}
|
||||
|
||||
_query_autostart_toml() {
|
||||
tomlq -r --arg host "$hostname" \
|
||||
'.hosts[$host].groups as $groups | .apps | to_entries[] | select(
|
||||
(.value.hosts | contains([$host])) or
|
||||
([.value.group] | inside($groups))
|
||||
) | '"$1" \
|
||||
"$XDG_CONFIG_HOME/autostart.toml"
|
||||
}
|
||||
|
||||
_list () {
|
||||
_query_autostart_toml '.value.alias // .key'
|
||||
}
|
||||
|
||||
_echo_table () {
|
||||
for unit in "$@"
|
||||
do
|
||||
printf "%s\t%s\t%s\t%s\n" \
|
||||
"$unit" \
|
||||
"$(_systemctl "$unit" is-enabled)" \
|
||||
"$(_systemctl "$unit" is-active)" \
|
||||
"$(_get_autostart_cmd "$unit")"
|
||||
done
|
||||
}
|
||||
|
||||
_autostart_manage_list () {
|
||||
_list
|
||||
}
|
||||
|
||||
_autostart_manage_info () {
|
||||
autostart_units=()
|
||||
while IFS='' read -r line
|
||||
do
|
||||
autostart_units+=("$line")
|
||||
done < <(_list)
|
||||
|
||||
_echo_table "${autostart_units[@]}" | column -t -s$'\t' --table-columns 'Unit,Enabled?,Active?,Command'
|
||||
}
|
||||
|
||||
_autostart_manage_log () {
|
||||
journalctl --user -fu "autostart@$1.service"
|
||||
}
|
||||
|
||||
_autostart_manage_sync () {
|
||||
rm "$HOME/.config/systemd/user/autostart.target.wants/"*
|
||||
|
||||
autostart_units=()
|
||||
while IFS='' read -r line
|
||||
do
|
||||
autostart_units+=("$line")
|
||||
done < <(_list)
|
||||
|
||||
for unit in "${autostart_units[@]}"
|
||||
do
|
||||
_systemctl "$unit" add-wants autostart.target
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
_get_autostart_cmd () {
|
||||
_query_autostart_toml 'select((.key == "'"$1"'") or (.value.alias == "'"$1"'")) | .value.command'
|
||||
}
|
||||
|
||||
_get_autostart_delay () {
|
||||
_query_autostart_toml 'select((.key == "'"$1"'") or (.value.alias == "'"$1"'")) | .value.delay // 0'
|
||||
}
|
||||
|
||||
_autostart_manage_exec () {
|
||||
cmd=$(_get_autostart_cmd "$1")
|
||||
sleep "$(_get_autostart_delay "$1")"
|
||||
bash -c "$cmd"
|
||||
}
|
||||
|
||||
_autostart_run_graphical () {
|
||||
pass x # Try to unlock yubikey asap
|
||||
|
||||
start-audio pipewire
|
||||
wait-for-service "network-online.target"
|
||||
|
||||
# Execute only if not already running
|
||||
# Don't match keepassxc-proxy
|
||||
if ! (pgrep -l keepassxc | grep -v prox) >/dev/null
|
||||
then
|
||||
if pass x
|
||||
then
|
||||
(pass keepass | head -n 1 | keepassxc --pw-stdin ~/sync/passwords.kdbx) &
|
||||
fi
|
||||
fi
|
||||
|
||||
autoinstall graphical
|
||||
autostart-manage run
|
||||
|
||||
}
|
||||
|
||||
_autostart_run_wayland () {
|
||||
_autostart_run_graphical
|
||||
|
||||
killall -SIGUSR2 waybar
|
||||
}
|
||||
|
||||
_autostart_run_xorg () {
|
||||
|
||||
feh --bg-fill "$XDG_PICTURES_DIR/wallpaper/active_wallpaper"
|
||||
|
||||
"$HOME/.config/polybar/launch.sh" &
|
||||
"$HOME/.config/bspwm/focus-voip.py" &
|
||||
|
||||
numlockx on
|
||||
xsetroot -cursor_name left_ptr
|
||||
xrdb "$HOME/.Xresources"
|
||||
|
||||
_autostart_run_graphical
|
||||
}
|
||||
|
||||
case $1 in
|
||||
list) _autostart_manage_list ;;
|
||||
info) _autostart_manage_info ;;
|
||||
sync) _autostart_manage_sync ;;
|
||||
enable) _systemctl "$2" add-wants autostart.target ;;
|
||||
disable) _systemctl "$2" disable ;;
|
||||
restart) _systemctl "${2:-*}" restart;;
|
||||
log) _autostart_manage_log "$2";;
|
||||
start) _systemctl "${2:-*}" start;;
|
||||
status) _systemctl "${2:-*}" status ;;
|
||||
stop) _systemctl "${2:-*}" stop ;;
|
||||
run) systemctl --user start autostart.target ;;
|
||||
run-xorg) _autostart_run_xorg ;;
|
||||
run-wayland) _autostart_run_wayland ;;
|
||||
exec) _autostart_manage_exec "$2" ;;
|
||||
*) echo "'$1' is not valid" ;;
|
||||
esac
|
|
@ -4,12 +4,6 @@ base_path="$HOME/.cache/remote-sources"
|
|||
file_path="$base_path/$2"
|
||||
|
||||
autoinstall file "$1" "$file_path"
|
||||
mkdir -p "$base_path"
|
||||
if [ ! -f "$file_path" ]
|
||||
then
|
||||
echo "Installing file $2"
|
||||
curl -fsSL -o "$file_path" "$1"
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC1090
|
||||
. "$file_path"
|
||||
|
|
83
.config/autoinstall.toml
Normal file
83
.config/autoinstall.toml
Normal file
|
@ -0,0 +1,83 @@
|
|||
[[autoinstall]]
|
||||
type = "file"
|
||||
source = "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim"
|
||||
target = "$HOME/.config/vim/autoload/plug.vim"
|
||||
hook = '[ -x "$(command -v vim)" ] && yes | vim +"PlugInstall --sync" +qa --not-a-term'
|
||||
group = "base"
|
||||
|
||||
[[autoinstall]]
|
||||
type = "git"
|
||||
source = "https://github.com/wbthomason/packer.nvim"
|
||||
target = "$HOME/.local/share/nvim/site/pack/packer/start/packer.nvim"
|
||||
hook = '[ -x "$(command -v nvim)" ] && nvim --headless -c "autocmd User PackerComplete quitall" -c "PackerSync"'
|
||||
group = "base"
|
||||
|
||||
[[autoinstall]]
|
||||
type = "exe"
|
||||
source = "https://github.com/starship/starship/releases/download/v1.17.1/starship-x86_64-unknown-linux-gnu.tar.gz"
|
||||
target = "startship"
|
||||
pipe = "tar xzO"
|
||||
group = "base"
|
||||
|
||||
[[autoinstall]]
|
||||
type = "exe"
|
||||
source = "https://raw.githubusercontent.com/qw3rtman/git-fire/master/git-fire"
|
||||
target = "git-fire"
|
||||
group = "base"
|
||||
|
||||
[[autoinstall]]
|
||||
type = "exe"
|
||||
source = "https://github.com/TheLocehiliosan/yadm/raw/master/yadm"
|
||||
target = "yadm"
|
||||
group = "base"
|
||||
|
||||
[[autoinstall]]
|
||||
type = "exe"
|
||||
source = "https://github.com/eza-community/eza/releases/download/v0.17.0/eza_x86_64-unknown-linux-gnu.tar.gz"
|
||||
target = "eza"
|
||||
pipe = "tar xzO"
|
||||
group = "base"
|
||||
|
||||
[[autoinstall]]
|
||||
type = "file"
|
||||
source = "https://raw.githubusercontent.com/dracula/alacritty/master/dracula.toml"
|
||||
target = "$HOME/.config/alacritty/dracula.toml"
|
||||
group = "graphical"
|
||||
|
||||
[[autoinstall]]
|
||||
type = "file"
|
||||
source = "https://raw.githubusercontent.com/dracula/duckduckgo/master/monkeyscript.user.js"
|
||||
target = "$HOME/.local/share/qutebrowser/greasemonkey/ddg-dracula.user.js"
|
||||
group = "graphical"
|
||||
|
||||
[[autoinstall]]
|
||||
type = "git"
|
||||
source = "https://github.com/dracula/qutebrowser.git"
|
||||
target = "$HOME/.config/qutebrowser/dracula"
|
||||
group = "graphical"
|
||||
|
||||
[[autoinstall]]
|
||||
type = "git"
|
||||
source = "https://github.com/dracula/gtk.git"
|
||||
target = "$HOME/.themes/Dracula"
|
||||
group = "graphical"
|
||||
|
||||
[[autoinstall]]
|
||||
type = "file"
|
||||
source = "https://github.com/dracula/gtk/releases/download/v3.0/Dracula-cursors.tar.xz"
|
||||
target = "$HOME/.icons/Dracula-cursors"
|
||||
pipe = "tar xJ"
|
||||
group = "graphical"
|
||||
|
||||
[[autoinstall]]
|
||||
type = "exe"
|
||||
source = "$(curl -fsSL 'https://data.services.jetbrains.com/products?code=TBA&release.type=release&fields=releases' | jq -r '.[0].releases[0].downloads.linux.link')"
|
||||
target = "jetbrains-toolbox"
|
||||
pipe = "tar xzO"
|
||||
group = "graphical"
|
||||
|
||||
[[autoinstall]]
|
||||
type = "text"
|
||||
source = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCkmWZmum4cVeDy5+9N1HdUzfnjEHSJ900ucD8F0wAy4MV1cdPYnZ4u5PFv5XMfmvA9SJ+VFsr0lhYlr+GQBG9aCCAdMJVVmEz3SccT6dp6ZYywT158RNshzfCe9ylWKK80+W7XnDXhdkec7aK+BQn5wOER3A3mUqRR0JDXWga9jyakH1K6OwXmQOO419bJWs2uCT1ZEgndHxKJEt2pEvoSz7z8p1SS2zyro+R3YtvL9WiDo3+0yPFYficNDr7s39yF5IJE+KTqAlCn5R2+kJ54lRmzB8oNS2jGwK2Q6wtph4AmfnlJTMODG2U2RjUltH2MIDXIYe2epATWL8qhkI4LTr38C7QR3DeJQsel/yTWdYqGakvU6Ge/xkbsaWOrSDTV3bPgKHzlL+dIKaGpV+5usZN4fpOLOb/nmYy3ekLpobzxza7rBRT2CxXS72DoPFaRE1ye7SxhcsLBNwre9YQFE4VvUZwJYkWz2V7eqGrk8VYnmQmT/bnUnMnVwMpeDc7pFKAFndIUxifoOj77c98Tdy3ncdS7SOd7+zRbLG+7k0UU1k89o1+tfREAddUJYR4RvB6g0kCyjpwOf1Pt4zhJR3y/zpsCCc5UnzK9X2kEo/8TSyvTr+GBiFVp5yLYgwCPJSNna33YX7+c3oLRM1QGgtqZk9qnGX9hgP8qpF8Akw== openpgp:0xAB920993"
|
||||
target = "$HOME/.ssh/authorized_keys"
|
||||
group = "ssh"
|
|
@ -28,18 +28,23 @@ _dott_completions()
|
|||
compgen -f "${COMP_WORDS[2]}"
|
||||
fi
|
||||
}
|
||||
complete -o filenames -F _dott_completions ".t"
|
||||
complete -F _dott_completions ".t"
|
||||
|
||||
_autostart_manage_completions()
|
||||
{
|
||||
if [ "${#COMP_WORDS[@]}" == "2" ]; then
|
||||
return
|
||||
fi
|
||||
#_autostart_manage_completions()
|
||||
#{
|
||||
# if [ "${#COMP_WORDS[@]}" == "2" ]; then
|
||||
# return
|
||||
# fi
|
||||
#
|
||||
# COMPREPLY=()
|
||||
# while IFS='' read -r line
|
||||
# do
|
||||
# COMPREPLY+=("$line")
|
||||
# done < <(compgen -W "$(autostart-manage list)" "${COMP_WORDS[1]}")
|
||||
#}
|
||||
#complete -F _autostart_manage_completions "autostart-manage"
|
||||
|
||||
COMPREPLY=()
|
||||
while IFS='' read -r line
|
||||
do
|
||||
COMPREPLY+=("$line")
|
||||
done < <(compgen -W "$(autostart-manage list)" "${COMP_WORDS[1]}")
|
||||
}
|
||||
complete -F _autostart_manage_completions "autostart-manage"
|
||||
for additional_completions in "$XDG_CONFIG_HOME/completionsrc.d/"*; do
|
||||
# shellcheck disable=1090
|
||||
. "$additional_completions"
|
||||
done
|
||||
|
|
|
@ -9,6 +9,7 @@ set +a
|
|||
|
||||
export AUTOSTART_DISPLAY=''
|
||||
|
||||
export BASH_COMPLETION_USER_DIR="$XDG_DATA_HOME"
|
||||
export BEMENU_OPTS="--tb '#6272a4'\
|
||||
--tf '#f8f8f2'\
|
||||
--fb '#282a36'\
|
||||
|
|
Loading…
Reference in a new issue