Ansible Role to configure Sway
Find a file
2024-09-11 21:37:10 +02:00
defaults/main Add mode resoze keybinding 2022-12-13 09:53:54 +01:00
files fix: update dbus nvironment variable to make portal work 2024-09-11 21:37:10 +02:00
meta Add metadata 2022-11-23 00:38:34 +01:00
tasks rework Sway validation 2022-11-30 09:51:02 +01:00
templates Adapt keybinding to new sway config checker 2022-11-30 09:57:24 +01:00
README.md Adapt keybinding to new sway config checker 2022-11-30 09:57:24 +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:
      bg: '/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, format: <option>: <value>

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 one variables: sway_keys_variables.

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

Licence

This script is released under le MIT licence

Copyright © 2021 Yorick Barbanneau

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.