Added backup timestamps to various omarchy-refresh-* files to prevent clobbering (#402)

* Added backup timestamps to omarchy-refresh-[hyprlock|swayosd|walker|waybar] scripts to prevent data loss if ran multiple times

* Added new script (omarchy-refresh-config) for refreshing various config files with automated backup creation
This commit is contained in:
Andy Davis
2025-07-30 10:12:37 -04:00
committed by GitHub
parent d4f6859022
commit ff5630c64f
5 changed files with 37 additions and 45 deletions

30
bin/omarchy-refresh-config Executable file
View File

@ -0,0 +1,30 @@
#!/bin/bash
# This script deploys ~/.local/share/omarchy/config/X/Y/Z -> ~/.config/X/Y/Z
config_file=$1
if [[ -z "$config_file" ]]; then
cat << USAGE
Usage: $0 [config_file]
Must provide a file path from the .config directory to be refreshed.
To copy ~/.local/share/omarchy/config/hypr/hyprlock.conf to ~/.config/hypr/hyprlock.conf
$0 hypr/hyprlock.conf
USAGE
exit 1
fi
# Backup the destination file (with timestamp) to avoid clobbering (Ex: hyprlock.conf.bak.1753817951)
backup_file="${HOME}/.config/${config_file}.bak.$(date +%s)"
cp -f "${HOME}/.config/${config_file}" "$backup_file" 2>/dev/null
# Deploy the source file
cp -f "${HOME}/.local/share/omarchy/config/${config_file}" "${HOME}/.config/${config_file}" 2>/dev/null
# Compare and delete/inform accordingly
if cmp -s "${HOME}/.config/${config_file}" "$backup_file"; then
rm $backup_file
else
echo -e "\e[31mExisting "${HOME}/.config/${config_file}" replaced with new Omarchy default, but ${backup_file} file was made.\e[0m"
fi

View File

@ -1,11 +1,4 @@
#!/bin/bash
# Overwrite local Hyprlock settings with the latest in Omarchy, but create a backup if it differs
cp -f ~/.config/hypr/hyprlock.conf ~/.config/hypr/hyprlock.conf.bak 2>/dev/null
cp -f ~/.local/share/omarchy/config/hypr/hyprlock.conf ~/.config/hypr/ 2>/dev/null
if cmp -s ~/.config/hypr/hyprlock.conf.bak ~/.config/hypr/hyprlock.conf; then
rm ~/.config/hypr/hyprlock.conf.bak
else
echo -e "\e[31mExisting .config/hypr/hyprlock.conf replaced with new Omarchy default, but a .bak file was made.\e[0m"
fi
# Overwrite local Hyprlock settings with the latest in Omarchy
omarchy-refresh-config hypr/hyprlock.conf

View File

@ -1,13 +1,7 @@
#!/bin/bash
cp -f ~/.config/swayosd/config.toml ~/.config/swayosd/config.toml.bak 2>/dev/null
cp -f ~/.local/share/omarchy/config/swayosd/config.toml ~/.config/swayosd/ 3>/dev/null
if cmp -s ~/.config/swayosd/config.toml.bak ~/.config/swayosd/config.toml; then
rm ~/.config/swayosd//config.toml.bak
else
echo -e "\e[31mExisting .config/swayosd/config.toml replaced with new Omarchy default, but a .bak file was made.\e[0m"
fi
omarchy-refresh-config swayosd/config.toml
omarchy-refresh-config swayosd/style.css
pkill swayosd-server
setsid uwsm app -- swayosd-server &>/dev/null &

View File

@ -1,13 +1,6 @@
#!/bin/bash
cp -f ~/.config/walker/config.toml ~/.config/walker/config.toml.bak 2>/dev/null
cp -f ~/.local/share/omarchy/config/walker/config.toml ~/.config/walker/ 2>/dev/null
if cmp -s ~/.config/walker/config.toml.bak ~/.config/walker/config.toml; then
rm ~/.config/walker/config.toml.bak
else
echo -e "\e[31mExisting .config/walker/config.toml replaced with new Omarchy default, but a .bak file was made.\e[0m"
fi
omarchy-refresh-config walker/config.toml
pkill walker
setsid uwsm app -- walker --gapplication-service &

View File

@ -1,25 +1,7 @@
#!/bin/bash
# Backup existing settings
cp -f ~/.config/waybar/config.jsonc ~/.config/waybar/config.jsonc.bak 2>/dev/null
cp -f ~/.config/waybar/style.css ~/.config/waybar/style.css.bak 2>/dev/null
# Overwrite local waybar settings with the latest in Omarchy
cp -f ~/.local/share/omarchy/config/waybar/config.jsonc ~/.config/waybar/ 2>/dev/null
cp -f ~/.local/share/omarchy/config/waybar/style.css ~/.config/waybar/ 2>/dev/null
# Remove identical backup files
if cmp -s ~/.config/waybar/config.jsonc.bak ~/.config/waybar/config.jsonc; then
rm ~/.config/waybar/config.jsonc.bak
else
echo -e "\e[31mExisting .config/waybar/config.jsonc replaced with new Omarchy default, but a .bak file was made.\e[0m"
fi
if cmp -s ~/.config/waybar/style.css.bak ~/.config/waybar/style.css; then
rm ~/.config/waybar/style.css.bak
else
echo -e "\e[31mExisting .config/waybar/style.css replaced with new Omarchy default, but a .bak file was made.\e[0m"
fi
omarchy-refresh-config waybar/config.jsonc
omarchy-refresh-config waybar/style.css
# Restart waybar
pkill -SIGUSR2 waybar