Use consistent bash5 style for conditionals and quoting

This commit is contained in:
David Heinemeier Hansson
2026-02-21 10:18:47 +01:00
parent d2acf3b6ba
commit 7514ae7dcf
113 changed files with 289 additions and 287 deletions
+2 -2
View File
@@ -4,13 +4,13 @@ if omarchy-cmd-missing uwsm; then
sudo rm -f /etc/systemd/system/getty@tty1.service.d/override.conf
sudo rmdir /etc/systemd/system/getty@tty1.service.d/ 2>/dev/null || true
if [ -f "$HOME/.bash_profile" ]; then
if [[ -f $HOME/.bash_profile ]]; then
# Remove the specific line
sed -i '/^\[\[ -z \$DISPLAY && \$(tty) == \/dev\/tty1 \]\] && exec Hyprland$/d' "$HOME/.bash_profile"
echo "Cleaned up .bash_profile"
fi
if [ -f "$HOME/.config/environment.d/fcitx.conf" ]; then
if [[ -f $HOME/.config/environment.d/fcitx.conf ]]; then
echo "Removing GTK_IM_MODULE from fcitx config for Wayland..."
sed -i 's/^GTK_IM_MODULE=fcitx$//' "$HOME/.config/environment.d/fcitx.conf"
fi
+1 -1
View File
@@ -1,6 +1,6 @@
echo "Set a default fontconfig"
if [[ ! -f "$HOME/.config/fontconfig/fonts.conf" ]]; then
if [[ ! -f $HOME/.config/fontconfig/fonts.conf ]]; then
mkdir -p ~/.config/fontconfig
cp ~/.local/share/omarchy/config/fontconfig/fonts.conf ~/.config/fontconfig/
fc-cache -fv
+3 -3
View File
@@ -1,7 +1,7 @@
echo "Update polkit policy to yield to fingerprint and fido2"
# If fprint exists in polkit, it was wrong and needs reset
if [ -f /etc/pam.d/polkit-1 ] && grep -Fq 'pam_fprintd.so' /etc/pam.d/polkit-1; then
if [[ -f /etc/pam.d/polkit-1 ]] && grep -Fq 'pam_fprintd.so' /etc/pam.d/polkit-1; then
sudo tee /etc/pam.d/polkit-1 >/dev/null <<'EOF'
auth sufficient pam_fprintd.so
auth required pam_unix.so
@@ -13,9 +13,9 @@ EOF
fi
# If fido2 is in sudo, it won't be in polkit either way
if grep -q pam_u2f.so /etc/pam.d/sudo && [ -f /etc/pam.d/polkit-1 ] && ! grep -q 'pam_u2f.so' /etc/pam.d/polkit-1; then
if grep -q pam_u2f.so /etc/pam.d/sudo && [[ -f /etc/pam.d/polkit-1 ]] && ! grep -q 'pam_u2f.so' /etc/pam.d/polkit-1; then
sudo sed -i '1i auth sufficient pam_u2f.so cue authfile=/etc/fido2/fido2' /etc/pam.d/polkit-1
elif grep -q pam_u2f.so /etc/pam.d/sudo && [ ! -f /etc/pam.d/polkit-1 ]; then
elif grep -q pam_u2f.so /etc/pam.d/sudo && [[ ! -f /etc/pam.d/polkit-1 ]]; then
sudo tee /etc/pam.d/polkit-1 >/dev/null <<'EOF'
auth sufficient pam_u2f.so cue authfile=/etc/fido2/fido2
auth required pam_unix.so
+2 -2
View File
@@ -4,7 +4,7 @@ echo "Reset DNS configuration to DHCP (remove forced Cloudflare DNS)"
# This preserves local development environments (.local domains, etc.)
# Users can still opt-in to Cloudflare DNS using: omarchy-setup-dns cloudflare
if [ -f /etc/systemd/resolved.conf ]; then
if [[ -f /etc/systemd/resolved.conf ]]; then
# Backup current config with timestamp
backup_timestamp=$(date +"%Y%m%d%H%M%S")
sudo cp /etc/systemd/resolved.conf "/etc/systemd/resolved.conf.bak.${backup_timestamp}"
@@ -18,7 +18,7 @@ if [ -f /etc/systemd/resolved.conf ]; then
echo "FallbackDNS=" | sudo tee -a /etc/systemd/resolved.conf >/dev/null
# Remove any forced DNS config from systemd-networkd
if [ -f /etc/systemd/network/99-omarchy-dns.network ]; then
if [[ -f /etc/systemd/network/99-omarchy-dns.network ]]; then
sudo rm -f /etc/systemd/network/99-omarchy-dns.network
sudo systemctl restart systemd-networkd
fi
+2 -2
View File
@@ -5,7 +5,7 @@ for desktop_file in ~/.local/share/applications/*.desktop; do
if grep -q 'Exec=chromium --new-window --ozone-platform=wayland --app=' "$desktop_file"; then
url=$(grep '^Exec=' "$desktop_file" | sed -n 's/.*--app="\?\([^"]*\)"\?.*/\1/p')
if [[ -n "$url" ]]; then
if [[ -n $url ]]; then
sed -i "s|^Exec=.*|Exec=omarchy-launch-webapp \"$url\"|" "$desktop_file"
fi
fi
@@ -13,7 +13,7 @@ done
echo "Updating Hyprland bindings"
HYPR_BINDINGS_FILE="$HOME/.config/hypr/bindings.conf"
if [ -f "$HYPR_BINDINGS_FILE" ]; then
if [[ -f $HYPR_BINDINGS_FILE ]]; then
sed -i 's/\$browser =.*chromium.*$/\$browser = omarchy-launch-browser/' "$HYPR_BINDINGS_FILE"
sed -i 's/\$webapp="/omarchy-launch-webapp "/g' "$HYPR_BINDINGS_FILE"
sed -i '/^\$webapp = \$browser --app/d' "$HYPR_BINDINGS_FILE"
+1 -1
View File
@@ -1,6 +1,6 @@
echo "Removing UseDNS=no from network files to fix DNS issue"
for file in /etc/systemd/network/*.network; do
[[ -f "$file" ]] || continue
[[ -f $file ]] || continue
sudo sed -i '/^UseDNS=no/d' "$file"
done
+1 -1
View File
@@ -1,6 +1,6 @@
echo "Fix DHCP DNS to allow VPN DNS override"
if [ -f /etc/systemd/resolved.conf ]; then
if [[ -f /etc/systemd/resolved.conf ]]; then
if grep -q "^DNS=$" /etc/systemd/resolved.conf && grep -q "^FallbackDNS=$" /etc/systemd/resolved.conf; then
sudo sed -i '/^DNS=$/d; /^FallbackDNS=$/d' /etc/systemd/resolved.conf
sudo systemctl restart systemd-resolved
+1 -1
View File
@@ -28,7 +28,7 @@ for pkg in "${PACKAGES[@]}"; do
done
WALKER_MAJOR=$(walker -v 2>&1 | grep -oP '^\d+' || echo "0")
if [[ "$WALKER_MAJOR" -lt 2 ]]; then
if (( WALKER_MAJOR < 2 )); then
NEEDS_MIGRATION=true
fi
+1 -1
View File
@@ -9,7 +9,7 @@ VS_CODE_SETTINGS="$HOME/.config/Code/User/settings.json"
if omarchy-cmd-present code; then
mkdir -p "$(dirname "$VS_CODE_SETTINGS")"
if [[ ! -f "$VS_CODE_SETTINGS" ]]; then
if [[ ! -f $VS_CODE_SETTINGS ]]; then
# If settings.json doesn't exist, create it with just the update.mode setting
printf '{\n "update.mode": "none"\n}\n' > "$VS_CODE_SETTINGS"
elif ! grep -q '"update.mode"' "$VS_CODE_SETTINGS"; then
+2 -3
View File
@@ -5,13 +5,12 @@ ICON_DIR="$APP_DIR/icons"
# Don't use omarchy-tui-remove to preserve icons
if [[ -f "$APP_DIR/Docker.desktop" ]]; then
if [[ -f $APP_DIR/Docker.desktop ]]; then
rm "$APP_DIR/Docker.desktop"
omarchy-tui-install "Docker" "lazydocker" tile "$ICON_DIR/Docker.png"
fi
if [[ -f "$APP_DIR/Disk Usage.desktop" ]]; then
if [[ -f $APP_DIR/"Disk Usage.desktop" ]]; then
rm "$APP_DIR/Disk Usage.desktop"
omarchy-tui-install "Disk Usage" "bash -c 'dust -r; read -n 1 -s'" float "$ICON_DIR/Disk Usage.png"
fi
+1 -1
View File
@@ -15,7 +15,7 @@ if command -v limine &>/dev/null && [[ -f /etc/default/limine ]]; then
uki_file=$(find /boot/EFI/Linux/ -name "omarchy*.efi" -printf "%f\n" 2>/dev/null | head -1)
if [[ -n "$uki_file" ]]; then
if [[ -n $uki_file ]]; then
while IFS= read -r bootnum; do
sudo efibootmgr -b "$bootnum" -B >/dev/null 2>&1
done < <(efibootmgr | grep -E "^Boot[0-9]{4}\*? Omarchy" | sed 's/^Boot\([0-9]\{4\}\).*/\1/')
+1 -1
View File
@@ -1,6 +1,6 @@
echo "Add a default keyring for gnome-keyring that unlocks on login"
if [ -f "$HOME/.local/share/keyrings/Default_keyring.keyring" ] || [ -f "$HOME/.local/share/keyrings/default" ]; then
if [[ -f $HOME/.local/share/keyrings/Default_keyring.keyring ]] || [[ -f $HOME/.local/share/keyrings/default ]]; then
if gum confirm "Do you want to replace existing keyring with one that's auto-unlocked on login?"; then
bash "$OMARCHY_PATH/install/login/default-keyring.sh"
fi
+1 -1
View File
@@ -17,7 +17,7 @@ omarchy-pkg-add grim slurp wayfreeze-git
echo "Add nfs support by default to Nautilus"
omarchy-pkg-add gvfs-nfs
if [ ! -d "$HOME/.config/nvim" ]; then
if [[ ! -d $HOME/.config/nvim ]]; then
echo "Add missing nvim config"
omarchy-nvim-setup
fi
+1 -1
View File
@@ -2,6 +2,6 @@ echo "Ensure interactive shell check is at the top of .bashrc"
BASHRC="$HOME/.bashrc"
if [ -f "$BASHRC" ] && ! grep -q '\[\[ $- != \*i\* \]\] && return' "$BASHRC"; then
if [[ -f $BASHRC ]] && ! grep -q '\[\[ $- != \*i\* \]\] && return' "$BASHRC"; then
sed -i '1i# If not running interactively, don'\''t do anything (leave this at the top of this file)\n[[ $- != *i* ]] && return\n' "$BASHRC"
fi
+1 -1
View File
@@ -2,6 +2,6 @@ echo "Add right-click terminal action to waybar omarchy menu icon"
WAYBAR_CONFIG="$HOME/.config/waybar/config.jsonc"
if [[ -f "$WAYBAR_CONFIG" ]] && ! grep -A5 '"custom/omarchy"' "$WAYBAR_CONFIG" | grep -q '"on-click-right"'; then
if [[ -f $WAYBAR_CONFIG ]] && ! grep -A5 '"custom/omarchy"' "$WAYBAR_CONFIG" | grep -q '"on-click-right"'; then
sed -i '/"on-click": "omarchy-menu",/a\ "on-click-right": "omarchy-launch-terminal",' "$WAYBAR_CONFIG"
fi
+1 -1
View File
@@ -1,6 +1,6 @@
echo "Add default Ctrl+P binding for imv; backup existing config if present"
if [ -f ~/.config/imv/config ]; then
if [[ -f ~/.config/imv/config ]]; then
cp ~/.config/imv/config ~/.config/imv/config.bak.$(date +%s)
else
mkdir -p ~/.config/imv
+5 -5
View File
@@ -3,21 +3,21 @@ echo "Setting up xdg-terminal-exec for gtk-launch terminal support"
# https://github.com/basecamp/omarchy/issues/1852
# Remove old symlink if it exists -- if someone ran the previous migration early
if [ -L /usr/local/bin/xdg-terminal-exec ]; then
if [[ -L /usr/local/bin/xdg-terminal-exec ]]; then
sudo rm /usr/local/bin/xdg-terminal-exec
fi
omarchy-pkg-add xdg-terminal-exec
# Set up xdg-terminals.list based on current $TERMINAL
if [ -n "$TERMINAL" ]; then
if [[ -n $TERMINAL ]]; then
case "$TERMINAL" in
alacritty) desktop_id="Alacritty.desktop" ;;
ghostty) desktop_id="com.mitchellh.ghostty.desktop" ;;
kitty) desktop_id="kitty.desktop" ;;
esac
if [ -n "$desktop_id" ]; then
if [[ -n $desktop_id ]]; then
mkdir -p ~/.config
cat > ~/.config/xdg-terminals.list << EOF
# Terminal emulator preference order for xdg-terminal-exec
@@ -42,7 +42,7 @@ sed -i 's/export TERMINAL=.*/export TERMINAL=xdg-terminal-exec/' ~/.config/uwsm/
# Update waybar config to use xdg-terminal-exec
waybar_config=~/.config/waybar/config.jsonc
if [ -f "$waybar_config" ]; then
if [[ -f $waybar_config ]]; then
sed -i 's|"on-click-right": "omarchy-launch-terminal"|"on-click-right": "xdg-terminal-exec"|' "$waybar_config"
sed -i 's|"on-click": "\$TERMINAL -e btop"|"on-click": "xdg-terminal-exec btop"|' "$waybar_config"
sed -i 's|"on-click": "\$TERMINAL --class=Wiremix -e wiremix"|"on-click": "xdg-terminal-exec --app-id=com.omarchy.Wiremix -e wiremix"|' "$waybar_config"
@@ -51,7 +51,7 @@ fi
# Update hyprland window rules to use DNS-format class names
system_conf=~/.config/hypr/apps/system.conf
if [ -f "$system_conf" ]; then
if [[ -f $system_conf ]]; then
if grep -q 'class:(.*|Impala|' "$system_conf" || grep -q 'class:(.*|Wiremix|' "$system_conf" || grep -q '|Omarchy|' "$system_conf"; then
sed -i 's/\bImpala\b/com.omarchy.Impala/g; s/\bWiremix\b/com.omarchy.Wiremix/g; s/|Omarchy|/|com.omarchy.Omarchy|/g' "$system_conf"
fi
+1 -1
View File
@@ -1,7 +1,7 @@
echo "Remove alternative limine.conf files"
if omarchy-cmd-present limine; then
if [ ! -f /boot/limine.conf ]; then
if [[ ! -f /boot/limine.conf ]]; then
echo "Error: /boot/limine.conf does not exist. Do not reboot without resolving this issue!"
exit 1
fi
+1 -1
View File
@@ -2,7 +2,7 @@ echo "Update hyprlock font to match current system font"
font_name=$(omarchy-font-current)
if [[ -n "$font_name" ]]; then
if [[ -n $font_name ]]; then
cp ~/.config/hypr/hyprlock.conf ~/.config/hypr/hyprlock.conf.bak.$(date +%s)
echo "Found font '$font_name', updating hyprlock"
+1 -1
View File
@@ -1,7 +1,7 @@
echo "Add emergency entry for Walker"
CONFIG_FILE="$HOME/.config/walker/config.toml"
if [[ -f "$CONFIG_FILE" ]] && ! grep -q 'command = "omarchy-restart-walker"' "$CONFIG_FILE"; then
if [[ -f $CONFIG_FILE ]] && ! grep -q 'command = "omarchy-restart-walker"' "$CONFIG_FILE"; then
cat >> "$CONFIG_FILE" << 'EOF'
[[emergencies]]
+6 -6
View File
@@ -4,7 +4,7 @@ echo "Migrate to new theme setup"
OMARCHY_DIR="$HOME/.local/share/omarchy"
USER_BACKGROUNDS_DIR="$HOME/.config/omarchy/backgrounds"
if [[ -d "$OMARCHY_DIR/themes" ]]; then
if [[ -d $OMARCHY_DIR/themes ]]; then
cd "$OMARCHY_DIR"
# Get list of git-tracked background files (relative to omarchy dir)
@@ -15,21 +15,21 @@ if [[ -d "$OMARCHY_DIR/themes" ]]; then
theme_name=$(basename "$theme_dir")
backgrounds_dir="themes/$theme_name/backgrounds"
[[ -d "$backgrounds_dir" ]] || continue
[[ -d $backgrounds_dir ]] || continue
for bg_file in "$backgrounds_dir"/*; do
[[ -f "$bg_file" ]] || continue
[[ -f $bg_file ]] || continue
# Check if this file is tracked by git
is_tracked=false
for tracked in "${TRACKED_BACKGROUNDS[@]}"; do
if [[ "$tracked" == "$bg_file" ]]; then
if [[ $tracked == $bg_file ]]; then
is_tracked=true
break
fi
done
if [[ "$is_tracked" == "false" ]]; then
if [[ $is_tracked == "false" ]]; then
# This is a user-added background, move it to user config
user_theme_bg_dir="$USER_BACKGROUNDS_DIR/$theme_name"
mkdir -p "$user_theme_bg_dir"
@@ -49,7 +49,7 @@ if [[ -L $CURRENT_THEME_LINK ]]; then
CURRENT_THEME_NAME=$(basename "$(readlink "$CURRENT_THEME_LINK")")
elif [[ -d $CURRENT_THEME_LINK ]]; then
CURRENT_THEME_NAME=$(basename "$CURRENT_THEME_LINK")
elif [[ -f "$HOME/.config/omarchy/current/theme.name" ]]; then
elif [[ -f $HOME/.config/omarchy/current/theme.name ]]; then
CURRENT_THEME_NAME=$(cat "$HOME/.config/omarchy/current/theme.name")
fi
+1 -1
View File
@@ -6,7 +6,7 @@ NVIDIA="$(lspci | grep -i 'nvidia')"
if echo "$NVIDIA" | grep -qE "GTX (9[0-9]{2}|10[0-9]{2})|GT 10[0-9]{2}|Quadro [PM][0-9]{3,4}|Quadro GV100|MX *[0-9]+|Titan (X|Xp|V)|Tesla V100"; then
ENVS_CONF="$HOME/.config/hypr/envs.conf"
if [ -f "$ENVS_CONF" ]; then
if [[ -f $ENVS_CONF ]]; then
# Check if file contains problematic variables
if grep -qE "env = (NVD_BACKEND,direct|LIBVA_DRIVER_NAME,nvidia)" "$ENVS_CONF"; then
echo "Removing incompatible NVIDIA environment variables for legacy GPU..."
+1 -1
View File
@@ -1,3 +1,3 @@
echo "Cure Chromium crash bug caused by mixing 145 and 144 sync logs"
rm -rf ~/.config/chromium/Default/Sync\ Data/LevelDB/*.log
rm -rf ~/.config/chromium/Default/"Sync Data"/LevelDB/*.log