forked from Shinonome/dots-hyprland
Merge branch 'end-4:main' into keybinds-settings
This commit is contained in:
@@ -18,11 +18,11 @@ input_path = '~/.config/matugen/templates/fuzzel/fuzzel_theme.ini'
|
||||
output_path = '~/.config/fuzzel/fuzzel_theme.ini'
|
||||
|
||||
[templates.gtk3]
|
||||
input_path = '~/.config/matugen/templates/gtk/gtk-colors.css'
|
||||
input_path = '~/.config/matugen/templates/gtk-3.0/gtk.css'
|
||||
output_path = '~/.config/gtk-3.0/gtk.css'
|
||||
|
||||
[templates.gtk4]
|
||||
input_path = '~/.config/matugen/templates/gtk/gtk-colors.css'
|
||||
input_path = '~/.config/matugen/templates/gtk-4.0/gtk.css'
|
||||
output_path = '~/.config/gtk-4.0/gtk.css'
|
||||
|
||||
[templates.kde_colors]
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* GTK Colors
|
||||
* Generated with Matugen
|
||||
*/
|
||||
|
||||
@media (prefers-color-scheme: light) {
|
||||
@define-color accent_color {{colors.primary.light.hex}};
|
||||
@define-color accent_fg_color {{colors.on_primary.light.hex}};
|
||||
@define-color accent_bg_color {{colors.primary.light.hex}};
|
||||
@define-color window_bg_color {{colors.background.light.hex}};
|
||||
@define-color window_fg_color {{colors.on_background.light.hex}};
|
||||
@define-color headerbar_bg_color {{colors.surface_dim.light.hex}};
|
||||
@define-color headerbar_fg_color {{colors.on_surface.light.hex}};
|
||||
@define-color popover_bg_color {{colors.surface_dim.light.hex}};
|
||||
@define-color popover_fg_color {{colors.on_surface.light.hex}};
|
||||
@define-color view_bg_color {{colors.surface.light.hex}};
|
||||
@define-color view_fg_color {{colors.on_surface.light.hex}};
|
||||
@define-color card_bg_color {{colors.surface.light.hex}};
|
||||
@define-color card_fg_color {{colors.on_surface.light.hex}};
|
||||
@define-color sidebar_bg_color @window_bg_color;
|
||||
@define-color sidebar_fg_color @window_fg_color;
|
||||
@define-color sidebar_border_color @window_bg_color;
|
||||
@define-color sidebar_backdrop_color @window_bg_color;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
@define-color accent_color {{colors.primary.dark.hex}};
|
||||
@define-color accent_fg_color {{colors.on_primary.dark.hex}};
|
||||
@define-color accent_bg_color {{colors.primary.dark.hex}};
|
||||
@define-color window_bg_color {{colors.background.dark.hex}};
|
||||
@define-color window_fg_color {{colors.on_background.dark.hex}};
|
||||
@define-color headerbar_bg_color {{colors.surface_dim.dark.hex}};
|
||||
@define-color headerbar_fg_color {{colors.on_surface.dark.hex}};
|
||||
@define-color popover_bg_color {{colors.surface_dim.dark.hex}};
|
||||
@define-color popover_fg_color {{colors.on_surface.dark.hex}};
|
||||
@define-color view_bg_color {{colors.surface.dark.hex}};
|
||||
@define-color view_fg_color {{colors.on_surface.dark.hex}};
|
||||
@define-color card_bg_color {{colors.surface.dark.hex}};
|
||||
@define-color card_fg_color {{colors.on_surface.dark.hex}};
|
||||
@define-color sidebar_bg_color @window_bg_color;
|
||||
@define-color sidebar_fg_color @window_fg_color;
|
||||
@define-color sidebar_border_color @window_bg_color;
|
||||
@define-color sidebar_backdrop_color @window_bg_color;
|
||||
}
|
||||
@@ -52,7 +52,9 @@
|
||||
|
||||
##### Not work, to be solved #####
|
||||
# swaylock pamtester
|
||||
|
||||
|
||||
# TODO: migrate all packages from dist-arch. Note that for each package, must know why it's needed and how it's used specifically, cuz things may be need tweak to properly use the package installed by Nix, especially those have hardcoded path /usr/* .
|
||||
### illogical-impulse-audio
|
||||
libcava #cava
|
||||
lxqt.pavucontrol-qt #pavucontrol-qt
|
||||
|
||||
+3
-18
@@ -292,24 +292,9 @@ function check_disk_space() {
|
||||
return 0
|
||||
}
|
||||
|
||||
function auto_get_git_submodule(){
|
||||
local git_submodules_list=()
|
||||
|
||||
while IFS= read -r path; do
|
||||
[ -z "$path" ] && continue
|
||||
git_submodules_list+=("$path")
|
||||
done < <(git submodule status --recursive 2>/dev/null | awk '{print $2}')
|
||||
|
||||
local missing=0
|
||||
|
||||
for p in "${git_submodules_list[@]}"; do
|
||||
if [ ! -d "$p" ] || [ -z "$(ls -A "$p" 2>/dev/null)" ]; then
|
||||
missing=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$missing" -eq 1 ]; then
|
||||
function auto_update_git_submodule(){
|
||||
if git submodule status --recursive | grep -E '^[+-U]';then
|
||||
# Note: `git pull --recurse-submodules` cannot substitute `git submodule update --init --recursive` cuz it does not init a submodule when needed.
|
||||
x git submodule update --init --recursive
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -9,15 +9,11 @@
|
||||
pkglistfile=$(mktemp)
|
||||
pkglistfile_orig=${LIST_FILE_PATH}
|
||||
pkglistfile_orig_s=${REPO_ROOT}/cache/dependencies_stripped.conf
|
||||
#if ! "$(command -v curl)";then
|
||||
# echo "Please install curl first.";exit 1
|
||||
#fi
|
||||
#if ! "$(command -v gzip)";then
|
||||
# echo "Please install gzip first.";exit 1
|
||||
#fi
|
||||
#if ! "$(command -v pacman)";then
|
||||
# echo "pacman not found, aborting...";exit 1
|
||||
#fi
|
||||
for cmd in curl gzip pacman;do
|
||||
if ! command -v $cmd;then
|
||||
echo "Please install $cmd first.";exit 1
|
||||
fi
|
||||
done
|
||||
remove_bashcomments_emptylines $pkglistfile_orig $pkglistfile_orig_s
|
||||
|
||||
cat $pkglistfile_orig_s | sed "s_\ _\n_g" > $pkglistfile
|
||||
|
||||
@@ -4,7 +4,7 @@ printf "${STY_CYAN}[$0]: 1. Install dependencies\n${STY_RST}"
|
||||
|
||||
function outdate_detect(){
|
||||
# Shallow clone prevent latest_commit_timestamp() from working.
|
||||
x git_auto_unshallow
|
||||
x git_auto_unshallow 2>&1>/dev/null
|
||||
|
||||
local source_path="$1"
|
||||
local target_path="$2"
|
||||
@@ -119,12 +119,17 @@ elif [[ -f "./sdata/dist-${OS_DISTRO_ID}/install-deps.sh" ]]; then
|
||||
if [[ "${tmp_update_status}" =~ ^(OUTDATED|EMPTY_TARGET|EMPTY_SOURCE|FORCE_OUTDATED|WIP)$ ]]; then
|
||||
printf "${STY_RED}${STY_BOLD}===URGENT===${STY_RST}\n"
|
||||
printf "${STY_RED}"
|
||||
printf "The community provided ./sdata/dist-${TARGET_ID}/ is not updated (update status: ${tmp_update_status}),\n"
|
||||
printf "which means it does not fully reflect the latest changes of ./sdata/dist-arch/ .\n"
|
||||
printf "You are highly recommended to abort this script, until someone (maybe you?) has updated the ./sdata/dist-${TARGET_ID}/ to fully reflect the latest changes in ./sdata/dist-arch/ .\n"
|
||||
printf "PR is welcomed. Please see discussion#2140 for details.\n"
|
||||
printf "The community provided ./sdata/dist-${TARGET_ID}/ is outdated (status: ${tmp_update_status}),\n"
|
||||
printf "which means it probably does not reflect all latest changes of ./sdata/dist-arch/ .\n"
|
||||
printf "\n"
|
||||
printf "According to the actual changes, it may still works, but it can also work unexpectedly.\n"
|
||||
printf "It's highly recommended to check the following links before continue:${STY_RST}\n"
|
||||
printf "${STY_UNDERLINE}https://github.com/end-4/dots-hyprland/discussions/2140${STY_RST}\n"
|
||||
printf "${STY_RED}${STY_INVERT}If you are proceeding anyway, illogical-impulse will very likely not work as expected.${STY_RST}\n"
|
||||
printf "${STY_UNDERLINE}https://github.com/end-4/dots-hyprland/commits/main/sdata/dist-arch${STY_RST}\n"
|
||||
printf "${STY_UNDERLINE}https://github.com/end-4/dots-hyprland/commits/main/sdata/dist-${TARGET_ID}${STY_RST}\n"
|
||||
printf "\n"
|
||||
printf "${STY_PURPLE}${STY_INVERT}PR on ./sdata/dist-${TARGET_ID}/ to properly reflect the latest changes of ./sdata/dist-arch is welcomed.${STY_RST}\n"
|
||||
printf "\n"
|
||||
if [ "$ask" = "false" ]; then
|
||||
echo "Urgent problem encountered, aborting...";exit 1
|
||||
fi
|
||||
@@ -163,7 +168,7 @@ else
|
||||
printf "./sdata/dist-${OS_DISTRO_ID}/install-deps.sh not found.\n"
|
||||
printf "./sdata/dist-${TARGET_ID}/install-deps.sh will be used.\n"
|
||||
printf "1. It may disrupt your system and will likely fail without your manual intervention.\n"
|
||||
printf "2. It's WIP and only contains small number of dependencies far from enough.\n"
|
||||
printf "2. It is WIP and only contains small number of dependencies far from enough.\n"
|
||||
printf "Proceed only at your own risk.\n"
|
||||
printf "${STY_RST}"
|
||||
pause
|
||||
|
||||
+180
-166
@@ -1,134 +1,150 @@
|
||||
# This script is meant to be sourced.
|
||||
# It's not for directly running.
|
||||
|
||||
# TODO: https://github.com/end-4/dots-hyprland/issues/2137
|
||||
# See https://github.com/end-4/dots-hyprland/issues/2137
|
||||
#
|
||||
# Stage 1 todos:
|
||||
# TODO: Properly handle hyprland config, ~/.config/hypr/hyprland.conf should be overwritten only when firstrun
|
||||
# TODO: add --exp-files-path <path> Use <path> instead of the default yaml config
|
||||
# TODO: add --exp-files-regen Force copy the default config to ${EXP_FILE_PATH} (auto do this when not existed)
|
||||
# TODO: Implement versioning, i.e. when user-defined yaml config file has version number mismatch with the default one, produce error. If only minor version number is not the same, the error can be ommitted via --exp-file-no-strict .
|
||||
# TODO: add --exp-files-no-strict Ignore error when minor version number is not the same
|
||||
#
|
||||
# Stage 2 todos:
|
||||
# TODO: Implement bool key symlink (both read-write and read-only), when the value of `symlink` is true, then instead using `rsync` or `cp`, use `ln`.
|
||||
# TODO: add --exp-file-reset-symlink Try to remove all symlink in .config and .local, which point to the local repo
|
||||
# TODO: Update help and doc about `--exp-files` and the yaml config, including the possible values of mode.
|
||||
#
|
||||
# Stage 3 todos:
|
||||
# TODO: Implement user-define yaml with merging (override) ability for user who only wants little customization and is satisfied with most of the defaults. User can use `./install-files.yaml` as custom config. When `./install-files.yaml` exists and have correct major version number, merge it together with `sdata/step/3.install-files.yaml` to generate a `cache/install-files.final.yaml` to determine how to copy files. About how to merge two yaml files, I know some software such as rime input method and docker supports a override yaml config, which we may reference from. See also https://github.com/mikefarah/yq/discussions/1437
|
||||
# TODO: Implement variants like keybindings, terminals, etc under user_preferences.
|
||||
|
||||
# Configuration file
|
||||
CONFIG_FILE="sdata/subcmd-install/3.files.yaml"
|
||||
CONFIG_FILE="sdata/subcmd-install/3.files-exp.yaml"
|
||||
|
||||
# =============================================================================
|
||||
wizard_update_preferences() {
|
||||
echo -e "${STY_CYAN}=== Dotfiles Customization ===${STY_RESET}"
|
||||
|
||||
echo -e "${STY_CYAN}=== Dotfiles Customization ===${STY_RESET}"
|
||||
|
||||
# Get current preferences
|
||||
current_shell=$(yq '.user_preferences.shell // "fish"' "$CONFIG_FILE")
|
||||
current_terminal=$(yq '.user_preferences.terminal // "kitty"' "$CONFIG_FILE")
|
||||
current_keybindings=$(yq '.user_preferences.keybindings // "default"' "$CONFIG_FILE")
|
||||
|
||||
|
||||
echo "Current preferences:"
|
||||
echo " Shell: $current_shell"
|
||||
echo " Terminal: $current_terminal"
|
||||
echo " Keybindings: $current_keybindings"
|
||||
echo
|
||||
|
||||
|
||||
# Shell selection
|
||||
echo "Which shell do you prefer?"
|
||||
echo "1) fish (default)"
|
||||
echo "2) zsh"
|
||||
read -p "Enter choice [1-2]: " shell_choice
|
||||
|
||||
|
||||
case "$shell_choice" in
|
||||
1|"") shell="fish" ;;
|
||||
2) shell="zsh" ;;
|
||||
*) echo "Invalid choice, using fish"; shell="fish" ;;
|
||||
1|"") shell="fish" ;;
|
||||
2) shell="zsh" ;;
|
||||
*) echo "Invalid choice, using fish"; shell="fish" ;;
|
||||
esac
|
||||
|
||||
|
||||
# Terminal selection
|
||||
echo
|
||||
echo "Which terminal do you prefer?"
|
||||
echo "1) kitty (default)"
|
||||
echo "2) foot"
|
||||
read -p "Enter choice [1-2]: " terminal_choice
|
||||
|
||||
|
||||
case "$terminal_choice" in
|
||||
1|"") terminal="kitty" ;;
|
||||
2) terminal="foot" ;;
|
||||
*) echo "Invalid choice, using kitty"; terminal="kitty" ;;
|
||||
1|"") terminal="kitty" ;;
|
||||
2) terminal="foot" ;;
|
||||
*) echo "Invalid choice, using kitty"; terminal="kitty" ;;
|
||||
esac
|
||||
|
||||
|
||||
# Keybindings selection
|
||||
echo
|
||||
echo "Which keybinding style do you prefer?"
|
||||
echo "1) default (arrow keys)"
|
||||
echo "2) vim (H/J/K/L)"
|
||||
read -p "Enter choice [1-2]: " keybind_choice
|
||||
|
||||
|
||||
case "$keybind_choice" in
|
||||
1|"") keybindings="default" ;;
|
||||
2) keybindings="vim" ;;
|
||||
*) echo "Invalid choice, using default"; keybindings="default" ;;
|
||||
1|"") keybindings="default" ;;
|
||||
2) keybindings="vim" ;;
|
||||
*) echo "Invalid choice, using default"; keybindings="default" ;;
|
||||
esac
|
||||
|
||||
|
||||
# Update YAML in-place
|
||||
yq -i ".user_preferences.shell = \"$shell\"" "$CONFIG_FILE"
|
||||
yq -i ".user_preferences.terminal = \"$terminal\"" "$CONFIG_FILE"
|
||||
yq -i ".user_preferences.keybindings = \"$keybindings\"" "$CONFIG_FILE"
|
||||
|
||||
|
||||
echo
|
||||
echo "Preferences updated!"
|
||||
}
|
||||
}
|
||||
|
||||
# Get user preference
|
||||
get_pref() {
|
||||
yq -r ".user_preferences.$1" "$CONFIG_FILE"
|
||||
yq -r ".user_preferences.$1" "$CONFIG_FILE"
|
||||
}
|
||||
|
||||
# Check if pattern should be processed based on user preferences
|
||||
should_process_pattern() {
|
||||
local pattern="$1"
|
||||
local condition=$(echo "$pattern" | yq '.condition // "true"')
|
||||
local pattern="$1"
|
||||
local condition=$(echo "$pattern" | yq '.condition // "true"')
|
||||
|
||||
# If no condition or condition is "true", always process
|
||||
if [[ "$condition" == "true" ]]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
|
||||
# Extract the preference type and value from condition
|
||||
local type=$(echo "$condition" | yq '.type')
|
||||
local value=$(echo "$condition" | yq '.value')
|
||||
|
||||
|
||||
[[ "$(get_pref "$type")" == "$value" ]]
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
# Compare hashes of files/directories, return true if they are the same, false otherwise
|
||||
files_are_same() {
|
||||
local path1="$1"
|
||||
local path2="$2"
|
||||
|
||||
local path1="$1"
|
||||
local path2="$2"
|
||||
|
||||
# Check if paths exist
|
||||
if [[ ! -e "$path1" || ! -e "$path2" ]]; then
|
||||
return 1
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
# For directories, use find + md5sum to compare recursively
|
||||
# For files, use md5sum directly
|
||||
if [[ -d "$path1" && -d "$path2" ]]; then
|
||||
# Compare directory contents using find and md5sum
|
||||
local hash1=$(find "$path1" -type f -exec md5sum {} \; | sort -k 2 | md5sum | awk '{print $1}')
|
||||
local hash2=$(find "$path2" -type f -exec md5sum {} \; | sort -k 2 | md5sum | awk '{print $1}')
|
||||
[[ "$hash1" == "$hash2" ]]
|
||||
# Compare directory contents using find and md5sum
|
||||
local hash1=$(find "$path1" -type f -exec md5sum {} \; | sort -k 2 | md5sum | awk '{print $1}')
|
||||
local hash2=$(find "$path2" -type f -exec md5sum {} \; | sort -k 2 | md5sum | awk '{print $1}')
|
||||
[[ "$hash1" == "$hash2" ]]
|
||||
elif [[ -f "$path1" && -f "$path2" ]]; then
|
||||
# Compare file hashes
|
||||
local hash1=$(md5sum "$path1" | awk '{print $1}')
|
||||
local hash2=$(md5sum "$path2" | awk '{print $1}')
|
||||
[[ "$hash1" == "$hash2" ]]
|
||||
# Compare file hashes
|
||||
local hash1=$(md5sum "$path1" | awk '{print $1}')
|
||||
local hash2=$(md5sum "$path2" | awk '{print $1}')
|
||||
[[ "$hash1" == "$hash2" ]]
|
||||
else
|
||||
# One is a file, one is a directory - different types
|
||||
return 1
|
||||
# One is a file, one is a directory - different types
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
}
|
||||
|
||||
# Find next backup number
|
||||
get_next_backup_number() {
|
||||
local base_path="$1"
|
||||
local counter=1
|
||||
local base_path="$1"
|
||||
local counter=1
|
||||
|
||||
while [[ -e "${base_path}.old.${counter}" ]]; do
|
||||
((counter++))
|
||||
done
|
||||
while [[ -e "${base_path}.old.${counter}" ]]; do
|
||||
((counter++))
|
||||
done
|
||||
|
||||
echo $counter
|
||||
echo $counter
|
||||
}
|
||||
|
||||
# =============================================================================
|
||||
@@ -146,118 +162,116 @@ readarray patterns < <(yq -o=j -I=0 '.patterns[]' "$CONFIG_FILE")
|
||||
|
||||
# Process each pattern
|
||||
for pattern in "${patterns[@]}"; do
|
||||
from=$(echo "$pattern" | yq '.from' - | envsubst)
|
||||
to=$(echo "$pattern" | yq '.to' - | envsubst)
|
||||
mode=$(echo "$pattern" | yq '.mode' - | envsubst)
|
||||
condition=$(echo "$pattern" | yq '.condition // "true"')
|
||||
|
||||
# Handle fontconfig fontset override
|
||||
# If FONTSET_DIR_NAME is set and this is the fontconfig pattern, use the fontset instead
|
||||
if [[ "$from" == "dots/.config/fontconfig" ]] && [[ -n "${FONTSET_DIR_NAME:-}" ]]; then
|
||||
from="dots-extra/fontsets/${FONTSET_DIR_NAME}"
|
||||
echo "Using fontset \"${FONTSET_DIR_NAME}\" for fontconfig"
|
||||
fi
|
||||
|
||||
# Check if pattern should be processed
|
||||
if ! should_process_pattern "$pattern"; then
|
||||
# Format condition message nicely
|
||||
if [[ "$condition" != "true" ]]; then
|
||||
cond_type=$(echo "$condition" | yq -r '.type // ""')
|
||||
cond_value=$(echo "$condition" | yq -r '.value // ""')
|
||||
if [[ -n "$cond_type" && -n "$cond_value" ]]; then
|
||||
echo "Skipping $from -> $to (condition not met: $cond_type == '$cond_value')"
|
||||
else
|
||||
echo "Skipping $from -> $to (condition not met)"
|
||||
fi
|
||||
else
|
||||
echo "Skipping $from -> $to (condition not met)"
|
||||
fi
|
||||
continue
|
||||
fi
|
||||
|
||||
echo "Processing: $from -> $to (mode: $mode)"
|
||||
|
||||
# Build exclude arguments for rsync
|
||||
excludes=()
|
||||
if echo "$pattern" | yq -e '.excludes' >/dev/null 2>&1; then
|
||||
while IFS= read -r exclude; do
|
||||
excludes+=(--exclude "$exclude")
|
||||
done < <(echo "$pattern" | yq -r '.excludes[]')
|
||||
fi
|
||||
|
||||
# Check if source exists
|
||||
if [[ ! -e "$from" ]]; then
|
||||
echo "Warning: Source does not exist: $from (skipping)"
|
||||
continue
|
||||
fi
|
||||
|
||||
# Ensure destination directory exists for files
|
||||
if [[ -f "$from" ]]; then
|
||||
v mkdir -p "$(dirname "$to")"
|
||||
fi
|
||||
|
||||
# Execute based on mode
|
||||
case $mode in
|
||||
"sync")
|
||||
if [[ -d "$from" ]]; then
|
||||
warning_rsync_delete
|
||||
v rsync -av --delete "${excludes[@]}" "$from/" "$to/"
|
||||
else
|
||||
warning_rsync_normal
|
||||
# For files, don't use trailing slash and don't use --delete
|
||||
v rsync -av "${excludes[@]}" "$from" "$to"
|
||||
fi
|
||||
;;
|
||||
"soft")
|
||||
warning_rsync_normal
|
||||
if [[ -d "$from" ]]; then
|
||||
v rsync -av "${excludes[@]}" "$from/" "$to/"
|
||||
else
|
||||
# For files, don't use trailing slash
|
||||
v rsync -av "${excludes[@]}" "$from" "$to"
|
||||
fi
|
||||
;;
|
||||
"hard")
|
||||
v cp -r "$from" "$to"
|
||||
;;
|
||||
"hard-backup")
|
||||
if [[ -e "$to" ]]; then
|
||||
if files_are_same "$from" "$to"; then
|
||||
echo "Files are identical, skipping backup"
|
||||
else
|
||||
backup_number=$(get_next_backup_number "$to")
|
||||
v mv "$to" "$to.old.$backup_number"
|
||||
v cp -r "$from" "$to"
|
||||
fi
|
||||
else
|
||||
v cp -r "$from" "$to"
|
||||
fi
|
||||
;;
|
||||
"soft-backup")
|
||||
if [[ -e "$to" ]]; then
|
||||
if files_are_same "$from" "$to"; then
|
||||
echo "Files are identical, skipping backup"
|
||||
else
|
||||
v cp -r "$from" "$to.new"
|
||||
fi
|
||||
else
|
||||
v cp -r "$from" "$to"
|
||||
fi
|
||||
;;
|
||||
"skip")
|
||||
echo "Skipping $from"
|
||||
;;
|
||||
"skip-if-exists")
|
||||
if [[ -e "$to" ]]; then
|
||||
echo "Skipping $from (destination exists)"
|
||||
else
|
||||
v cp -r "$from" "$to"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Unknown mode: $mode"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
from=$(echo "$pattern" | yq '.from' - | envsubst)
|
||||
to=$(echo "$pattern" | yq '.to' - | envsubst)
|
||||
mode=$(echo "$pattern" | yq '.mode' - | envsubst)
|
||||
condition=$(echo "$pattern" | yq '.condition // "true"')
|
||||
|
||||
#####################################################################################
|
||||
# Handle fontconfig fontset override
|
||||
# If FONTSET_DIR_NAME is set and this is the fontconfig pattern, use the fontset instead
|
||||
if [[ "$from" == "dots/.config/fontconfig" ]] && [[ -n "${FONTSET_DIR_NAME:-}" ]]; then
|
||||
from="dots-extra/fontsets/${FONTSET_DIR_NAME}"
|
||||
echo "Using fontset \"${FONTSET_DIR_NAME}\" for fontconfig"
|
||||
fi
|
||||
|
||||
# Check if pattern should be processed
|
||||
if ! should_process_pattern "$pattern"; then
|
||||
# Format condition message nicely
|
||||
if [[ "$condition" != "true" ]]; then
|
||||
cond_type=$(echo "$condition" | yq -r '.type // ""')
|
||||
cond_value=$(echo "$condition" | yq -r '.value // ""')
|
||||
if [[ -n "$cond_type" && -n "$cond_value" ]]; then
|
||||
echo "Skipping $from -> $to (condition not met: $cond_type == '$cond_value')"
|
||||
else
|
||||
echo "Skipping $from -> $to (condition not met)"
|
||||
fi
|
||||
else
|
||||
echo "Skipping $from -> $to (condition not met)"
|
||||
fi
|
||||
continue
|
||||
fi
|
||||
|
||||
echo "Processing: $from -> $to (mode: $mode)"
|
||||
|
||||
# Build exclude arguments for rsync
|
||||
excludes=()
|
||||
if echo "$pattern" | yq -e '.excludes' >/dev/null 2>&1; then
|
||||
while IFS= read -r exclude; do
|
||||
excludes+=(--exclude "$exclude")
|
||||
done < <(echo "$pattern" | yq -r '.excludes[]')
|
||||
fi
|
||||
|
||||
# Check if source exists
|
||||
if [[ ! -e "$from" ]]; then
|
||||
echo "Warning: Source does not exist: $from (skipping)"
|
||||
continue
|
||||
fi
|
||||
|
||||
# Ensure destination directory exists for files
|
||||
if [[ -f "$from" ]]; then
|
||||
v mkdir -p "$(dirname "$to")"
|
||||
fi
|
||||
|
||||
# Execute based on mode
|
||||
case $mode in
|
||||
"sync")
|
||||
if [[ -d "$from" ]]; then
|
||||
warning_rsync_delete
|
||||
v rsync -av --delete "${excludes[@]}" "$from/" "$to/"
|
||||
else
|
||||
warning_rsync_normal
|
||||
# For files, don't use trailing slash and don't use --delete
|
||||
v rsync -av "${excludes[@]}" "$from" "$to"
|
||||
fi
|
||||
;;
|
||||
"soft")
|
||||
warning_rsync_normal
|
||||
if [[ -d "$from" ]]; then
|
||||
v rsync -av "${excludes[@]}" "$from/" "$to/"
|
||||
else
|
||||
# For files, don't use trailing slash
|
||||
v rsync -av "${excludes[@]}" "$from" "$to"
|
||||
fi
|
||||
;;
|
||||
"hard")
|
||||
v cp -r "$from" "$to"
|
||||
;;
|
||||
"hard-backup")
|
||||
if [[ -e "$to" ]]; then
|
||||
if files_are_same "$from" "$to"; then
|
||||
echo "Files are identical, skipping backup"
|
||||
else
|
||||
backup_number=$(get_next_backup_number "$to")
|
||||
v mv "$to" "$to.old.$backup_number"
|
||||
v cp -r "$from" "$to"
|
||||
fi
|
||||
else
|
||||
v cp -r "$from" "$to"
|
||||
fi
|
||||
;;
|
||||
"soft-backup")
|
||||
if [[ -e "$to" ]]; then
|
||||
if files_are_same "$from" "$to"; then
|
||||
echo "Files are identical, skipping backup"
|
||||
else
|
||||
v cp -r "$from" "$to.new"
|
||||
fi
|
||||
else
|
||||
v cp -r "$from" "$to"
|
||||
fi
|
||||
;;
|
||||
"skip")
|
||||
echo "Skipping $from"
|
||||
;;
|
||||
"skip-if-exists")
|
||||
if [[ -e "$to" ]]; then
|
||||
echo "Skipping $from (destination exists)"
|
||||
else
|
||||
v cp -r "$from" "$to"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Unknown mode: $mode"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
# The possible values of `mode`: (by default `sync`)
|
||||
# - `sync`: Make the destination completely the same as the source.
|
||||
# - `soft`: Skip existing files when copying
|
||||
# - `hard`: Overwrite existing files when copying
|
||||
# - `soft-backup`: If target file exists, copy source file to `*.new`. Do not create `*.new` but skip coyping when source and target HASH values are exactly the same.
|
||||
# - `hard-backup`: If target file exists, create backup by renaming it to `*.old.<n>` where `<n>` is a number increment from 1 to prevent backup gets overwritten when running twice. (Keep in mind that this script must be idempotent.) Also must compare the actual file content by using MD5 HASH value to prevent generating lots of `*.old.<n>`s when runnng multiple times. Do not create backup but skip coyping when source and target HASH values are exactly the same.
|
||||
# - `skip`: Skip this step
|
||||
# - `skip-if-exists`: Skip this step if target exists
|
||||
version: "1.0"
|
||||
user_preferences:
|
||||
shell: "fish" # fish | zsh
|
||||
@@ -22,7 +22,7 @@ function auto_backup_configs(){
|
||||
false) if [[ ! -d "$BACKUP_DIR" ]]; then local backup=true;fi;;
|
||||
*)
|
||||
printf "${STY_RED}"
|
||||
printf "Would you like to backup clashing dirs/files to \"$BACKUP_DIR\"?"
|
||||
printf "Would you like to backup clashing dirs/files to \"$BACKUP_DIR\"?\n"
|
||||
printf "${STY_RST}"
|
||||
while true;do
|
||||
echo " y = Yes, backup"
|
||||
@@ -33,7 +33,7 @@ function auto_backup_configs(){
|
||||
local backup=true;break ;;
|
||||
[nNsS]) echo -e "${STY_BLUE}Alright, skipping...${STY_RST}"
|
||||
local backup=false;break ;;
|
||||
*) echo -e "${STY_RED}Please enter [y/n].${STY_RST}";;
|
||||
*) echo -e "${STY_RED}Please enter [y/n/s].${STY_RST}";;
|
||||
esac
|
||||
done
|
||||
;;
|
||||
@@ -46,8 +46,8 @@ function auto_backup_configs(){
|
||||
}
|
||||
|
||||
#####################################################################################
|
||||
showfun auto_get_git_submodule
|
||||
v auto_get_git_submodule
|
||||
showfun auto_update_git_submodule
|
||||
v auto_update_git_submodule
|
||||
|
||||
# Backup
|
||||
if [[ ! "${SKIP_BACKUP}" == true ]]; then auto_backup_configs; fi
|
||||
|
||||
@@ -27,12 +27,13 @@ Options for install:
|
||||
Possible values of <set>: $(ls -A ${REPO_ROOT}/dots-extra/fontsets)
|
||||
${STY_CYAN}
|
||||
New features (experimental):
|
||||
--exp-files Use yaml-based config for the third step copying files.
|
||||
This feature is ${STY_YELLOW}still on early stage${STY_CYAN}, feedback and contribution welcomed,
|
||||
see https://github.com/end-4/dots-hyprland/issues/2137 for details.
|
||||
--via-nix Use Nix and Home-manager to install dependencies.
|
||||
This feature is ${STY_RED}working in progress${STY_CYAN}. Contribution is welcomed,
|
||||
see https://github.com/end-4/dots-hyprland/issues/1061 for details.
|
||||
--exp-files Use yaml-based config for the third step copying files.
|
||||
This feature is ${STY_YELLOW}still on early stage${STY_CYAN},
|
||||
feedback and contribution welcomed,
|
||||
see https://github.com/end-4/dots-hyprland/issues/2137 for details.
|
||||
--via-nix Use Nix and Home-manager to install dependencies.
|
||||
This feature is ${STY_RED}working in progress${STY_CYAN}. Contribution is welcomed,
|
||||
see https://github.com/end-4/dots-hyprland/issues/1061 for details.
|
||||
${STY_RST}"
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ Syntax:
|
||||
|
||||
Subcommands:
|
||||
install (Re)Install/Update illogical-impulse.
|
||||
Note: To update to the latest, manually run \"git pull\" first.
|
||||
install-deps Run the install step \"1. Install dependencies\"
|
||||
install-setups Run the install step \"2. Setup for permissions/services etc\"
|
||||
install-files Run the install step \"3. Copying config files\"
|
||||
@@ -36,6 +37,8 @@ Subcommands:
|
||||
|
||||
For each <subcommand>, use -h for details:
|
||||
$0 <subcommand> -h
|
||||
|
||||
${STY_BOLD}${STY_CYAN}Access ${STY_UNDERLINE}https://ii.clsty.link${STY_RST} ${STY_BOLD}${STY_CYAN}for documentation about illogical-impulse.${STY_RST}
|
||||
"
|
||||
}
|
||||
case $1 in
|
||||
|
||||
Reference in New Issue
Block a user