-
Notifications
You must be signed in to change notification settings - Fork 5
Sway Dispatcher
Almarhoon Ibraheem edited this page Jun 24, 2024
·
8 revisions
The swayipc dispatcher
module provides various functions to send commands to Sway. This module utilizes the Sway IPC protocol to send commands to Sway for different types of tasks as focusing workspaces, changing active outputs, updating monitors, and more.
- Description: Sets the default container layout for tiled containers.
- Parameters:
- orientation:
SWAY-ORIENTATION-HORIZONTAL
,SWAY-ORIENTATION-VERTICAL
,SWAY-ORIENTATION-AUTO
- orientation:
- Example
(sway-default-orientation SWAY-ORIENTATION-HORIZONTAL)
- Description: Includes another configuration file from path (not scheme file).
- Parameters:
- file-path: string
- Example
(sway-include "/path/to/config/file.conf")
- Description: Executes custom background command. Default is swaybg.
- Parameters:
- command: string
- Example
(sway-swaybg-command "custom_bg_command")
- Description: Executes custom command for swaynag. Default is swaynag.
- Parameters:
- command: string
- Example
(sway-swaynag-command "custom_nag_command")
- Description: Specifies the initial layout for new containers in an empty workspace.
- Parameters:
- layout:
SWAY-LAYOUT-DEFAULT
,SWAY-LAYOUT-STACKING
,SWAY-LAYOUT-TABBED
- layout:
- Example
(sway-workspace-layout SWAY-LAYOUT-TABBED)
- Description: Enables or disables Xwayland support, which allows X11 applications to be used.
- Parameters:
- option:
SWAY-XWAYLAND-ENABLE
,SWAY-XWAYLAND-DISABLE
,SWAY-XWAYLAND-FORCE
- option:
- Example
(sway-xwayland SWAY-XWAYLAND-ENABLE)
- Description: Enables or disables Xwayland support, which allows X11 applications to be used.
- Parameters:
- option:
SWAY-BORDER-NONE
,SWAY-BORDER-NORMAL
,SWAY-BORDER-CSD
,SWAY-BORDER-PIXEL
- thickness: int
- option:
- Example
(sway-border SWAY-BORDER-NORMAL 2)
- Description: Cycles through the available border styles.
- Example
(sway-border-toggle)
- Description: Exit sway and end your Wayland session.
- Example
(sway-exit)
- Description: Make focused view floating, non-floating, or the opposite of what it is now.
- Parameters:
- layout:
SWAY-FLOATING-ENABLED
,SWAY-FLOATING-DISABLED
,SWAY-FLOATING-TOGGLE
- layout:
- Example
(sway-floating SWAY-FLOATING-ENABLED)
- Description: Moves focus to the container that matches the specified criteria.
- Parameters:
- criteria: A criteria string, use
(sway-criteria)
to build one.
- criteria: A criteria string, use
- Example
(sway-focus-container-criteria (sway-criteria #:title "Firefox"))
- Description: Moves focus to the next container in the specified direction.
- Parameters:
- direction:
SWAY-DIRECTION-UP
,SWAY-DIRECTION-RIGHT
,SWAY-DIRECTION-DOWN
,SWAY-DIRECTION-LEFT
- direction:
- Example
(sway-focus-container SWAY-DIRECTION-RIGHT)
- Description: Moves focus to the previous or next container in the current layout.
- Parameters:
- sibling:
SWAY-SIBLING-NEXT
,SWAY-SIBLING-PREV
- sibling:
- Example
(sway-focus-container-sibling SWAY-SIBLING-NEXT)
- Description: Moves focus to the last-focused child of the focused container.
- Example
(sway-focus-container-child)
- Description: Moves focus to the last-focused parent of the focused container.
- Example
(sway-focus-container-parent)
- Description: Moves focus to the next output in the specified direction.
- Parameters:
- direction:
SWAY-DIRECTION-UP
,SWAY-DIRECTION-RIGHT
,SWAY-DIRECTION-DOWN
,SWAY-DIRECTION-LEFT
- direction:
- Example
(sway-focus-output-direction SWAY-DIRECTION-UP)
- Description: Moves focus to the named output.
- Parameters:
- name: string, output name
- Example
(sway-focus-output-name "HDMI-A-1")
- Description: Sets focus to the last focused tiling container.
- Example
(sway-focus-container-tiling)
- Description: Sets focus to the last focused floating container.
- Example
(sway-focus-container-floating)
- Description: Makes focused view fullscreen, non-fullscreen, or the opposite of current.
- Parameters:
- option:
SWAY-FULLSCREEN-ENABLED
,SWAY-FULLSCREEN-DISABLED
,SWAY-FULLSCREEN-TOGGLE
- global:
#t
,#f
- option:
- Example
(sway-fullscreen SWAY-FULLSCREEN-TOGGLE #:global #t)
- Description: Changes the inner or outer gaps for either all workspaces or the current workspace.
- Parameters:
- option:
SWAY-GAPS-OPTION-INNER
,SWAY-GAPS-OPTION-OUTER
,SWAY-GAPS-OPTION-HORIZONTAL
,SWAY-GAPS-OPTION-VERTICAL
,SWAY-GAPS-OPTION-TOP
,SWAY-GAPS-OPTION-RIGHT
,SWAY-GAPS-OPTION-BOTTOM
,SWAY-GAPS-OPTION-LEFT
- workspace:
SWAY-GAPS-WORKSPACE-ALL
,SWAY-GAPS-WORKSPACE-CURRENT
,SWAY-GAPS-WORKSPACE-SET
,SWAY-GAPS-WORKSPACE-PLUS
,SWAY-GAPS-WORKSPACE-MINUS
,SWAY-GAPS-WORKSPACE-TOGGLE
- amount: amount of gap (number)
- option:
- Example
(sway-gaps SWAY-GAPS-OPTION-INNER SWAY-GAPS-WORKSPACE-CURRENT 10)
- Description: Set/unset an idle inhibitor for the view.
- Parameters:
- option:
SWAY-INHIBIT-IDLE-FOCUS
,SWAY-INHIBIT-IDLE-FULLSCREEN
,SWAY-INHIBIT-IDLE-OPEN
,SWAY-INHIBIT-IDLE-NONE
,SWAY-INHIBIT-IDLE-VISIBLE
- option:
- Example
(sway-inhibit-idle SWAY-INHIBIT-IDLE-FOCUS)
- Description: Set/unset an idle inhibitor for the view.
- Parameters:
- option:
SWAY-LAYOUT-DEFAULT
,SWAY-LAYOUT-SPLITH
,SWAY-LAYOUT-SPLITV, SWAY-LAYOUT-STACKING
,SWAY-LAYOUT-TABBED
- option:
- Example
(sway-layout SWAY-LAYOUT-SPLITH)
- Description: Cycles the layout mode of the focused container though a preset list of layouts.
- Parameters:
- option:
SWAY-LAYOUT-TOGGLE-ALL
,SWAY-LAYOUT-TOGGLE-SPLIT
- option:
- Example
(sway-layout-toggle #:option SWAY-LAYOUT-TOGGLE-ALL)
- Description: Moves the focused container in the direction specified.
- Parameters:
- direction:
SWAY-DIRECTION-UP
,SWAY-DIRECTION-RIGHT
,SWAY-DIRECTION-DOWN
,SWAY-DIRECTION-LEFT
- amount: int
- direction:
- Example
(sway-move-container SWAY-DIRECTION-RIGHT #:amount 50)
- Description: Moves the focused container to the specified position in the workspace.
- Parameters:
- x: int
- y: int
- Example
(sway-move-container-absolute-position 100 100)
- Description: Moves the focused container to be centered on the workspace.
- Example
(sway-move-container-absolute-center)
- Description: Moves the focused container to be centered on the cursor.
- Example
(sway-move-container-cursor)
- Description: Moves the focused container to the specified mark.
- Parameters:
- mark: string
- Example
(sway-move-container-to-mark "my_mark")
- Description: Moves the focused container to the workspace name
- Parameters:
- workspace:
workspace name
,SWAY-WORKSPACE-PREVIOUS
,SWAY-WORKSPACE-NEXT
- workspace:
- Example
(sway-move-container-to-workspace SWAY-WORKSPACE-PREVIOUS)
- Description: Moves the focused container to the output in the specified direction.
- Parameters:
- direction:
SWAY-DIRECTION-UP
,SWAY-DIRECTION-RIGHT
,SWAY-DIRECTION-DOWN
,SWAY-DIRECTION-LEFT
- direction:
- Example
(sway-move-container-to-output SWAY-DIRECTION-UP)
- Description: Moves the focused container to the scratchpad.
- Parameters: None
- Example
(sway-move-container-to-scratchpad)
- Description: Moves the focused workspace to the specified output id|name|direction.
- Parameters:
- output: Output name, output id,
SWAY-OUTPUT-CURRENT
,SWAY-OUTPUT-UP
,SWAY-OUTPUT-RIGHT
,SWAY-OUTPUT-DOWN
,SWAY-OUTPUT-LEFT
.
- output: Output name, output id,
- Example
(sway-move-workspace-to-output "HDMI-1")
- Description: A no operation command that can be used to override default behavior.
- Parameters:
- comment: Optional comment argument, ignored but logged for debugging purposes.
- Example
(sway-nop #:comment "This does nothing")
- Description: Reloads the sway config file and applies any changes.
- Parameters: None
- Example
(sway-reload)
- Description: Renames a workspace from old-name to new-name.
- Parameters:
- old-name: Old workspace name (string).
- new-name: New workspace name (string).
- Example
(sway-rename-workspace "1" "Development")
- Description: Renames the current workspace to new-name.
- Parameters:
- new-name: New workspace name (string).
- Example
(sway-rename-current-workspace "Development")
- Description: Resizes the currently focused container by amount, specified in pixels or percentage points.
- Parameters:
- type:
SWAY-RESIZE-TYPE-SHRINK
,SWAY-RESIZE-TYPE-GROW-WIDTH
,SWAY-RESIZE-TYPE-GROW-HEIGHT
. - amount: Number.
- unit:
SWAY-SIZE-UNIT-PX
,SWAY-SIZE-UNIT-PPT
(optional).
- type:
- Example
(sway-resize SWAY-RESIZE-TYPE-SHRINK 10 #:unit SWAY-SIZE-UNIT-PX)
- Description: Sets the height of the container to height, specified in pixels or percentage points.
- Parameters:
- amount: Number.
- unit:
SWAY-SIZE-UNIT-PX
,SWAY-SIZE-UNIT-PPT
(optional).
- Example
(sway-resize-height 20 #:unit SWAY-SIZE-UNIT-PX)
- Description: Sets the width of the container to width, specified in pixels or percentage points.
- Parameters:
- amount: Number.
- unit:
SWAY-SIZE-UNIT-PX
,SWAY-SIZE-UNIT-PPT
(optional).
- Example
(sway-resize-width 30 #:unit SWAY-SIZE-UNIT-PX)
- Description: Shows a window from the scratchpad.
- Parameters: None
- Example
(sway-show-scratchpad)
- Description: Enables or disables the ability of clients to inhibit keyboard shortcuts for a view.
- Parameters:
- flag: Boolean (
#t
for enable,#f
for disable).
- flag: Boolean (
- Example
(sway-shortcuts-inhibitor #t)
- Description: Splits the current container vertically or horizontally. When none is specified, the effect of a previous split is undone.
- Parameters:
- option:
SWAY-SPLIT-VERTICAL
,SWAY-SPLIT-HORIZONTAL
,SWAY-SPLIT-NONE
,SWAY-SPLIT-TOGGLE
.
- option:
- Example
(sway-split-container SWAY-SPLIT-VERTICAL)
- Description: Sticks a floating window to the current output so that it shows up on all workspaces.
- Parameters:
- flag:
SWAY-STICKY-ENABLE
,SWAY-STICKY-DISABLE
,SWAY-STICKY-TOGGLE
.
- flag:
- Example
(sway-sticky SWAY-STICKY-TOGGLE)
- Description: Swaps the position, geometry, and fullscreen status of focused container with another target container.
- Parameters:
- type:
SWAY-SWAY-CONTAINER-TYPE-ID
,SWAY-SWAY-CONTAINER-TYPE-CONTAINER-ID
,SWAY-SWAY-CONTAINER-TYPE-MARK
. - arg: Argument passed (based on selected type).
- type:
- Example
(sway-swap-container SWAY-SWAY-CONTAINER-TYPE-ID 123)
- Description: Sets the format of window titles.
- Parameters:
- format: A string that can use some placeholders to display windows title format:
-
%title
: The title supplied by the window. -
%app_id
: The wayland app ID (applicable to wayland windows only). -
%class
: The X11 classname (applicable to xwayland windows only). -
%instance
: The X11 instance (applicable to xwayland windows only). -
%shell
: The protocol the window is using (typically xwayland or xdg_shell).
-
- format: A string that can use some placeholders to display windows title format:
- Example
(sway-title-format "%title - %app_id")
- Description: Assigns views matching criteria to workspace.
- Parameters:
- criteria: A criteria string, use
(sway-criteria)
to build one. - workspace: Workspace name.
- criteria: A criteria string, use
- Example
(sway-assign-to-workspace (sway-criteria #:title "Firefox") "2")
- Description: Assigns views matching criteria to output.
- Parameters:
- criteria: A criteria string, use
(sway-criteria)
to build one. - output: Output name.
- criteria: A criteria string, use
- Example
(sway-assign-to-output (sway-criteria #:title "Firefox") "HDMI-1")
- Description: Binds key combo to execute the sway command when pressed.
- Parameters:
- key: A string that represents the key to bind.
- command: A string sway command to execute option receiving the key.
- whole-window: Affect the region in which the mouse bindings can be triggered (optional).
- border: Affect the region in which the mouse bindings can be triggered (optional).
- exclude-titlebar: Affect the region in which the mouse bindings can be triggered (optional).
- release: Command is executed when the key combo is released (optional).
- locked: Run command also when screen locking program is active (optional).
- to-code: The keysyms will be translated into the corresponding keycodes, making them layout independent (optional).
- input-device: The binding will only be executed for specified input device (optional).
- no-warn: Silence sway warning when overriding a keybinding (optional).
- no-repeat: The command will not be run repeatedly when the key is held (optional).
- inhibited: Keyboard shortcuts run also when inhibitor is active for the currently focused window (optional).
- group: Binding will only be available for specified group (optional).
- Example
(sway-bindsym "Mod4+Return" "exec alacritty" #:no-warn #t)
- Description: For binding with key/button codes instead of key/button names.
- Parameters:
- code: A string that represents the code to bind.
- command: A string sway command to execute option receiving the key.
- whole-window: Affect the region in which the mouse bindings can be triggered (optional).
- border: Affect the region in which the mouse bindings can be triggered (optional).
- exclude-titlebar: Affect the region in which the mouse bindings can be triggered (optional).
- release: Command is executed when the key combo is released (optional).
- locked: Run command also when screen locking program is active (optional).
- input-device: The binding will only be executed for specified input device (optional).
- no-warn: Silence sway warning when overriding a keybinding (optional).
- no-repeat: The command will not be run repeatedly when the key is held (optional).
- inhibited: Keyboard shortcuts run also when inhibitor is active for the currently focused window (optional).
- group: Binding will only be available for specified group (optional).
- Example
(sway-bindcode "38" "exec alacritty" #:no-warn #t)
- Description: Binds switch to execute the sway command on state changes.
- Parameters:
- switch: Supported switches are lid (laptop lid) and tablet (tablet mode) switches.
- state: Valid values are on, off, and toggle.
- command: A string sway command to execute option receiving the key.
- locked: Run command also when screen locking program is active (optional).
- no-warn: Silence sway warning when overriding a keybinding (optional).
- Example
(sway-bindswitch "tablet:on" "exec echo 'tablet mode enabled'")