Suivant: , Précédent: , Monter: Services du dossier personnel   [Table des matières][Index]


13.3.15 Sway window manager

Le module (gnu home services sway) fournit home-sway-service-type, un service personnel permettant de configurer le gestionnaire de fenêtre Sway pour Wayland de manière déclarative.

Voici un exemple de service et sa configuration que vous pouvez ajouter au champ services de votre home-environment :

(service home-sway-service-type
         (sway-configuration
          (gestures
           '((swipe:3:down . "move to scratchpad")
             (swipe:3:up   . "scratchpad show")))
          (outputs
           (list (sway-output
                  (identifier '*)
                  (background (file-append sway
                                           "\
/share/backgrounds/sway/Sway_Wallpaper_Blue_1920x1080.png")))))))

L’exemple ci-dessus décrit une configuration Sway dans laquelle

Remarque : This home service only sets up the configuration file and profile packages for Sway. It does not start Sway in any way. If you want to do so, you might be interested in using greetd-wlgreet-sway-session instead.

The procedure sway-configuration->file defined below can be used to provide the value for the optional sway-configuration field of greetd-wlgreet-sway-session.

Procedure :sway-configuration->file config

This procedure takes one argument config, which must be a sway-configuration record (defined below), and returns a file-like object representing the serialized configuration.

Variable :home-sway-service-type

This is a home service type to set up Sway. It takes care of:

  • providing a ~/.config/sway/config file,
  • adding Sway-related packages to your profile.
Data Type :sway-configuration

This configuration record describes the Sway configuration (see sway(5)). Available fields are:

variables (default: %sway-default-variables)

The value of this field is an association list in which keys are symbols and values are either strings, G-expressions or file-like objects (voir G-Expressions).

Example:

