refactor config

This commit is contained in:
Alexander Navarro 2023-02-13 01:53:52 -03:00
commit 4f0e213f4a
155 changed files with 13983 additions and 0 deletions

12
scripts/check-dependencies Executable file
View file

@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -Eeuo pipefail
# Return 1 if any of the arguments is missing
for dep in "$@"; do
if ! (command -v "$dep" &>/dev/null || systemctl -q list-unit-files "${dep}.service" &>/dev/null); then
echo -e "${dep} not found!"
exit 1
fi
done

61
scripts/check-tools Normal file
View file

@ -0,0 +1,61 @@
#!/usr/bin/env bash
source "${DOOTS}/config/zsh/functions/colors.zsh"
define_colors
# r̶u̶s̶t̶ linux cli/tui tools and apps that i use
# ( -v" "-v" "-V" "-V" "-V" "-v" "--version" "--version" "-V" "-V" "-v" "-V" "-V" "--version")
declare -A tools
tools=(
[alacritty]=" --version"
[atuin]="󰳗 --version"
[bat]="󰭟 --version"
[broot]="פּ --version"
[btop]=" --version"
[chafa]="󰈟 --version"
[cowsay]=" --version"
[cava]="󰺢 -v"
[delta]=" --version"
[dust]=" --version"
[exa]=" --version"
[fd]=" --version"
[foot]=" --version"
[fuck]="󰚌 --version"
[fzf]=" --version"
[git]=" --version"
[kitty]=" --version"
[librewolf]=" --version"
[lsd]=" --version"
[mpv]=" --version"
[pipes.sh]="ﳣ --version"
[neofetch]=" --version"
[nvim]=" --version"
[rg]=" --version"
[starship]="󱓞 --version"
[tldr]=" --version"
[tmux]=" -V"
[zsh]=" --version"
)
mapfile -t sorted_tools < <(echo "${!tools[@]}" | tr ' ' '\n' | sort)
printf "${BLD}%-18s %-10s %-10s\n" "Tools" "Status" "Version"
printf "%s\n${RST}" "-----------------------------------------------"
for tool in "${sorted_tools[@]}"; do
IFS=' ' read -r -a tool_data <<< "${tools[$tool]}"
if command -v "$tool" &> /dev/null; then
version=$("$tool" "${tool_data[1]}" 2> /dev/null | awk '{
for (i = 1; i <= NF; i++) {
if ($i ~ /[0-9]+.[0-9]+([.][0-9]+)?/) {
print $i;
exit;
}
}
}')
printf "${BLU}${tool_data[0]}${RST}${BLD} %-18s ${GRN}%-10s ${RST}${YLW}%-10s\n${RST}" \
"$tool" "" "$version"
else
printf "${CYN}${tool_data[0]}${RST}${BLD} %-18s ${RED}%-10s ${BLK}%-10s\n${RST}" \
"$tool" "" "command not found"
fi
done

44
scripts/download-mega-extract Executable file
View file

@ -0,0 +1,44 @@
#!/usr/bin/env bash
format=$1
shift
path=$1
shift
link=$1
shift
check-dependencies megatools zenity unzip
if [[ -z $link ]]; then
echo "A link from mega is required"
exit 1
fi
if [[ -z $path ]]; then
path="$(zenity --file-selection --directory)"
fi
if [[ -z $path ]]; then
path="$(zenity --file-selection --directory)"
fi
extract_zip() {
file_path="$path/$file"
unzip -q -d "$path" "$file_path"
rm "$file_path"
}
echo "Downloading file..."
file="$(megatools dl --no-progress --print-names --path "$path" "$link")"
case "$format" in
zip)
extract_zip "$file"
;;
*)
echo default
;;
esac
echo "Done!"

66
scripts/set-random-wallpaper Executable file
View file

@ -0,0 +1,66 @@
#!/usr/bin/env bash
# Original script steal from (specific commit):
# https://github.com/lime-desu/dootsfile/blob/58abca63dfd596d4812fcf95567cc3ad63ffbb6f/scripts/set-random-wallpaper.sh
WALLPAPER_DIR=${HOME}/Drives/Stuff/Pictures/Waifus
WALLPAPER_PREFIX="Fondos_PC.*"
RANDOM_PICTURE=$(fd -apt f "$WALLPAPER_PREFIX" "$WALLPAPER_DIR" | shuf -n 1)
CURRENT_DESKTOP="$(echo "$XDG_CURRENT_DESKTOP" | awk '{for (i=1;i<=NF;i++) { $i=toupper(substr($i,1,1)) tolower(substr($i,2)) }}1')"
case "$CURRENT_DESKTOP" in
Gnome)
gsettings set org.gnome.desktop.background picture-uri "file://$RANDOM_PICTURE"
gsettings set org.gnome.desktop.background picture-uri-dark "file://$RANDOM_PICTURE"
;;
Xfce)
backdrop=$(xfconf-query --channel xfce4-desktop --property /backdrop --list | grep -E -e "screen.*/monitor.*image-path$" -e "screen.*/monitor.*/last-image$")
for i in ${backdrop}; do
xfconf-query --channel xfce4-desktop --property "$i" --create --type string --set "$RANDOM_PICTURE"
xfconf-query --channel xfce4-desktop --property "$i" --set "$RANDOM_PICTURE"
done
;;
KDE)
export DISPLAY=:0
kwriteconfig5 --file kdeglobals --group Wallpaper --key Picture "$RANDOM_PICTURE"
qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript '
var allDesktops = desktops();
print (allDesktops);
for (i=0;i<allDesktops.length;i++) {{
d = allDesktops[i];
d.wallpaperPlugin = "org.kde.image";
d.currentConfigGroup = Array("Wallpaper","org.kde.image","General");
d.writeConfig("Image", "file:///'$RANDOM_PICTURE'")
}}
'
;;
Sway)
MODES=(
[bg - center]=center
[bg - fill]=fill
[bg - max]=fit
[bg - scale]=stretch
[bg - tile]=tile
)
# default to fill if there's no bgtypes
BGTYPE=${BGTYPE:fill}
MODE=${MODES[$BGTYPE]}
swaymsg output "*" bg "$WALLPAPER" "$MODE"
;;
i3)
if command -v feh >/dev/null; then
feh --bg-scale "$RANDOM_PICTURE"
elif command -v nitrogen >/dev/null; then
nitrogen --set-scaled "$RANDOM_PICTURE"
fi
;;
*)
notify-send "Error: $(basename "$0")" "This script does not support $CURRENT_DESKTOP."
exit 1
;;
esac
if [[ "$CURRENT_DESKTOP" =~ ^(Gnome|Xfce|KDE|Sway|i3)$ ]]; then
display_path="$(echo "$RANDOM_PICTURE" | awk -F '/' '{print "(...)/"$(NF-1)"/"$NF}')"
notify-send 'Wallpaper changed:' "$display_path"
fi