Skip to content

Latest commit

 

History

History
289 lines (210 loc) · 7.52 KB

File metadata and controls

289 lines (210 loc) · 7.52 KB

Sway Desktop Environment - Ansible Setup

This repository contains an Ansible playbook to automate the installation and configuration of a Sway desktop environment with wpgtk theming integration.

Features

  • Automated installation of Sway window manager and related components
  • wpgtk integration for cohesive theming across all applications
  • Pre-configured dotfiles following best practices
  • Multi-distribution support: Fedora, Ubuntu/Debian, Arch Linux, openSUSE, and Fedora rpm-ostree variants (e.g., Silverblue, Kinoite)
  • Modular role-based design for easy customization

Components Installed

  • Sway: Tiling Wayland compositor
  • Waybar: Highly customizable status bar
  • Ulauncher: Application launcher with wpgtk theme
  • Kitty: Modern, GPU-accelerated terminal emulator
  • wpgtk: Wallpaper and theming tool for consistent color schemes
  • Additional utilities: swaylock, swayidle, grim, slurp, wf-recorder, and more

Prerequisites

  • A supported Linux distribution (Fedora, Fedora rpm-ostree variants, Ubuntu/Debian, Arch Linux, or openSUSE)
  • Python 3 installed
  • Ansible installed (version 2.9 or higher)
  • Sudo privileges for installing system packages

Installation

1. Clone this repository

git clone https://github.com/GeoDerp/My-Sway-Build.git
cd My-Sway-Build

2. Install Ansible (if not already installed)

Fedora:

sudo dnf install ansible -y

Ubuntu/Debian:

sudo apt update
sudo apt install ansible -y

Arch Linux:

sudo pacman -S ansible

openSUSE:

sudo zypper install ansible

Fedora rpm-ostree variants (Silverblue/Kinoite/etc.):

sudo rpm-ostree install ansible

After installing Ansible, install the required collections:

ansible-galaxy collection install -r requirements.yml

3. Run the playbook

Run the complete setup:

ansible-playbook playbook.yml

Or run specific roles using tags:

# Install only system dependencies
ansible-playbook playbook.yml --tags dependencies

# Install only wpgtk
ansible-playbook playbook.yml --tags wpgtk

# Install Sway window manager
ansible-playbook playbook.yml --tags sway

# Install Waybar
ansible-playbook playbook.yml --tags waybar

# Install Ulauncher
ansible-playbook playbook.yml --tags ulauncher

# Install Kitty terminal
ansible-playbook playbook.yml --tags kitty

Configuration

wpgtk Setup

After installation, you need to add wallpapers and apply a theme:

  1. Add a wallpaper:

    wpg -a /path/to/your/wallpaper.jpg
  2. Apply the theme:

    wpg -s /path/to/your/wallpaper.jpg
  3. The following configs are registered as wpgtk templates:

    • ~/.config/sway/config
    • ~/.config/waybar/style.css
    • ~/.config/kitty/kitty.conf
    • ~/.config/ulauncher/user-themes/wpgtk-theme/theme.css

How wpgtk templates work: Config files use template variables like {color0}, {color15}, {active}, {inactive}, etc. When you run wpg -s, wpgtk replaces these with actual hex colors from your chosen wallpaper's color scheme. This ensures consistent theming across all applications.

Starting Sway

To start Sway, simply run:

sway

Or add it to your login shell for auto-start (modify ~/.bash_profile):

if [ -z "$WAYLAND_DISPLAY" ] && [ "$XDG_VTNR" -eq 1 ]; then
    exec sway
fi

Key Bindings

See the Sway config for complete keybinding documentation.

Essential Shortcuts

  • Alt + Return: Open terminal
  • Alt + d: Launch application launcher (ulauncher)
  • Alt + Shift + q: Kill focused window
  • Alt + Shift + r: Reload Sway configuration
  • Super + l: Lock screen
  • Alt + Shift + c: Open Firefox
  • Alt + Shift + w: Change wallpaper (random)
  • Alt + 1-0: Switch to workspace 1-10
  • Alt + Shift + 1-0: Move window to workspace 1-10
  • Print: Take screenshot
  • Print + Shift: Take screenshot of selected region

Project Structure

.
├── ansible.cfg              # Ansible configuration
├── inventory.yml            # Inventory file
├── playbook.yml            # Main playbook
├── roles/                  # Ansible roles
│   ├── system_dependencies/
│   ├── wpgtk/
│   ├── sway/
│   ├── waybar/
│   ├── ulauncher/
│   └── kitty/
├── Backup-.configs/        # Dotfiles and configurations
│   ├── sway/
│   ├── waybar/
│   ├── ulauncher/
│   └── kitty/
└── README.md

Customization

Modifying Configurations

All configuration files are stored in the Backup-.configs/ directory:

  • Sway: Backup-.configs/sway/config
  • Waybar: Backup-.configs/waybar/config and style.css
  • Ulauncher: Backup-.configs/ulauncher/user-themes/wpgtk-theme/
  • Kitty: Backup-.configs/kitty/kitty.conf

After modifying these files, run the playbook again to apply changes:

ansible-playbook playbook.yml

Adding New Roles

To add a new component:

  1. Create a new role directory: mkdir -p roles/myapp/{tasks,defaults,files}
  2. Add tasks in roles/myapp/tasks/main.yml
  3. Add the role to playbook.yml
  4. Run the playbook with the new role

Troubleshooting

wpgtk not found

If wpgtk is not in your PATH after installation, add this to your ~/.bashrc:

export PATH="$HOME/.local/bin:$PATH"

Sway won't start

Check the logs:

journalctl -xe | grep sway

Common issues:

  • Missing graphics drivers
  • Incorrect display configuration
  • Conflicting desktop environments

Waybar not displaying

Ensure waybar is installed and the config is valid:

waybar -c ~/.config/waybar/config -s ~/.config/waybar/style.css

wpgtk theme not applying

If colors aren't updating after adding a wallpaper:

  1. Check if wpgtk is available:

    wpg --version
  2. Manually reapply the theme:

    wpg -s /path/to/your/wallpaper.jpg
  3. Verify template files are registered:

    wpg -t

Swaylock shows blank/black screen

This usually happens when the wallpaper variables aren't properly expanded. Ensure:

  • You've applied a wpgtk theme at least once
  • The lock wallpaper exists: ls ~/.config/wpg/wallpapers/*.lock.png
  • Run the playbook again to regenerate configs: ansible-playbook playbook.yml

Kitty terminal shows "invalid color name" error

This occurs when wpgtk hasn't processed the template yet. The config uses wpgtk template variables (e.g., {color0}, {color15}) that need to be replaced with actual hex colors.

Solution:

  1. Apply a wpgtk theme to process all templates: wpg -s /path/to/wallpaper.jpg
  2. This will replace template variables with hex colors from your wallpaper's color scheme
  3. If the error persists, check that kitty.conf is registered as a wpgtk template: wpg -t | grep kitty

The Ansible playbook automatically registers kitty.conf as a wpgtk template, so colors will update whenever you change themes.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Sway - Tiling Wayland compositor
  • wpgtk - Wallpaper and theming tool
  • Waybar - Highly customizable Wayland bar
  • Ulauncher - Application launcher

Author

GeoDerp

Support

If you encounter any issues or have questions, please open an issue on GitHub.