Ansible Role to configure Sway
Find a file
2022-11-18 23:22:12 +01:00
defaults/main Add variables templates 2022-11-18 23:18:33 +01:00
files Add variables templates 2022-11-18 23:18:33 +01:00
tasks Add variables templates 2022-11-18 23:18:33 +01:00
templates Variable name correction in workspace template 2022-11-18 23:22:12 +01:00
README.md First commit 2022-11-17 22:49:38 +01:00

Sway Ansible role

Role to configure Sway window manager

Variables

This role have multiples variables for managing all configurations

output

Manage displays and options

sway_outputs:
  - id: 'all'
    name: '*'
    options:
      - option: 'bg'
        value: '/usr/share/backgrounds/sway/sway_wallpaper_blue_1920x1080.png fill'

This example reproduce default beaviour:

  • id: display id, useful for (future) kanshi configuration role
  • name: name of display, this can be found with swaymsg -t get_outputs
  • options: list of options

Input

Manage input configuration

sway_inputs:
  - name: '*'
    options:
      - option: 'xkb_layout'
        value: 'us'
      - option: 'xkb_variant'
        value: 'altgr-intl'
  • name: name of input, can be found with swaymsg -t get_inputs
  • options: list of options

Keybinding

Manage keybinding

sway_keybindings:
  - mode: 'normal'
    bindings:
      - bindsym: '$mod+Return'
        action: 'exec $term'
      - bindsym: '$mod+Shift+q'
        action: 'kill'
  # ...
  - mode: 'resize'
    bindings:
      - bindsym: '$left'
        action: 'resize shrink width 10 px or 10 ppt'
      - bindsym: '$down'
        action: 'resize grow height 10 px or 10 ppt'
  # ...

You can define different modes, normal mode is mandatory, others are optionnals. This example reflect the default configuration with normal and resize modes. bindings contains a list of keyboard shortcuts and actions

theme configuration

This part is divided in two parts, one for theme options, one for colors

sway_theme_parameters:
  default_orientation: 'auto'
  workspace_layout: 'default'
  # ...

sway_theme_colors:
  focused:
    border: '#4c7899'
    backgound: '#385579'
    text: '#ffffff'
    indicator: '#2efef4'
    child_border: '#285577'
  focused_inactive:
    # ...

theme_parameters contains a list of key:value, each key represent a configuration parameter, value represent ... his value.

theme_colors represent a list of client classes, each classe contains list of colors. Check sway manual with man 5 sway.

Workspaces

Like theming, there is two list for two puposes:

  1. The first to manage workspaces name
  2. The second to manage assign and rules:
sway_workspaces:
  1: '1'
  2: '2'
  3: '3'
  # ...
sway_rules:
  - verb: 'assign'
    query: '[app_id="^firefox$"]'
    action: 3
  - verb: 'assign'
    query: '[app_id="KeePassXC$"]'
    action: 3
  # ...
  - verb: 'for_window'
    query: '[app_id="org.pwmt.zathura"]'
    action: 'floating enable'
  - verb: 'for_window'
    query: '[app_id="^launcher$"]'
    action: 'floating enable, resize set 800px 400px'
  # ...

sway_workspace represent a list of workspaces defined by a key that represent the keyboard key to press with $mod to access this workspace and a value that represent the workspace name.

sway_rules reprensents the list of rules for managing windows :

  • verb: type of rule - assign to assign a program to a specific workspace and for_windows for managing windows rules (float, size etc.)
  • query: witch windows to target
  • action: what you want to do with window

Sway manual can be useful : man 5 sway