Improve autoinstall and other scripts

This commit is contained in:
Tobias Reisinger 2022-12-20 01:09:47 +01:00
parent cf6ef78b67
commit 26d81c5c5e
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
3 changed files with 26 additions and 4 deletions

View file

@ -10,6 +10,7 @@ declare -A mapper=(
["environment.local"]="$HOME/.config/environment.local" ["environment.local"]="$HOME/.config/environment.local"
["git"]="$HOME/.config/git/config" ["git"]="$HOME/.config/git/config"
["git-ignore"]="$HOME/.config/git/ignore" ["git-ignore"]="$HOME/.config/git/ignore"
["home-manager"]="$HOME/.config/nixpkgs/home.nix"
["qutebrowser"]="$HOME/.config/qutebrowser/common.py" ["qutebrowser"]="$HOME/.config/qutebrowser/common.py"
["starship"]="$HOME/.config/starship.toml" ["starship"]="$HOME/.config/starship.toml"
["sxhkd"]="$HOME/.config/sxhkd/sxhkdrc" ["sxhkd"]="$HOME/.config/sxhkd/sxhkdrc"

View file

@ -28,6 +28,8 @@ _autoinstall_base () {
_autoinstall_file \ _autoinstall_file \
"https://raw.githubusercontent.com/qw3rtman/git-fire/master/git-fire" \ "https://raw.githubusercontent.com/qw3rtman/git-fire/master/git-fire" \
"$HOME/.local/bin/git-fire" "$HOME/.local/bin/git-fire"
return 0
} }
_autoinstall_graphical () { _autoinstall_graphical () {
@ -50,11 +52,21 @@ _autoinstall_graphical () {
_autoinstall_archive \ _autoinstall_archive \
"https://github.com/dracula/gtk/releases/download/v3.0/Dracula-cursors.tar.xz" \ "https://github.com/dracula/gtk/releases/download/v3.0/Dracula-cursors.tar.xz" \
"$HOME/.icons/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_all () { _autoinstall_all () {
_autoinstall_base _autoinstall_base
_autoinstall_graphical _autoinstall_graphical
return 0
} }
_autoinstall_git () { _autoinstall_git () {
@ -63,7 +75,9 @@ _autoinstall_git () {
echo "Installing repo $1 to $2" echo "Installing repo $1 to $2"
mkdir -p "$2" mkdir -p "$2"
git clone "$1" "$2" >/dev/null 2>&1 git clone "$1" "$2" >/dev/null 2>&1
return 0
fi fi
return 1
} }
_autoinstall_file () { _autoinstall_file () {
@ -74,7 +88,9 @@ _autoinstall_file () {
mkdir -p "$file_path" mkdir -p "$file_path"
cd "$file_path" || exit cd "$file_path" || exit
curl -fsSLo "$2" "$1" curl -fsSLo "$2" "$1"
return 0
fi fi
return 1
} }
_autoinstall_archive () { _autoinstall_archive () {
@ -86,17 +102,22 @@ _autoinstall_archive () {
cd "$file_path" || exit cd "$file_path" || exit
curl -fsSLo "$2" "$1" curl -fsSLo "$2" "$1"
tar xaf "$2" tar xaf "$2"
return 0
fi fi
return 1
} }
_autoinstall_env () { _autoinstall_env () {
if [ -x "$(command -v envsubst)" ] if [ -x "$(command -v envsubst)" ]
then then
envsubst < "$1.tpl" > "$1" envsubst < "$1.tpl" > "$1"
return 0
fi fi
return 1
} }
case $1 in action="${1:-base}"
case $action in
all) _autoinstall_all ;; all) _autoinstall_all ;;
base) _autoinstall_base ;; base) _autoinstall_base ;;
graphical) _autoinstall_graphical ;; graphical) _autoinstall_graphical ;;
@ -104,5 +125,5 @@ case $1 in
file) _autoinstall_file "$2" "$3" ;; file) _autoinstall_file "$2" "$3" ;;
archive) _autoinstall_archive "$2" "$3" ;; archive) _autoinstall_archive "$2" "$3" ;;
env) _autoinstall_env "$2" ;; env) _autoinstall_env "$2" ;;
*) echo "'$1' is not valid" ;; *) echo "'$action' is not a valid action." ;;
esac esac

View file

@ -32,13 +32,13 @@ main()
if [ -n "$1" ] && [ -e "$1" ] if [ -n "$1" ] && [ -e "$1" ]
then then
convert "$1" "$path" convert "$1" "$path"
clip_image "$path"
upload_image "$path" upload_image "$path"
clip_image "$path"
else else
if [ "$(flameshot gui -r | tee $path | wc -c)" -gt 0 ] if [ "$(flameshot gui -r | tee $path | wc -c)" -gt 0 ]
then then
clip_image "$path"
upload_image "$path" upload_image "$path"
clip_image "$path"
fi fi
fi fi
} }