Ansible Role to configure Sway
Find a file
2022-11-19 17:13:13 +01:00
defaults/main Avoid validation problem fot keybinding file 2022-11-19 17:13:13 +01:00
files Add variables templates 2022-11-18 23:18:33 +01:00
tasks Put startup file in right place 2022-11-19 17:06:05 +01:00
templates Avoid validation problem fot keybinding file 2022-11-19 17:13:13 +01:00
README.md Avoid validation problem fot keybinding file 2022-11-19 17:13:13 +01:00

Sway Ansible role

Role to configure Sway window manager

Variables

This role have multiples variables for managing all configurations, all variables are initalized to reproduce default configuration.

There is no bar configured by this role because it is out of his scope. A futur role will be created for installing and configuring Waybar.

Packages

sway_packages list packages to install.

variables

sway_variables contains a list of variable needed for configuration files like $term or $menu

sway_variables:
 - name: '$term'
   value: 'foot'
 - name: '$menu' 
   value: 'dmenu_path | dmenu | xargs swaymsg exec --'

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

Keybinding require two variables: sway_keys_variables and sway_keybindings. sway_keys_variables defined variables for keybinding. Because configuration file checking throw an error if the first argument of bindsym contains a variable not defined is the file (because 10-variables.config is not included when testing)

sway_keys_variables:
 - name: '$left'
   value: 'h'
 - name: '$down'
   value: 'j'
 - name: '$up'
   value: 'k'
 - name: '$right'
   value: 'l'
 - name: '$mod'
   value: 'Mod4'
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