Overview
Theupdate.sh script synchronizes your local configuration files from the Config-Sway repository to your home directory. It intelligently manages dotfiles in both ~/.config and ~ directories, creating backups before applying changes and tracking which files are managed by the repository.
Location
Usage
Options
Skip creating backup directories before synchronization. Use with caution.
What It Does
Step-by-Step Execution
-
Pre-flight Checks
- Verifies
.configdirectory exists in the repository - Checks that
rsyncis installed - Validates command-line options
- Verifies
-
Backup Creation (unless
--no-backupis specified)- Creates timestamped backup:
~/.config.bak-YYYYMMDD-HHMMSS - Creates home dotfiles backup:
~/home-dots.bak-YYYYMMDD-HHMMSS - Backups are made before any changes are applied
- Creates timestamped backup:
-
~/.config Synchronization
- Reads top-level directories/files from repository’s
.config - Uses
rsync -a --deleteto sync each managed directory - Creates tracking file:
~/.config/.config-sway-managed - Removes directories that were deleted from the repository
- Reads top-level directories/files from repository’s
-
Home Directory Synchronization (if
home/exists)- Syncs dotfiles from repository’s
home/directory to~ - Creates tracking file:
~/.home-dots-managed - Only affects files listed in the tracking file
- Syncs dotfiles from repository’s
-
Service Reloads
- Restarts
xdg-desktop-portalandxdg-desktop-portal-wlr - Reloads Sway configuration with
swaymsg reload - Restarts Waybar with the new configuration
- Restarts
Synchronization Behavior
The script usesrsync -a --delete which means:
- Archive mode (
-a): Preserves permissions, timestamps, symlinks, etc. - Delete mode (
--delete): Removes files in destination not present in source - Scoped deletion: Only deletes within managed directories tracked by the script
Options Reference
—no-backup
Skips the creation of backup directories. This makes the script run faster but removes the safety net.Managed Files Tracking
The script maintains two tracking files:~/.config/.config-sway-managed
Lists all top-level directories/files in~/.config managed by Config-Sway:
~/.home-dots-managed
Lists all dotfiles in~ managed by Config-Sway:
Error Handling
Missing .config Directory
.config directory is required.
rsync Not Found
install.sh on Arch Linux.
Unknown Option
--no-backup is supported.
Exit Codes
- 0: Success (all files synchronized)
- 1: Error (missing dependencies, invalid options, or synchronization failure)
Examples
Standard Update with Backup
Update Without Backup
Restore from Backup
If you need to restore from a backup:Repository Structure
The script expects this repository structure:Synchronized Directories
Typically synchronized directories include:~/.config/sway- Sway window manager configuration~/.config/waybar- Waybar status bar configuration~/.config/kitty- Kitty terminal configuration~/.config/rofi- Rofi launcher configuration~/.config/mako- Mako notification daemon configuration~/.config/ranger- Ranger file manager configuration~/.config/scripts- Custom utility scripts~/.config/themes- Theme definitions~/.config/wallpapers- Wallpaper collection
Service Reloads
After synchronization, the script automatically reloads:XDG Desktop Portals
Sway Window Manager
Waybar Status Bar
Related Scripts
install.sh- Install dependencies and run update.shtheme-switcher.sh- Apply theme configurations
Safety Features
- Automatic Backups: Creates timestamped backups before making changes
- Scoped Deletion: Only removes files explicitly managed by the repository
- Tracking Files: Maintains lists of managed files to prevent accidental deletion
- Strict Error Handling: Uses
set -euo pipefailto catch errors early
Notes
- The script can be run multiple times safely - it’s idempotent
- Backup directories accumulate over time; clean old backups manually
- Only top-level directories in
.configare synchronized individually - Files in
home/must be at the first level (not nested) - The script automatically detects its location and can be run from any directory
Source Code
View the full source:update.sh (141 lines)
Author: Fravelz