(variables `((mod . "Mod4") ; string
             (term ; file-append
              . ,(file-append foot "/bin/foot"))
             (Term ; G-expression
              . ,#~(string-append #$foot "/bin/foot"))))

Remarque : Default keybindings assume the existence of variables named $mod, $left, $right, $up and $down. If you choose not to define these variables, make sure to remove keybindings referring to them.

keybindings (default: %sway-default-keybindings)

This field describes keybindings for the default mode. The value is an association list: keys are symbols and values are either strings or G-expressions.

The following snippet launches the terminal when pressing $mod+t and $mod+Shift+t (assuming that a variable $term is defined):

`(($mod+t . ,#~(string-append "exec " #$foot "/bin/foot"))
  ($mod+Shift+t . "exec $term"))
gestures (default: %sway-default-gestures)

Similar to the previous field, but for finger-gestures.

The following snippet allows to navigate through workspaces by swiping right and left with three fingers:

'((swipe:3:right . "workspace next_on_output")
  (swipe:3:left  . "workspace prev_on_output"))
packages (default: %sway-default-packages)

This field describes a list of packages to add to the user profile. At the moment, the default value only adds sway to the profile.

inputs (par défaut : '())

List of sway-input configuration records (described below).

outputs (default: '())

List of sway-output configuration records (described below).

bar (optional sway-bar record)

Optional sway-bar record (described below) to configure a Sway bar.

modes (default: %sway-default-modes)

List of sway-mode records (described below) to add modes to the Sway configuration. The default value %sway-default-modes adds the “resize” mode of the default Sway configuration (as described below).

startup+reload-programs (default: '())

Programs to execute at startup time and after every configuration reload. The value of this field is a list of strings, G-expressions or file-like objects (voir G-Expressions).

startup-programs (default: %sway-default-startup-programs)

Programs to execute at startup time. As above, values of this field are a list of strings, G-expressions or file-like objects.

The default value, %sway-default-startup-programs, executes swayidle in order to lock the screen after 5 minutes of inactivity (displaying a background distributed with Sway) and turn the screen off after 10 minutes of inactivity.

extra-content (default: '())

Lines to add to the configuration file. The value of this field is a list of strings or G-expressions.

Data Type :sway-input

sway-input records describe input blocks (see sway-input(5)). For example, the following snippet makes all keyboards use a French layout, in which capslock has been remapped to ctrl:

(sway-input (identifier "type:keyboard")
            (layout
              (keyboard-layout "fr" #:options '("ctrl:nocaps"))))

Available fields for sway-input configuration records are:

identifier (default: '*)

Identifier of the input. The field accepts symbols and strings. If the identifier is a symbol, it is inserted as is; if it is a string, it will be quoted in the configuration file.

layout (optional <keyboard-layout> record)

Keyboard specific option. Field specifying the layout to use for the input. The value must be a <keyboard-layout> record (voir Disposition du clavier).

Remarque : (gnu home services sway) does not re-export the keyboard-layout procedure.

disable-while-typing (optional boolean)

If #t (resp. #f) enables (resp. disables) the “disable while typing” option for this input.

disable-while-trackpointing (optional boolean)

If #t (resp. #f), enables (resp. disables) the “disable while track-pointing” option for this input.

tap (optional boolean)

Enables or disables the “tap” option, which allows clicking by tapping on a touchpad.

extra-content (default: '())

Lines to add to the input block. The value of this field must a list whose elements are either strings or G-expressions.

Data Type :sway-output

sway-output records describe Sway outputs (see sway-output(5)). Available fields are:

identifier (default: '*)

Identifier of the monitor. The field accepts symbols and strings. If the identifier is a symbol, it is inserted as is; if it is a string, it will be quoted in the configuration file.

resolution (optional string)

This string defines the resolution of the monitor.

position (optional)

The (optional) value of this field must be a point. Example:

(position
 (point (x 1920)
        (y 0)))
background (optional)

The value of this field describes what wallpaper to use on this output. The field accepts the following types of values:

  • a string,
  • a G-expression,
  • a file-like object,
  • a pair. The first argument of this pair must be a string, a G-expression or a file-like object. The second element describes how the wallpaper will be displayed. It must be a symbol among stretch, fill, fit, center and tile.

    If the second element is not specified (i.e. when the value is not a pair), the fill mode will be used.

Remarque : In order to use an SVG file, you must have librsvg in your profile (e.g. by adding it in the packages field of sway-configuration).

extra-content (default: '())

List defining additional lines to add to the output configuration block. Elements of the list must be either strings or G-expressions.

Data Type :sway-border-color
border

Color of the border.

background

Color of the background.

text

Color of the text.

Data Type :sway-color
background (optional string)

Background color of the bar.

statusline (optional string)

Text color of the status line.

focused-background (optional string)

Background color of the bar on the currently focused monitor.

focused-statusline (optional string)

Text color of the statusline on the currently focused monitor.

focused-workspace (optional sway-border-color)

Color scheme for focused workspaces.

active-workspace (optional sway-border-color)

Color scheme for active workspaces.

inactive-workspace (optional sway-border-color)

Color scheme for inactive workspaces.

urgent-workspace (optional sway-border-color)

Color scheme for workspaces containing “urgent windows”.

binding-mode (optional sway-border-color)

Color scheme for the binding mode indicator.

Data Type :sway-bar

Describes the Sway bar (see sway-bar(5)).

identifier (default: 'bar0)

Identifier of the bar. The value must be a symbol.

position (optional)

Specify the position of the bar. Accepted values are 'top or 'bottom.

hidden-state (optional)

Specify the appearance of the bar when it is hidden. Accepted values are 'hide or 'show.

binding-mode-indicator (optional)

Boolean enabling or disabling the binding mode indicator.

colors (optional)

An optional sway-color configuration record.

status-command (optional)

This field accept strings, G-expressions and executable file-like values. The default value is a command (string) that prints the date and time every second.

Each line printed on stdout by this command (or script) will be displayed on the status area of the bar.

Below are a few examples using:

mouse-bindings (default: '())

This field accepts an associative list. Keys are integers describing mouse events. Values can either be strings or G-expressions.

The module (gnu home services sway) exports constants %ev-code-mouse-left, %ev-code-mouse-right and %ev-code-mouse-scroll-click whose values are integers corresponding to left, right and scroll click respectively. For example, with (mouse-bindings `((,%ev-code-mouse-left . "exec $term"))), left clicks in the status bar open the terminal (assuming that the variable $term is bound to a terminal).

Data Type :sway-mode

Describes a Sway mode (see sway(5)). For example, the following snippet defines the resize mode of the default Sway configuration:

(sway-mode
 (mode-name "resize")
 (keybindings
  '(($left  . "resize shrink width 10px")
    ($right . "resize grow width 10px")
    ($down  . "resize grow height 10px")
    ($up    . "resize shrink height 10px")
    (Left   . "resize shrink width 10px")
    (Right  . "resize grow width 10px")
    (Down   . "resize grow height 10px")
    (Up     . "resize shrink height 10px")
    (Return . "mode \"default\"")
    (Escape . "mode \"default\""))))
mode-name (default: "default")

Name of the mode. This field accepts strings.

keybindings (default: '())

This field describes keybindings. The value is an association list: keys are symbols and values are either strings or G-expressions, as above.

mouse-bindings (default: '())

Ditto, but keys are mouse events (integers). Constants %ev-code-mouse-* described above can be used as helpers to define mouse bindings.


Suivant: Networking Home Services, Précédent: Media Home Services, Monter: Services du dossier personnel   [Table des matières][Index]