mbxutils/bin/mbxinit

66 lines
2.0 KiB
Plaintext
Raw Normal View History

2021-10-20 18:17:15 +02:00
#!/bin/bash
# mbxinit - initialize/update config files needed by mbxutils
2021-10-21 01:14:20 +02:00
# TODO check for GUI package managers
# TODO generate favorites here
2021-10-25 00:33:00 +02:00
# TODO check available icons: Papirus, Numix-Square, Numix-Circle, BeautyLine, Sardi
2021-10-20 18:17:15 +02:00
CNF_DIR="$HOME/.config/mbxutils"
CNF_FILE="$CNF_DIR/mbx.conf"
[ ! -d "$CNF_DIR" ] && mkdir -p "$CNF_DIR" && cp -r /usr/share/mbxutils/* "$CNF_DIR"/
mkdir -p "$CNF_DIR"/inc
check_fonts() {
2021-10-21 18:15:31 +02:00
search_fonts=(Ubuntu "Noto Sans" "Noto Sans Light" "DejaVu Serif" "Autour One" "JetBrains Mono" "Droid Sans" Roboto Helvetica Cantarell)
2021-10-20 18:17:15 +02:00
while read -r x
do
if ( dlm=$'\x1F' ; IFS="$dlm" ; [[ "$dlm${search_fonts[*]}$dlm" == *"$dlm${x}$dlm"* ]] ) ; then
fonts+=("${x}")
fi
done < <(fc-list| cut -d: -f2|cut -d, -f1,2 |tr , '\n'|sort|uniq)
printf '%s\n' "${fonts[@]}" > "$CNF_DIR"/inc/fonts.inc
2021-10-21 18:15:31 +02:00
mbx setvar "font=\'${fonts[0]}\'"
2021-10-20 18:17:15 +02:00
}
check_terminals() {
2021-10-21 01:14:20 +02:00
search_terminals=(terminator lxterminal xfce4-terminal alacritty gnome-terminal konsole qterminal )
2021-10-20 18:17:15 +02:00
for i in "${search_terminals[@]}"
do
if hash ${i} 2>/dev/null; then
terminals+=("${i}")
fi
done
printf '%s\n' "${terminals[@]}" > "$CNF_DIR"/inc/terminals.inc
2021-10-21 01:14:20 +02:00
mbx setvar terminal=${terminals[0]}
2021-10-20 18:17:15 +02:00
}
check_browsers() {
2021-10-21 18:15:31 +02:00
search_browsers=(firefox chromium vivaldi opera brave midori qutebrowser falkon)
2021-10-20 18:17:15 +02:00
for i in "${search_browsers[@]}"
do
if hash ${i} 2>/dev/null; then
browsers+=("${i}")
fi
done
printf '%s\n' "${browsers[@]}" > "$CNF_DIR"/inc/browsers.inc
2021-10-21 18:15:31 +02:00
mbx setvar wwwbrowser=${browsers[0]}
2021-10-20 18:17:15 +02:00
}
check_file_managers() {
2021-10-21 01:14:20 +02:00
search_file_managers=(xdg-open pcmanfm thunar pcmanfm-qt caja nautilus dolphin)
2021-10-20 18:17:15 +02:00
for i in "${search_file_managers[@]}"
do
if hash ${i} 2>/dev/null; then
file_managers+=("${i}")
fi
done
printf '%s\n' "${file_managers[@]}" > "$CNF_DIR"/inc/file_managers.inc
2021-10-21 01:14:20 +02:00
mbx setvar filemanager=${file_managers[0]}
2021-10-20 18:17:15 +02:00
}
check_fonts
check_terminals
check_browsers
check_file_managers