switch to flatpak zen browser
This commit is contained in:
@@ -1,95 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source $HOME/dotfiles/bin/helpers/functions.sh
|
||||
|
||||
install_font() {
|
||||
font_url="$1"
|
||||
font_name="$2"
|
||||
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
font_dir="$HOME/Library/Fonts"
|
||||
else
|
||||
font_dir="$HOME/.local/share/fonts"
|
||||
fi
|
||||
|
||||
mkdir -p $font_dir
|
||||
|
||||
# Check if any font files with the base name exist in the target directory
|
||||
found=$(find "$font_dir" -name "${font_name}*.ttf" | wc -l)
|
||||
if [ $found -gt 0 ]; then
|
||||
printfe "%s\n" "green" " - $font_name is already installed"
|
||||
else
|
||||
printfe "%s" "yellow" " - Downloading $font_name..."
|
||||
echo -en "\r"
|
||||
|
||||
result=$(curl -s -L -w "%{http_code}" -o /tmp/$font_name.zip $font_url)
|
||||
if [ $? -ne 0 ] || [ "$result" -ne "200" ]; then
|
||||
printfe "%s\n" "red" " - Failed to download $font_name"
|
||||
printfe "%s\n" "red" " HTTP status code: $result"
|
||||
return 1
|
||||
fi
|
||||
|
||||
printfe "%s" "yellow" " - Unzipping $font_name..."
|
||||
echo -en "\r"
|
||||
|
||||
result=$(unzip -o /tmp/$font_name.zip -d /tmp/$font_name 2>&1)
|
||||
if [ $? -ne 0 ]; then
|
||||
printfe "%s\n" "red" " - Failed to unzip $font_name"
|
||||
printfe "%s\n" "red" " Error: $result"
|
||||
return 1
|
||||
fi
|
||||
|
||||
printfe "%s\n" "yellow" " - Moving $font_name to $font_dir..."
|
||||
mv /tmp/$font_name/*.ttf $font_dir &> /dev/null
|
||||
|
||||
# Clear font cache
|
||||
if [[ "$OSTYPE" != "darwin"* ]]; then
|
||||
fc-cache -fv $font_dir &> /dev/null
|
||||
fi
|
||||
|
||||
printfe "%s\n" "green" " - $font_name has been installed"
|
||||
fi
|
||||
}
|
||||
|
||||
ensure_fonts_installed() {
|
||||
# Load fonts from cat $DOTFILES_CONFIG | shyaml keys config.fonts
|
||||
fonts=($(cat $DOTFILES_CONFIG | shyaml keys config.fonts))
|
||||
|
||||
for font in "${fonts[@]}"; do
|
||||
name=$(cat $DOTFILES_CONFIG | shyaml get-value config.fonts.$font.name)
|
||||
url=$(cat $DOTFILES_CONFIG | shyaml get-value config.fonts.$font.url)
|
||||
install_font $url $name
|
||||
done
|
||||
}
|
||||
|
||||
print_fonts_status() {
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
font_dir="$HOME/Library/Fonts"
|
||||
else
|
||||
font_dir="$HOME/.local/share/fonts"
|
||||
fi
|
||||
|
||||
mkdir -p $font_dir
|
||||
|
||||
fonts=($(cat $DOTFILES_CONFIG | shyaml keys config.fonts))
|
||||
total_fonts=0
|
||||
installed_fonts=0
|
||||
|
||||
for font in "${fonts[@]}"; do
|
||||
font_name=$(echo $font | awk '{print $2}')
|
||||
((total_fonts++))
|
||||
|
||||
found=$(find "$font_dir" -name "${font_name}*.ttf" | wc -l)
|
||||
if [ "$found" -gt 0 ]; then
|
||||
((installed_fonts++))
|
||||
fi
|
||||
done
|
||||
|
||||
printfe "%s" "cyan" "NerdFonts:"
|
||||
if [ "$installed_fonts" -eq "$total_fonts" ]; then
|
||||
printfe "%s" "green" " $installed_fonts/$total_fonts "
|
||||
else
|
||||
printfe "%s" "red" " $installed_fonts/$total_fonts "
|
||||
fi
|
||||
printfe "%s\n" "cyan" "fonts installed"
|
||||
}
|
@@ -1,74 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source $HOME/dotfiles/bin/helpers/functions.sh
|
||||
|
||||
ensure_gnome_extensions_installed() {
|
||||
if is_wsl; then
|
||||
printfe "%s\n" "yellow" "Running in WSL, skipping GNOME extensions."
|
||||
return
|
||||
fi
|
||||
|
||||
# In case gnome-extensions is installed but we don't use GNOME let's do a check
|
||||
if [ "$XDG_CURRENT_DESKTOP" != "GNOME" ]; then
|
||||
printfe "%s\n" "red" " - XDG_CURRENT_DESKTOP is not GNOME, likely not running GNOME."
|
||||
return
|
||||
fi
|
||||
|
||||
# Attempt to connect to GNOME shell, if it fails, we can stop here
|
||||
if ! gnome-extensions &> /dev/null; then
|
||||
printfe "%s\n" "red" " - gnome-extensions command not found, likely not running GNOME?!"
|
||||
return
|
||||
fi
|
||||
|
||||
printfe "%s" "cyan" " - Loading GNOME extension json file..."
|
||||
echo -en '\r'
|
||||
|
||||
if [ ! -f ~/dotfiles/gnome/extensions.json ]; then
|
||||
printfe "%s\n" "red" " - No GNOME extensions file found."
|
||||
return
|
||||
fi
|
||||
|
||||
extensions=$(cat ~/dotfiles/gnome/extensions.json)
|
||||
gnome_extensions=($(echo $extensions | jq -r '.[]'))
|
||||
|
||||
for i in "${gnome_extensions[@]}";
|
||||
do
|
||||
printfe "%s" "cyan" " - Fetching extension details for $(echo $i | grep -oP 'extension/\K[^/]+')"
|
||||
echo -en '\r'
|
||||
|
||||
# Check if extension_id is already installed
|
||||
if gnome-extensions list | grep --quiet ${i}; then
|
||||
printfe "%s\n" "green" " - Extension $i is already installed."
|
||||
continue
|
||||
fi
|
||||
|
||||
printfe "%s" "cyan" " - Installing $i..."
|
||||
echo -en '\r'
|
||||
|
||||
result=$(gext install $i 2>&1)
|
||||
if [ $? -ne 0 ]; then
|
||||
printfe "%s\n" "red" " - Failed to install $i"
|
||||
printfe "%s\n" "red" " $result"
|
||||
continue
|
||||
fi
|
||||
|
||||
if echo $result | grep --quiet "Cannot find extension"; then
|
||||
printfe "%s\n" "red" " - Failed to install $i, extension not found."
|
||||
continue
|
||||
fi
|
||||
|
||||
printfe "%s\n" "green" " - Extension $i has been installed."
|
||||
done
|
||||
}
|
||||
|
||||
# Export a JSON file with all installed GNOME extensions IDs
|
||||
export_gnome_extensions() {
|
||||
# Only export if we have the gnome-extensions command
|
||||
if ! command -v gnome-extensions &> /dev/null; then
|
||||
printfe "%s\n" "red" " - gnome-extensions command not found, likely not running GNOME."
|
||||
return
|
||||
fi
|
||||
|
||||
extensions=$(gnome-extensions list --enabled --user)
|
||||
echo $extensions | jq -R -s -c 'split("\n")[:-1]' > ~/dotfiles/gnome/extensions.json
|
||||
}
|
Reference in New Issue
Block a user