5.4 KiB
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 rolename
: name of display, this can be found withswaymsg -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 withswaymsg -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:
- The first to manage workspaces name
- 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 andfor_windows
for managing windows rules (float, size etc.)query
: witch windows to targetaction
: 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.