Overview
Thetheme-switcher.sh script provides an interactive theme switcher for Sway using Rofi. It displays available themes with wallpaper previews and applies comprehensive theme changes including Kitty terminal colors, Waybar styling, Rofi colors, Sway window decorations, and wallpapers.
Themes are stored in
~/.config/themes/ with each theme in its own directory containing configuration files and wallpapers.Location
Usage
Interactive Mode
Direct Application
Name of the theme directory in
~/.config/themes/ to apply directly (skips Rofi selection)What It Does
Step-by-Step Execution
-
Theme Discovery
- Scans
~/.config/themes/for theme directories - Looks for wallpaper previews (
.jpg,.png,.webp) - Builds Rofi menu with theme names and preview icons
- Scans
-
Theme Selection
- Displays interactive Rofi menu (if no theme specified)
- Shows wallpaper preview thumbnails for each theme
- Uses custom Rofi theme:
~/.config/rofi/styles/_core/theme-switcher.rasi
-
Backup Creation
- Creates timestamped backups of existing configurations
- Format:
original.bak-YYYYMMDD-HHMMSS - Backs up before each component is modified
-
Kitty Configuration
- Copies theme’s
kitty/directory to~/.config/kitty - Applies color scheme and terminal styling
- Copies theme’s
-
Waybar Configuration
- Copies
colors.cssandstyle.cssto~/.config/waybar - Converts Hyprland-specific config to Sway format
- Generates
config-sway.jsoncwith module replacements:hyprland/workspaces→sway/workspaceshyprland/window→sway/window- Special workspace toggle →
kitty -e btop
- Copies
-
Sway Window Theme
- Applies
sway/theme.conffor window decorations - Sets border colors, title bar colors, and fonts
- Applies
-
Rofi Color Palette
- Uses theme’s
rofi-style/_core/palette.rasiif available - Otherwise, auto-generates from
sway/theme.confvariables:- Extracts
$bg,$fg,$active,$inactivecolors - Extracts font configuration
- Creates
~/.config/rofi/styles/_core/palette.rasi
- Extracts
- Uses theme’s
-
Wallpaper Application
- Finds wallpaper file (
wallpaper.jpg,.png, or.webp) - Saves path to
~/.config/sway/wallpaper - Kills existing
swaybgprocess - Launches new
swaybgwith selected wallpaper
- Finds wallpaper file (
-
Service Reloads
- Restarts Waybar with new configuration
- Reloads Sway to apply theme changes
- Sends desktop notification on completion
Theme Structure
Each theme directory should follow this structure:Required Files
Theme wallpaper image. At least one format must be present.
Optional Files
Kitty terminal configuration files. Entire directory is copied to
~/.config/kitty.Waybar color definitions (CSS variables).
Waybar styling and layout.
Waybar module configuration. Automatically converted from Hyprland to Sway format.
Sway window decoration theme with color variables:
$bg- Background color$fg- Foreground color$active- Active window color$inactive- Inactive window colorfont- Font definition
Custom Rofi color palette. If not provided, auto-generated from
sway/theme.conf.Sway Theme Configuration Format
Examplesway/theme.conf:
Auto-Generated Rofi Palette
When no custom Rofi palette is provided, the script generates one from Sway theme variables:Current Theme Tracking
The currently active theme is saved to:Notifications
The script sends desktop notifications usingnotify-send:
Success
Errors
Error Handling
Themes Directory Missing
Rofi Not Found
sudo pacman -S rofi
No Themes Available
Theme Not Found
No Wallpaper
wallpaper.jpg, wallpaper.png, or wallpaper.webp file.
Missing swaybg
sudo pacman -S swaybg
Exit Codes
- 0: Success (theme applied) or cancelled by user
- 1: Error (missing dependencies, theme not found, or no wallpaper)
Examples
Interactive Theme Selection
Apply Specific Theme
Keybinding in Sway
Add to~/.config/sway/config:
Create New Theme
Backup Management
Backups are created with timestamps. Clean old backups periodically:Integration with Waybar
Example Waybar module for theme switching:Related Scripts
wallpaper-switcher.sh- Change wallpaper without changing themeupdate.sh- Sync configuration files from repository
Dependencies
rofi- Application launcher (for theme selection UI)swaybg- Wallpaper utility (for applying wallpapers)swaymsg- Sway IPC tool (for reloading configuration)waybar- Status bar (optional, for bar theming)notify-send- Desktop notifications (optional)
Notes
- Themes are applied system-wide and persist across reboots
- The script is designed to work with both Hyprland and Sway themes (auto-converts)
- Backups are created automatically to prevent data loss
- Rofi theme preview requires icons support (
-show-iconsflag) - The script uses
set -euo pipefailfor strict error handling
Source Code
View the full source:.config/rofi/scripts/theme-switcher.sh (186 lines)
Author: Fravelz