Last active
April 28, 2024 13:39
-
-
Save rpigott/a3efdc08fa4d5fd7df38d091ab5e8532 to your computer and use it in GitHub Desktop.
swaymsg zsh completions w/ sway command completion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#compdef swaymsg | |
typeset -A opt_args | |
__swaymsg() { | |
# Reuse socket path from command line if present | |
swaymsg ${(kv)opt_args[(I)-s|--socket]} "$@" 2>/dev/null | |
} | |
# _sway | |
# sway ipc {{{ | |
(( $+functions[_sway_ipc_types] )) || | |
_sway_ipc_types() { | |
local -a ipc_types=( | |
'get_workspaces:Get a list of workspaces and their status' | |
'get_inputs:Get a list of current inputs' | |
'get_outputs:Get the list of current outputs' | |
'get_tree:Get a JSON-encoded layout tree' | |
'get_seats:Get a list of all seats, their properties and assigned devices' | |
'get_marks:Get a JSON-encoded list of marks' | |
'get_bar_config:Get a JSON-encoded configuration for swaybar' | |
'get_version:Get JSON-encoded version information for the running instance of sway' | |
'get_binding_modes:Get a JSON-encoded list of currently configured binding modes' | |
'get_binding_state:Get the name of the current binding mode' | |
'get_config:Get a JSON-encoded copy of the current configuration' | |
'send_tick:Sends a tick event to all subscribed clients' | |
'subscribe:Subscribe to a list of event types' | |
) | |
_describe -t sway-ipc-type 'ipc type' ipc_types "$@" | |
} | |
# TODO: could be less clunky | |
(( $+functions[_sway_ipc_events] )) || | |
_sway_ipc_events() { | |
local -a ipc_events=( | |
'"workspace"[Sent whenever an event involving a workspace occurs]' | |
'"mode"[Sent whenever the binding mode changes]' | |
'"window"[Sent whenever an event involving a view occurs]' | |
'"barconfig_update"[Sent whenever a bar config changes]' | |
'"binding"[Sent when a configured binding is executed]' | |
'"shutdown"[Sent when the ipc shuts down because sway is exiting]' | |
'"tick"[Sent when an ipc client sends a send_tick message]' | |
'"bar_status_update"[Sent when the visibility of a bar should change]' | |
'"input"[Sent when something related to input devices changes]' | |
) | |
if (( $+compstate[quote] )); then | |
compset -P '\[' | |
compset -P '*,' | |
_values -s, "event" $ipc_events | |
fi | |
} | |
(( $+functions[_sway_app_ids] )) || | |
_sway_app_ids() { | |
local -a app_ids | |
if (( $+commands[jq] )); then | |
app_ids=(${(@f)"$(__swaymsg -rt get_tree | jq -rf =(<<-JQF | |
recurse(.nodes[]?, .floating_nodes[]?) | | |
select(.type == "con" or .type == "floating_con").app_id // empty | |
JQF | |
))"}) | |
fi | |
compadd "$@" -a app_ids | |
} | |
(( $+functions[_sway_titles] )) || | |
_sway_titles() { | |
local -a titles | |
if (( $+commands[jq] )); then | |
titles=(${${(@q-f)"$(__swaymsg -rt get_tree | jq -rf =(<<-JQF | |
recurse(.nodes[]?, .floating_nodes[]?) | | |
select(.type == "con" or .type == "floating_con").name // empty | |
JQF | |
))"}//\'/\"}) | |
fi | |
compadd "$@" -a titles | |
} | |
# }}} | |
# sway objects {{{ | |
# TODO: handle ctx_active device automagically? | |
local -a subcmd_{criteria,output,input,workspace,mark,seat,binding_mode,bar} | |
(( $+functions[_sway_criteria] )) || | |
_sway_criteria() { | |
# Only worth completing in quoted args. Manually insert "[ prefix, then complete. | |
if (( $+compstate[quote] )) && compset -P '\['; then | |
_values -s ' ' "attribute" \ | |
'app_id[Specific name of wayland applications]:app_id:{_sway_app_ids}' \ | |
'class[class of X11 applications]:' \ | |
'con_id[Unique id of containers]:' \ | |
'con_mark[Window marks]:mark:{_sway_marks}' \ | |
'floating[Match floating windows]' \ | |
'id[X11 window ID]:' \ | |
'instance[Window instance]:' \ | |
'pid[Window client pid]:' \ | |
'shell[Window shell]:shell:(xdg_shell xwayland)' \ | |
'tiling[Match tiling windows]' \ | |
'title[Window title]:title:{_sway_titles}' \ | |
'urgent[Urgent state of windows]:state:(first last latest newest oldest recent)' \ | |
'window_role[X11 WM_WINDOW_ROLE]:' \ | |
'window_type[EWMH _NET_WM_WINDOW_TYPE]:type:(normal dialog utility toolbar splash menu dropdown_menu popup_menu tooltip notification)' \ | |
'workspace[Workspace name for view]:workspace:{_sway_workspaces}' | |
fi | |
} | |
subcmd_criteria=(/$'[[][^\0]#[\\]]\0'/ ':_sway_criteria') | |
(( $+functions[_sway_outputs] )) || | |
_sway_outputs() { | |
local -a outputs | |
if (( $+commands[jq] )); then | |
outputs=( ${(@f)"$(__swaymsg -rt get_outputs | jq -r '.[].name')"} ) | |
else | |
__swaymsg -pt get_outputs | while read OUTPUT NAME OTHER; do | |
[[ $OUTPUT == "Output" ]] && outputs+="$NAME" | |
done | |
fi | |
compadd "$@" -a outputs | |
} | |
subcmd_output=(/$'[^\0]#\0'/ ':output:output device:_sway_outputs') | |
(( $+functions[_sway_inputs] )) || _sway_inputs() { | |
local -A inputs | |
if (( $+commands[jq] )); then | |
inputs=( ${(@f)"$(__swaymsg -rt get_inputs | jq -r '.[] | (.identifier, .name)' )"} ) | |
fi | |
local -a comps=( "${(@k)inputs//:/\\:}" ) | |
local -a descr=( "${(@v)inputs//:/\\:}" ) | |
_describe "input device" descr comps | |
} | |
subcmd_input=(/$'[^\0]#\0'/ ':input:input device:_sway_inputs') | |
(( $+functions[_sway_workspaces] )) || | |
_sway_workspaces() { | |
local -a workspaces | |
if (( $+commands[jq] )); then | |
workspaces=( ${(@f)"$(__swaymsg -rt get_workspaces | jq -r '.[].name')"} ) | |
else | |
__swaymsg -pt get_workspaces | while read WORK NAME OTHER; do | |
[[ $WORK == "Workspace" ]] && workspaces+="$NAME" | |
done | |
fi | |
compadd "$@" -a workspaces | |
} | |
subcmd_workspace=(/$'[^\0]#\0'/ ':workspace:workspace:_sway_workspaces') | |
(( $+functions[_sway_marks] )) || | |
_sway_marks() { | |
local -a marks | |
if (( $+commands[jq] )); then | |
marks=( ${(@f)"$(__swaymsg -rt get_marks | jq -r '.[]')"} ) | |
fi | |
compadd "$@" -a marks | |
} | |
subcmd_mark=( /$'[^\0]#\0'/ ':mark:mark:_sway_marks' ) | |
(( $+functions[_sway_seats] )) || | |
_sway_seats() { | |
local -a seats | |
if (( $+commands[jq] )); then | |
seats=( ${(@f)"$(__swaymsg -rt get_seats | jq -r '.[].name')"} ) | |
else | |
__swaymsg -pt get_seats | while read SEAT NAME; do | |
[[ $SEAT == "Seat:" ]] && seats+="$NAME" | |
done | |
fi | |
compadd "$@" -a seats | |
} | |
subcmd_seat=(/$'[^\0]#\0'/ ':seat:seat:_sway_seats') | |
(( $+functions[_sway_binding_modes] )) || | |
_sway_binding_modes() { | |
local -a modes | |
if (( $+commands[jq] )); then | |
modes=(${(@f)"$(__swaymsg -rt get_binding_modes | jq -r '.[]')"}) | |
fi | |
compadd "$@" -a modes | |
} | |
subcmd_binding_mode=(/$'[^\0]#\0'/ ':mode:binding mode:_sway_binding_modes') | |
(( $+functions[_sway_bars] )) || | |
_sway_bars() { | |
local -a bar_ids | |
if (( $+commands[jq] )); then | |
bar_ids=( ${(@f)"$(__swaymsg -rt get_bar_config | jq -r '.[]')"} ) | |
else | |
bar_ids=( "bar0" ) | |
fi | |
compadd "$@" -a bar_ids | |
} | |
subcmd_bar=(/$'[^\0]#\0'/ ":bar:bar id:_sway_bars") | |
# }}} | |
# _xkb | |
# FIXME: xkb include file paths / rule file | |
local XKB_DIR="/usr/share/X11/xkb" | |
local XKB_RULES="${XKB_DIR}/rules/${XKB_DEFAULT_RULES:-base}.xml" | |
# xkb_file {{{ | |
local -a subcmd_xkb_file=( /$'[^\0]#\0'/ ':_files -g "*.xkb"' ) | |
# }}} | |
# xkb_layout {{{ | |
local XSLT_XKB_LAYOUT # {{{ | |
read -d $'\0' XSLT_XKB_LAYOUT <<-\EOF | |
<?xml version="1.0"?> | |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exslt="http://exslt.org/common" version="1.0" extension-element-prefixes="exslt"> | |
<xsl:output omit-xml-declaration="yes" indent="no"/> | |
<xsl:template match="/"> | |
<xsl:for-each select="/xkbConfigRegistry/layoutList/layout"> | |
<xsl:for-each select="configItem"> | |
<xsl:call-template name="value-of-template"> | |
<xsl:with-param name="select" select="concat(name, '[', description, ']')"/> | |
</xsl:call-template> | |
<xsl:value-of select="' '"/> | |
</xsl:for-each> | |
</xsl:for-each> | |
</xsl:template> | |
<xsl:template name="value-of-template"> | |
<xsl:param name="select"/> | |
<xsl:value-of select="$select"/> | |
<xsl:for-each select="exslt:node-set($select)[position()>1]"> | |
<xsl:value-of select="' '"/> | |
<xsl:value-of select="."/> | |
</xsl:for-each> | |
</xsl:template> | |
</xsl:stylesheet> | |
EOF | |
# }}} | |
(( $+function[_xkb_layouts] )) || _xkb_layouts() { | |
local -a xkb_layouts | |
if (($+commands[xsltproc])) && [[ -f "$XKB_RULES" ]]; then | |
xkb_layouts=(${(@f)"$(xsltproc - "$XKB_RULES" <<< "$XSLT_XKB_LAYOUT")"}) | |
fi | |
if [[ ${#xkb_layouts} -gt 0 ]]; then | |
_values -s , 'xkb layout' $xkb_layouts | |
fi | |
} | |
local -a subcmd_xkb_layout=(/$'[^\0]#\0'/ ':xkb-layout:xkb layout:_xkb_layouts') | |
# }}} | |
# xkb_model {{{ | |
local XSLT_XKB_MODEL # {{{ | |
read -d $'\0' XSLT_XKB_MODEL <<-\EOF | |
<?xml version="1.0"?> | |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exslt="http://exslt.org/common" version="1.0" extension-element-prefixes="exslt"> | |
<xsl:output omit-xml-declaration="yes" indent="no"/> | |
<xsl:template match="/"> | |
<xsl:for-each select="/xkbConfigRegistry/modelList/model"> | |
<xsl:for-each select="configItem"> | |
<xsl:call-template name="value-of-template"> | |
<xsl:with-param name="select" select="concat(name, '[', description, ']')"/> | |
</xsl:call-template> | |
<xsl:value-of select="' '"/> | |
</xsl:for-each> | |
</xsl:for-each> | |
</xsl:template> | |
<xsl:template name="value-of-template"> | |
<xsl:param name="select"/> | |
<xsl:value-of select="$select"/> | |
<xsl:for-each select="exslt:node-set($select)[position()>1]"> | |
<xsl:value-of select="' '"/> | |
<xsl:value-of select="."/> | |
</xsl:for-each> | |
</xsl:template> | |
</xsl:stylesheet> | |
EOF | |
# }}} | |
(($+functions[_xkb_models])) || _xkb_models() { | |
local -a xkb_models | |
if (($+commands[xsltproc])) && [[ -f "$XKB_RULES" ]]; then | |
xkb_models=(${(@f)"$(xsltproc - "$XKB_RULES" <<< "$XSLT_XKB_MODEL")"}) | |
fi | |
_values 'xkb model' $xkb_models | |
} | |
local -a subcmd_xkb_model=(/$'[^\0]#\0'/ ':xkb-model:xkb model:_xkb_models') | |
# }}} | |
# xkb_options {{{ | |
local XSLT_XKB_OPTION_GROUP # {{{ | |
read -d $'\0' XSLT_XKB_OPTION_GROUP <<-\EOF | |
<?xml version="1.0"?> | |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exslt="http://exslt.org/common" version="1.0" extension-element-prefixes="exslt"> | |
<xsl:output omit-xml-declaration="yes" indent="no"/> | |
<xsl:template match="/"> | |
<xsl:for-each select="/xkbConfigRegistry/optionList/group"> | |
<xsl:for-each select="configItem"> | |
<xsl:call-template name="value-of-template"> | |
<xsl:with-param name="select" select="concat(name, ':', description)"/> | |
</xsl:call-template> | |
<xsl:value-of select="' '"/> | |
</xsl:for-each> | |
</xsl:for-each> | |
</xsl:template> | |
<xsl:template name="value-of-template"> | |
<xsl:param name="select"/> | |
<xsl:value-of select="$select"/> | |
<xsl:for-each select="exslt:node-set($select)[position()>1]"> | |
<xsl:value-of select="' '"/> | |
<xsl:value-of select="."/> | |
</xsl:for-each> | |
</xsl:template> | |
</xsl:stylesheet> | |
EOF | |
# }}} | |
local XSLT_XKB_OPTION # {{{ | |
read -d $'\0' XSLT_XKB_OPTION <<-\EOF | |
<?xml version="1.0"?> | |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exslt="http://exslt.org/common" version="1.0" extension-element-prefixes="exslt"> | |
<xsl:output omit-xml-declaration="yes" indent="no"/> | |
<xsl:template match="/"> | |
<xsl:for-each select="/xkbConfigRegistry/optionList/group"> | |
<xsl:for-each select="option/configItem"> | |
<xsl:call-template name="value-of-template"> | |
<xsl:with-param name="select" select="concat(name, ':', description)"/> | |
</xsl:call-template> | |
<xsl:value-of select="' '"/> | |
</xsl:for-each> | |
</xsl:for-each> | |
</xsl:template> | |
<xsl:template name="value-of-template"> | |
<xsl:param name="select"/> | |
<xsl:value-of select="$select"/> | |
<xsl:for-each select="exslt:node-set($select)[position()>1]"> | |
<xsl:value-of select="' '"/> | |
<xsl:value-of select="."/> | |
</xsl:for-each> | |
</xsl:template> | |
</xsl:stylesheet> | |
EOF | |
# }}} | |
(( $+functions[_xkb_options] )) || _xkb_options() { | |
local -a xkb_options xkb_option_groups | |
if (($+commands[xsltproc])) && [[ -f "$XKB_RULES" ]]; then | |
xkb_options=(${(@f)"$(xsltproc - "$XKB_RULES" <<< "$XSLT_XKB_OPTION")"}) | |
fi | |
compset -P '*,' | |
case "${words[$CURRENT]}" in | |
*:) | |
# complete an option | |
xkb_options=(${xkb_options[@]/:/\\:}) | |
_describe -t xkb-option 'xkb option' xkb_options "$@" | |
;; | |
*) | |
# complete a group name | |
_multi_parts ':' xkb_options | |
;; | |
esac | |
} | |
local -a subcmd_xkb_option=(/$'[^\0]#\0'/ ':xkb-option:xkb option:_xkb_options') | |
# }}} | |
# xkb_rules {{{ | |
(($+functions[_xkb_rules])) || _xkb_rules() { | |
setopt localoptions extendedglob | |
local -a xkb_rules=( "${XKB_DIR}/rules"/[[:lower:]]#(N:t) ) | |
_values 'xkb rules' $xkb_rules | |
} | |
local -a subcmd_xkb_rules=(/$'[^\0]#\0'/ ':xkb-rules:xkb rules:_xkb_rules') | |
# }}} | |
# xkb_variant {{{ | |
local XSLT_XKB_VARIANT # {{{ | |
read -d $'\0' XSLT_XKB_VARIANT <<-\EOF | |
<?xml version="1.0"?> | |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exslt="http://exslt.org/common" version="1.0" extension-element-prefixes="exslt"> | |
<xsl:output omit-xml-declaration="yes" indent="no"/> | |
<xsl:template match="/"> | |
<xsl:for-each select="/xkbConfigRegistry/layoutList/layout"> | |
<xsl:choose> | |
<xsl:when test="configItem/name='ACTIVE_LAYOUT'"> | |
<xsl:for-each select="variantList/variant"> | |
<xsl:call-template name="value-of-template"> | |
<xsl:with-param name="select" select="concat(configItem/name, '[', configItem/description, ']')"/> | |
</xsl:call-template> | |
<xsl:value-of select="' '"/> | |
</xsl:for-each> | |
</xsl:when> | |
</xsl:choose> | |
</xsl:for-each> | |
</xsl:template> | |
<xsl:template name="value-of-template"> | |
<xsl:param name="select"/> | |
<xsl:value-of select="$select"/> | |
<xsl:for-each select="exslt:node-set($select)[position()>1]"> | |
<xsl:value-of select="' '"/> | |
<xsl:value-of select="."/> | |
</xsl:for-each> | |
</xsl:template> | |
</xsl:stylesheet> | |
EOF | |
# }}} | |
(($+functions[_xkb_variants])) || _xkb_variants() { | |
local -a xkb_variants | |
local active_layout=us # FIXME: use real active layout | |
if (($+commands[xsltproc])) && [[ -f "$XKB_RULES" ]]; then | |
XSLT_XKB_VARIANT="${XSLT_XKB_VARIANT/ACTIVE_LAYOUT/$active_layout}" | |
xkb_variants=(${(@f)"$(xsltproc - "$XKB_RULES" <<< "$XSLT_XKB_VARIANT")"}) | |
fi | |
_values 'xkb variant' $xkb_variants | |
} | |
local -a subcmd_xkb_variant=(/$'[^\0]#\0'/ ':xkb-variant:xkb variant:_xkb_variants') | |
# }}} | |
# _swaycmd | |
# common subcmds {{{ | |
local -a reply subcmd_{string,number,direction,edt,files} | |
subcmd_string=(/$'[^\0]#\0'/ ':( )') | |
subcmd_number=(/$'[0-9]##\0'/ ':number:number:( )') | |
subcmd_ed=(/$'(enable|disable)\0'/ ':(enable disable)') | |
subcmd_edt=(/$'(enable|disable|toggle)\0'/ ':(enable disable toggle)') | |
subcmd_onoff=(/$'(on|off)\0'/ ':(on off)') | |
subcmd_dir=(/$'(left|right|up|down)\0'/ ':(left right up down)') | |
subcmd_files=(/$'[^\0]#\0'/ ':_files') | |
# }}} | |
# swaymsg border {{{ | |
local -a swaycmd_border | |
_regex_words arguments "border option" \ | |
'none:No border' \ | |
'normal:Border thickness \[n\] and a title bar:$subcmd_number' \ | |
'csd:Allow client-side-decorations' \ | |
'pixel:Border thickness \[n\]:$subcmd_number' \ | |
'toggle:Cycle through the available border styles' | |
swaycmd_border=("$reply[@]") | |
# }}} | |
# swaymsg focus {{{ | |
local -a swaycmd_focus_output swaycmd_focus swaycmd_focus_target swaycmd_focus_np | |
_swaycmd_focus_output() { | |
_alternative \ | |
'direction:direction:(up down left right next prev)' \ | |
'output:output:_sway_outputs' | |
} | |
swaycmd_focus_output=( | |
/$'[^\0]#\0'/ # match any word here, as it may be an output name | |
':_swaycmd_focus_output' | |
) | |
subcmd_focus_target=(/$'[^\0]#\0'/ ':(sibling)') | |
_regex_words arguments "focus option" \ | |
{up,down,left,right}':Move focus to the next container' \ | |
'next:Move focus to the next container in the curent layout:$subcmd_focus_target' \ | |
'prev:Move focus to the previous container in the current layout:$subcmd_focus_target' \ | |
'child:Move focus to the last-focused child of the focused container' \ | |
'parent:Move focus to the parent' \ | |
'tiling:Set focus to the last focused tiling container' \ | |
'floating:Set focus to the last focused floating container' \ | |
'mode_toggle:Move focus between the floating and tiled layers' \ | |
'output:Move focus between outputs:$swaycmd_focus_output' | |
swaycmd_focus=("$reply[@]") | |
# }}} | |
# swaymsg fullscreen {{{ | |
_regex_words arguments "global option" "global:Make the view fullscreen across all outputs" | |
local -a swaycmd_fullscreen=($subcmd_edt "$reply[@]") | |
# }}} | |
# swaymsg gaps {{{ | |
local -a swaycmd_gaps swaycmd_gaps1 swaycmd_gaps2 swaycmd_gaps3 | |
_regex_words arguments "gaps option" \ | |
'inner:Set gaps around each view' \ | |
'outer:Set gaps around each workspace' \ | |
'horizontal:Set outer gaps in the horizontal direction ' \ | |
'vertical:Set outer gaps in the vertical direction' \ | |
{top,right,bottom,left}':Set gaps per side' | |
swaycmd_gaps1=("$reply[@]") | |
_regex_words arguments "gaps option" \ | |
'all:Affect all workspaces' \ | |
'current:Affect the current workspace' | |
swaycmd_gaps2=( "$reply[@]" ) | |
swaycmd_gaps3=( | |
/$'(set|plus|minus)\0'/ ':(set plus minus)' $subcmd_number | |
) | |
swaycmd_gaps=( | |
$swaycmd_gaps1 | |
"(" $swaycmd_gaps2 "|" $subcmd_number ")" | |
$swaycmd_gaps3 | |
) | |
# }}} | |
# swaymsg inhibit_idle {{{ | |
local -a swaycmd_inhibit_idle | |
_regex_words arguments "inhibit_idle option" \ | |
'focus:Inhibit when the view is focused by any seat' \ | |
'fullscreen:Inhibit when the view is fullscreen and visible' \ | |
'open:Inhibit until the view is closed' \ | |
'visible:Inhibit while the view is visible on any output' \ | |
'none:Remove any existing idle inhibitor for the view' | |
swaycmd_inhibit_idle=("$reply[@]") | |
# }}} | |
# swaymsg layout {{{ | |
local -a swaycmd_layout swaycmd_layout_toggle | |
_regex_words arguments "layouts" "split" "tabbed" "stacking" "splitv" "splith" | |
swaycmd_layout_toggle=( | |
# No argument | |
"(" "|" | |
# Long form | |
"$reply[@]" "#" "|" | |
# Short form | |
/$'(split|all)\0'/ ':(split all)' | |
")" | |
) | |
_regex_words arguments "layout option" \ | |
'default' 'splith' 'splitv' 'stacking' 'tabbed' \ | |
'toggle:Cycle layout modes:$swaycmd_layout_toggle' | |
swaycmd_layout=("$reply[@]") | |
# }}} | |
# swaymsg move {{{ | |
local -a subcmd_px=( /$'px\0'/ ':(px)' ) | |
local -a subcmd_px_opt=( "(" /$'px\0'/ ':(px)' "|" ")" ) | |
local -a swaycmd_move_dir=( | |
$subcmd_dir | |
"(" $subcmd_number $subcmd_px "|" ")" | |
) | |
local cursor=cursor | |
(( $+functions[_swaycmd_sub_cursor] )) || | |
_swaycmd_sub_cursor() { | |
compadd "$@" $cursor | |
} | |
local -a swaycmd_move_position=( | |
"(" "|" /$'absolute\0'/ -'unset cursor' ':(absolute)' ")" | |
/$'position\0'/ ':(position)' | |
"(" /$'center\0'/ ':(center)' "|" | |
/$'(cursor|mouse|pointer)'/ ":_swaycmd_sub_cursor" "|" | |
$subcmd_number $subcmd_px_opt $subcmd_number $subcmd_px_opt ")" | |
) | |
_regex_words arguments "move option" \ | |
'mark:Move focused container to the specified mark:$subcmd_mark' \ | |
'workspace:Move focused container to the specified workspace:$subcmd_workspace' \ | |
'output:Move focused container to specified output:$subcmd_output' \ | |
'scratchpad:Move focused container to the scratchpad' | |
local -a swaycmd_move_container=( | |
"(" "|" /$'(container|window)\0'/ ':(container window)' ")" | |
/$'to\0'/ ':(to)' | |
"$reply[@]" | |
) | |
_swaycmd_move_workspace() { | |
_alternative \ | |
'direction:direction:(up down left right)' \ | |
':current:(current)' \ | |
'output:output:_sway_outputs' | |
} | |
local -a swaycmd_move_workspace=( | |
/$'workspace\0'/ ':(workspace)' /$'to\0'/ ':(to)' | |
/$'[^\0]#\0'/ ':_swaycmd_move_workspace' | |
) | |
local -a swaycmd_move=( | |
"(" | |
$swaycmd_move_dir "|" | |
$swaycmd_move_position "|" | |
$swaycmd_move_container "|" | |
$swaycmd_move_workspace "|" | |
")" | |
) | |
# }}} | |
# swaymsg rename workspace {{{ | |
local -a swaycmd_rename_workspace=( | |
/$'workspace\0'/ ':(workspace)' | |
"(" $subcmd_workspace "|" ")" | |
/$'to\0'/ ':(to)' | |
/$'[^\0]#\0'/ ':workspace:name:( )' | |
) | |
# }}} | |
# swaymsg resize {{{ | |
local -a subcmd_unit_opt=( | |
"(" "|" /$'(px|ppt)'/ ':(px ppt)' ")" | |
) | |
local -a swaycmd_resize=( | |
"(" "(" | |
/$'(shrink|grow)\0'/ ':(shrink grow set)' | |
/$'(width|height)\0'/ ':(width height)' | |
$subcmd_number $subcmd_unit_opt | |
")" "|" | |
/$'set\0'/ ':(set)' | |
/$'(width|height)\0'/ ':(width height)' $subcmd_number $subcmd_unit_opt | |
/$'(height)\0'/ ':(height)' $subcmd_number $subcmd_unit_opt ")" | |
) | |
# }}} | |
#swaymsg split {{{ | |
_regex_words arguments "split option" \ | |
'v*ertical:Split the current container vertically' \ | |
'h*orizontal:Split the current container horizontally' \ | |
't*oggle:Split opposite the parent container layout' | |
local -a swaycmd_split=("$reply[@]") | |
#}}} | |
# {{{ swaymsg swap | |
swaycmd_swap=( | |
/$'container\0'/ ':(container)' | |
/$'with\0'/ ':(with)' | |
"(" /$'(id|con_id)\0'/ ':(id con_id)' "|" | |
/$'mark\0'/ ':(mark)' "$subcmd_mark[@]" ")" | |
) | |
# }}} | |
# swaymsg assign{{{ | |
local -a swaycmd_assign swaycmd_assign_output | |
_swaycmd_assign_output() { | |
_alternative \ | |
':direction:(left right up down)' \ | |
':output:_sway_outputs' | |
} | |
swaycmd_assign_output=(/$'[^\0]#\0'/ ':_swaycmd_assign_output') | |
_regex_words arguments "assign option" \ | |
'workspace:Assign to specified workspace:$subcmd_workspace' \ | |
'output:Assign to specified output:$swaycmd_assign_output' | |
swaycmd_assign=( | |
$subcmd_criteria | |
# don't complete the arrow, just match it if it's there | |
"(" "|" /$'\u2192\0'/ ':( )' ")" | |
"$reply[@]" | |
) | |
# }}} | |
# swaymsg bindsym/bindcode/unbindsym/unbindcode {{{ | |
local -a swaycmd_{un,}bind{sym,code} | |
local -a bindsym_common=( | |
'--whole-window[Mouse only option. Enable mousekey binding anywhere]' | |
'--border[Mouse only option. Enable mousekey binding over window borders]' | |
'--exclude-titlebar[Mouse only option. Disable mousekey bindings over titlebars]' | |
'--release[Trigger binding on key release instead of key press]' | |
'--input-device=[Only trigger with the specified input device]' | |
'--locked[Allow this binding to trigger when a screen locker program is active]' | |
'--no-warn[Do not give the user a warning when overwriting a binding]' | |
) | |
(( $+functions[_swaycmd_bindsym] )) || | |
_swaycmd_bindsym() { | |
compset -n 2 | |
_arguments $bindsym_common \ | |
'--to-code[Translate the bound keysym to a keycode in the first configured layout]' \ | |
':key combo' \ | |
'*:::sway command:= _swaycmd' | |
} | |
(( $+functions[_swaycmd_bindcode] )) || | |
_swaycmd_bindcode() { | |
compset -n 2 | |
_arguments $bindsym_common \ | |
':key code' \ | |
'*:::sway command:= _swaycmd' | |
} | |
swaycmd_bindsym=(/$'[^\0]#\0'/ ':_swaycmd_bindsym' "#") | |
swaycmd_bindcode=(/$'[^\0]#\0'/ ':_swaycmd_bindcode' "#") | |
swaycmd_unbindsym=(/$'--[^\0]#\0'/ ':_swaycmd_bindsym' "#") | |
swaycmd_unbindcode=(/$'--[^\0]#\0'/ ':_swaycmd_bindcode' "#") | |
# }}} | |
# swaymsg bindswitch/unbindswitch {{{ | |
local -a swaycmd_{un,}bindswitch | |
(( $+functions[_swaycmd_bindswitch] )) || | |
_swaycmd_bindswitch() { | |
local -a switches=(lid tablet) states=(on off toggle) | |
compset -n 2 | |
_arguments \ | |
'--locked[Allow this binding to trigger when a screen locker program is active]' \ | |
'--no-warn[Do not give the user a warning when overwriting a binding]' \ | |
'--reload[Also execute the command when the config is reloaded]' \ | |
':switch state:_sep_parts switches \: states' \ | |
'*:::sway command:= _swaycmd' | |
} | |
swaycmd_bindswitch=( /$'[^\0]#\0'/ ':_swaycmd_bindswitch' "#") | |
swaycmd_unbindswitch=( /$'[^\0]#\0'/ ':_sep_parts switches \: states' ) | |
# }}} | |
# swaymsg client.<class> {{{ | |
# TODO: this | |
local -a classes=(focused focused_inactive unfocused urgent) | |
local -a client_classes=( client.${^classes} ) | |
(( $+functions[_swaycmd_client] )) || | |
_swaycmd_client() { | |
compset -n 2 | |
_arguments ':border' ':background' ':text' ':indicator' ':child_border' | |
} | |
local -a swaycmd_client=( | |
/"${(j.|.)client_classes})"$'\0'/ -repeat=0 | |
":( ${client_classes} )" | |
"(" /$'\\#[0-9a-fA-F]#\0'/ -'(( repeat++ < 5 ))' ':( )' ")" "#" | |
) | |
# }}} | |
# swaymsg default_border {{{ | |
_regex_words arguments "default_border option" \ | |
'normal:Standard border with a title bar:$subcmd_number' \ | |
'pixel:Standard border with given width:$subcmd_number' \ | |
'none:No border' | |
local -a swaycmd_default_border=( "$reply[@]" ) | |
# }}} | |
# swaymsg exec {{{ | |
local -a swaycmd_exec=( /$'[^\0]#\0'/ ':{compset -n 3; _normal}' "#") | |
# }}} | |
# swaymsg for_window {{{ | |
local -a swaycmd_for_window | |
(( $+functions[_swaycmd_for_window] )) || | |
_swaycmd_for_window() { | |
compset -n 2 | |
_arguments \ | |
':criteria:_sway_criteria' \ | |
'*:::sway command:= _swaycmd' | |
} | |
swaycmd_for_window=( /$'[^\0]#\0'/ ':_swaycmd_for_window' "#") | |
# }}} | |
# swaymsg hide_edge_borders {{{ | |
_regex_words arguments "option" \ | |
"none:Always show borders" \ | |
"vertical:Hide borders adjacent to vertical edges" \ | |
"horizontal:Hide borders adjacent to horizontal edges" \ | |
"both:Always hide borders" \ | |
"smart:Hide all borders when the workspace has only one visible child" \ | |
"smart_no_gaps:Hide all borders when the workspace has only one visible child and no gaps" | |
local -a swaycmd_hide_edge_borders=("$reply[@]") | |
# }}} | |
# swaymsg urgent {{{ | |
_regex_words arguments "option" \ | |
"enable:Manually set the urgent state for a window" \ | |
"disable:Manually unset the urgent state for a window" \ | |
"allow:Allow a window to set its own urgent state" \ | |
"deny:Disallow a window from setting its own urgent state" | |
local -a swaycmd_urgent=("$reply[@]") | |
# }}} | |
# swaymsg workspace {{{ | |
local -a swaycmd_workspace swaycmd_workspace_cmd | |
local -a subcmd_output_repeat=( $subcmd_output "#" ) | |
_regex_words arguments "workspace option" \ | |
'gaps:Specify gaps for a workspace when it is created:$swaycmd_gaps1' \ | |
'output:Specify which output to show the given workspace:$subcmd_output_repeat' | |
swaycmd_workspace_cmd=("$reply[@]") | |
_regex_words arguments "workspace option" \ | |
'prev:Previous workspace on any output' \ | |
'next:Next workspace on any output' \ | |
'prev_on_output:Previous workspace on this output' \ | |
'next_on_output:Next workspace on this output' \ | |
'back_and_forth:Switch to the previously focused workspace' | |
swaycmd_workspace=( | |
"(" | |
"$reply[@]" "|" | |
"(" | |
"(" "|" /$'--no-auto-back-and-forth\0'/ ':(--no-auto-back-and-forth)' ")" | |
"(" "|" /$'number\0'/ ':(number)' ")" | |
$subcmd_workspace | |
")" "|" | |
$subcmd_workspace "$swaycmd_workspace_output[@]" ")" | |
) | |
# }}} | |
# swaymsg floating_maximum_size/floating_minimum_size {{{ | |
local -a swaymcmd_floating_size=( | |
/$'[0-9]#\0'/ ':width:( )' | |
/$'x\0'/ ':(x)' | |
/$'[0-9]#\0'/ ':height:( )' | |
) | |
# }}} | |
# swaymsg focus_on_window_activation {{{ | |
_regex_words arguments "fowa option" \ | |
'urgent:Set the urgent state for the activated windows' \ | |
'focus:Set focus to the activated windows' \ | |
'smart:Set focus to the activated window if it is already visible' \ | |
'none:Do nothing' | |
local -a swaycmd_fowa=("$reply[@]") | |
# }}} | |
# swaymsg titlebar_padding {{{ | |
local -a swaycmd_titlebar_padding=( | |
/$'[0-9]#\0'/ ':horizontal:( )' | |
/$'[0-9]#\0'/ ':vertical:( )' | |
) | |
# }}} | |
# swaymsg floating_modifier {{{ | |
_regex_words arguments "floating_modifier option" \ | |
'normal:Left click to move windows, right click to resize' \ | |
'inverse:Left click to resize windows, right click to move' | |
local -a swaycmd_floating_modifier=( /$'[^\0]#\0'/ ':modifier:modifier:(( none\:"Disable floating modifiers" ))' "$reply[@]") | |
# }}} | |
# swaymsg input {{{ | |
local -a swaycmd_input | |
(( $+functions[_sway_input_spec] )) || _sway_input_spec() { | |
local -a input_types=( | |
touchpad pointer keyboard touch | |
tablet_tool tablet_pad switch | |
) | |
input_types=("type:${(@)^input_types}") | |
_alternative \ | |
':input device:_sway_inputs' \ | |
":device class:( $input_types )" | |
} | |
local -a subcmd_input_spec=( /$'[^\0]#\0'/ ':_sway_input_spec' ) | |
(( $+functions[_sway_input_layouts] )) || | |
_sway_input_layouts() { | |
local prefix=${words[(i)input]} | |
local device="$words[$prefix + 1]" | |
local -a layout_names | |
if (( $+commands[jq] )); then | |
layout_names=( | |
${(@f)"$( | |
__swaymsg -rt get_inputs | | |
jq -r ".[] | select(.identifier == \"$device\" or .name == \"$device\").xkb_layout_names[]" | |
)"} | |
) | |
fi | |
local -a descr=( "${(@)layout_names}" ) | |
local -a comps=( {0..${#layout_names}} ) | |
_describe 'layout index' descr comps | |
} | |
local -a subcmd_input_layout=(/$'[^\0]#\0'/ ':_sway_input_layouts') | |
_regex_words arguments "tool mode" "pen" "eraser" "brush" "pencil" "airbrush" | |
local -a subcmd_input_tool=("$reply[@]") | |
_regex_words arguments "event type" "absolute" "relative" | |
local -a subcmd_input_event_type=("$reply[@]") | |
local -a subcmd_input_tool_mode=("$subcmd_input_tool[@]" "$subcmd_input_event_type[@]") | |
_regex_words arguments "accel profile" "adaptive" "flat" | |
local -a subcmd_input_accel_profile=("$reply[@]") | |
_regex_words arguments "click method" "none" "button_areas" "clickfinger" | |
local -a subcmd_input_click_method=("$reply[@]") | |
_regex_words arguments "option" "enabled" "disabled" "disabled_on_external_mouse" | |
local -a subcmd_input_events=( | |
"(" "$reply[@]" "|" /$'toggle\0'/ ':(toggle)' "$reply[@]" "#" ")" | |
) | |
_regex_words arguments "scroll button" "disable" button{{1..3},8,9} | |
local -a subcmd_input_scroll_button=("$reply[@]") | |
_regex_words arguments "scroll method" "none" "two_finger" "edge" "on_button_down" | |
local -a subcmd_input_scroll_method=("$reply[@]") | |
_regex_words arguments "button map" "lrm:left-right-middle" "lmr:left-middle-right" | |
local -a subcmd_input_tap_button_map=("$reply[@]") | |
_regex_words input-command "input option" \ | |
'repeat_delay:Set the delay before repeating a held-down key in ms:$subcmd_number' \ | |
'repeat_rate:Set the key repeat rate in number of keypresses per second:$subcmd_number' \ | |
'xkb_file:Set all xkb configurations from a complete .xkb file:$subcmd_xkb_file' \ | |
'xkb_layout:Set the layout of the keyboard:$subcmd_xkb_layout' \ | |
'xkb_model:Set the model of the keyboard:$subcmd_xkb_model' \ | |
'xkb_options:Set extra xkb configuration options:$subcmd_xkb_option' \ | |
'xkb_rules:Set files or rules for keyboard mapping composition:$subcmd_xkb_rules' \ | |
'xkb_switch_layout:Switch the active keyboard layout by index:$subcmd_input_layout' \ | |
'xkb_variant:Set the keyboard variant:$subcmd_xkb_variant' \ | |
'tool_mode:Set the mode of a tablet tool:$subcmd_input_tool_mode' \ | |
'map_to_output:Map inputs from this device to specified output:$subcmd_output' \ | |
'map_to_region:Map inputs from this device to specified region' \ | |
'map_from_region:Ignore inputs from this device outside the specified region' \ | |
'accel_profile:Set the pointer acceleration profile:$subcmd_input_accel_profile' \ | |
'calibration_matrix:Set the calibration matrix' \ | |
'click_method:Set the click method:$subcmd_input_click_method' \ | |
'drag:Enable or disable tap-and-drag:$subcmd_ed' \ | |
'drag_lock:Enable or disable drag lock:$subcmd_ed' \ | |
'dwt:Enable or disable disable-while-typing:$subcmd_ed' \ | |
'events:Enable or disable send_events:$subcmd_input_events' \ | |
'left_handed:Enable or disable left handed mode:$subcmd_ed' \ | |
'middle_emulation:Enable or disable middle buttom emulation:$subcmd_ed' \ | |
'natural_scroll:Enable or diable natural (inverted) scrolling:$subcmd_ed' \ | |
'pointer_accel:Set the pointer acceleration' \ | |
'scroll_button:Set the button used for scroll_method on_button_down:$subcmd_input_scroll_button' \ | |
'scroll_factor:Set the scroll factor' \ | |
'scroll_method:Set the scroll method:$subcmd_input_scroll_method' \ | |
'tap:Enable or disable tap click:$subcmd_ed' \ | |
'tap_button_map:Set the button mapping for tap click:$subcmd_input_tap_button_map' | |
swaycmd_input=($subcmd_input_spec "$reply[@]") | |
# }}} | |
# swaymsg seat {{{ | |
local -a swaycmd_seat swaycmd_seat_cursor subcmd_tf swaycmd_idle_source | |
local -a swaycmd_keyboard_grouping subcmd_xcursor_theme swaycmd_cursor_constraint swaycmd_shortcuts_inhibitor | |
_regex_words arguments 'status' 'true' 'false' | |
subcmd_tf=("$reply[@]") | |
_regex_words arguments 'state' \ | |
'enable:Allow clients to capture the cursor' \ | |
'disable:Disallow clients to capture the cursor' \ | |
'escape:Escape the cursor from a client capture' | |
swaycmd_cursor_constraint=("$reply[@]") | |
_regex_words arguments 'cursor command' \ | |
'move:Move the cursor relative to the current position' \ | |
'set:Set the cursor position in absolute coordinates' \ | |
'press:Simulate pressing the mouse button' \ | |
'release:Simulate releasing the mouse button' | |
swaycmd_seat_cursor=("$reply[@]") | |
_regex_words arguments 'idle source' \ | |
'keyboard' 'pointer' 'touchpad' 'touch' 'tablet_pad' 'tablet_tool' 'switch' | |
swaycmd_idle_source=("$reply[@]") | |
_regex_words arguments 'keyboard grouping' \ | |
'none:Disable all keyboard grouping' \ | |
'smart:Sync the effective layout between keyboards by layout and repeat info' | |
swaycmd_keyboard_grouping=("$reply[@]") | |
_regex_words arguments 'inhibitor command' \ | |
'enable:Allow future inhibitors by default' \ | |
'disable:Disallow future inhibitors by default and disable active inhibitors' \ | |
'activate:Activate an existing inhibitor' \ | |
'deactivate:Deactivate an existing inhibitor' \ | |
'toggle:Toggle the state of an existing inhibitor' | |
swaycmd_shortcuts_inhibitor=("$reply[@]") | |
typeset -T XCURSORPATH xcursorpath | |
if [[ -z "$XCURSORPATH" ]]; then | |
XCURSORPATH="${XDG_DATA_HOME:-$HOME/.local/share}:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}" | |
xcursorpath=( ~/.icons "${(@)^xcursorpath}"/icons ) | |
fi | |
_regex_words arguments 'themes' default "${(@)^xcursorpath}"/*/cursors(N:h:t) | |
subcmd_xcursor_theme=("$reply[@]") | |
_regex_words arguments 'seat command' \ | |
'attach:Attach an input device to this seat by its input identifier:$subcmd_input' \ | |
'cursor:Modify the cursor:$swaycmd_seat_cursor:$swaycmd_seat_cursor' \ | |
'fallback:Set this seat ad the fallback seat:$subcmd_tf' \ | |
'idle_inhibit:Set the set of input event sources which can prevent the seat from becoming idle:$swaycmd_idle_source' \ | |
'idle_wake:Set the set of input event sources which can wake the seat from idle:$swaycmd_idle_source' \ | |
'keyboard_grouping:Set how keyboards in teh seat are grouped together:$swaycmd_keyboard_grouping' \ | |
'hide_cursor:Hide the cursor image after the specified timeout:$subcmd_number' \ | |
'pointer_constraint:Enable or disable the ability for clients to capture the cursor:$swaycmd_cursor_constraint' \ | |
'shortcuts_inhibitor:Enable or disable the ability of clients to inhibit keyboard shortcuts for the seat:$swaycmd_shortcuts_inhibitor' \ | |
'xcursor_theme:Override the default XCursor theme:$subcmd_xcursor_theme' | |
swaycmd_seat=( $subcmd_seat "$reply[@]" ) | |
# }}} | |
# swaymsg output {{{ | |
local -a swaycmd_output | |
local -a subcmd_color=(/$'[^\0]#\0'/ ':color:color:( )' ) | |
_regex_words arguments "scaling mode" "stretch" "fill" "fit" "center" "tile" | |
local -a subcmd_output_bg=( | |
"(" | |
$subcmd_files "$reply[@]" $subcmd_color "|" | |
$subcmd_color /$'solid_color\0'/ ':(solid_color)' | |
")" | |
) | |
_regex_words arguments "subpixel hint" "rgb" "bgr" "vrgb" "vbgr" "none" | |
local -a subcmd_output_subpixel_hint=("$reply[@]") | |
_regex_words arguments "scale filter" "linear" "nearest" "smart" | |
local -a subcmd_output_scale_filter=("$reply[@]") | |
_regex_words arguments "transform" "normal" "flipped" {flipped-,}{90,180,270} | |
local -a subcmd_output_transform=("$reply[@]") | |
_regex_words arguments "rotation direction" "clockwise" "anticlockwise" | |
subcmd_output_transform+=("$reply[@]") | |
# _regex_words arguments "option" "on" "off" | |
# local -a subcmd_output_dpms=("$reply[@]") | |
(( $+functions[_sway_output_modes] )) || _sway_output_modes() { | |
local prefix="${words[(i)output]}" | |
local output="${words[$prefix + 1]}" | |
local -a modes | |
if (( $+commands[jq] )); then | |
local query='.[] | select(.name == '"\"$output\""') | .modes[] | "\(.width)x\(.height)@\(.refresh / 1000)Hz"' | |
modes=( $(__swaymsg -rt get_outputs | jq -r $query) ) | |
fi | |
_multi_parts -i '@' modes | |
} | |
subcmd_output_modes=(/$'[^\0]#\0'/ ':modes:mode:_sway_output_modes') | |
_regex_words output-command "output option" \ | |
'mode:Configure the specified output to use the given mode:$subcmd_output_modes' \ | |
'res*olution:Configure the specified output to use the given mode:$subcmd_output_modes' \ | |
'pos*ition:Place the specified output at a specific position' \ | |
'scale:Scale the specified output'\ | |
'scale_filter:Set how lo-dpi applications are scaled:$subcmd_output_scale_filter' \ | |
'subpixel:Manually set subpixel hinting for the specified output:$subcmd_output_subpixel_hint' \ | |
{background,bg}':Set the background of the specified output:$subcmd_output_bg' \ | |
'transform:Transform the specified output:$subcmd_output_transform' \ | |
'disable:Disable the specified output' \ | |
'enable:Enable the specified output' \ | |
'toggle:Toggle the specified output' \ | |
'dpms:Enable or disable the specified output via DPMS:$subcmd_onoff' \ | |
'max_render_time:Enables delaying output rendering to reduce latency' \ | |
'adaptive_sync:Enable or disable adaptive sync on the output:$subcmd_onoff' | |
swaycmd_output=( $subcmd_output "$reply[@]" ) | |
# }}} | |
# swaymsg bar {{{ | |
local -a subcmd_bar_output=( $subcmd_output "#" ) | |
_regex_words arguments "bar state" "hide" "show" "toggle" | |
local -a subcmd_bar_hidden_state=("$reply[@]" $subcmd_bar_hidden_state) | |
_regex_words arguments "yes no" "yes" "no" | |
local -a subcmd_yn=("$reply[@]") | |
_regex_words arguments "bar position" "top" "bottom" | |
local -a subcmd_bar_position=("$reply[@]") | |
_regex_words arguments "bar mode" \ | |
"dock:Permanently visible" \ | |
"hide:Hidden unless the modifier key is pressed" \ | |
"invisible:Permanently hidden" \ | |
"overlay:Permanently visible on top of other windows" \ | |
"toggle:Switch between dock and hide" | |
local -a subcmd_bar_mode=("$reply[@]" $subcmd_bar_mode) | |
_regex_words bar-commands "bar option" \ | |
'binding_mode_indicator:Enable or disable the binding mode indicator:$subcmd_yn' \ | |
'font:Specify the font in pango font decsription format' \ | |
'gaps:Set gaps from the edge of the screen for the bar' \ | |
'height:Set the bar height. A height of 0 wil match the font size:$subcmd_number' \ | |
'hidden_state:Set the hidden state of the bar:$subcmd_bar_hidden_state' \ | |
'mode:Set the mode of the bar:$subcmd_bar_mode' \ | |
'modifier:Set the modifier key that shows a hidden bar' \ | |
'output:Restrict the bar to a certain output:$subcmd_bar_output' \ | |
'pango_markup:Enable or disable pango markup in status lines:$subcmd_ed' \ | |
'position:Set the position of the bar:$subcmd_bar_position' \ | |
'separator_symbol:Specify the separator symbol between blocks' \ | |
'wrap_scroll:Enable or disable wrapping when scrolling through workspaces:$subcmd_yn' \ | |
'workspace_buttons:Enable or disable workspace buttons:$subcmd_yn' \ | |
'workspace_min_width:Set the minimum width of workspace buttons:$subcmd_number' | |
swaycmd_bar=( $subcmd_bar "$reply[@]") | |
# }}} | |
# swaymsg <generic> {{{ | |
_regex_words arguments "option" "show" | |
local -a swaycmd_scratchpad=("$reply[@]") | |
_regex_words arguments "option" "yes" "no" "always" | |
local -a swaycmd_focus_follows_mouse=("$reply[@]") | |
_regex_words arguments "option" "yes" "no" "force" | |
local -a swaycmd_focus_wrapping=("$reply[@]") | |
_regex_words arguments "option" "on" "no_gaps" "off" | |
local -a swaycmd_smart_borders=("$reply[@]") | |
_regex_words arguments "option" "on" "off" | |
local -a swaycmd_smart_gaps=("$reply[@]") | |
_regex_words arguments "option" "output" "container" "none" | |
local -a swaycmd_mouse_warping=("$reply[@]") | |
_regex_words arguments "option" "smart" "ignore" "leave_fullscreen" | |
local -a swaycmd_popup_during_fullscreen=("$reply[@]") | |
_regex_words arguments "option" "yes" "no" | |
local -a swaycmd_show_marks=("$reply[@]") | |
_regex_words arguments "option" "set" "plus" "minus" | |
local -a swaycmd_opacity=("$reply[@]" $subcmd_number) | |
_regex_words arguments "option" "left" "center" "right" | |
local -a swaycmd_title_align=("$reply[@]") | |
# }}} | |
# swaymsg <command> {{{ | |
local -a swaycmd | |
_regex_words commands 'sway command' \ | |
'border:Set border style for the focused window:$swaycmd_border' \ | |
'exit:Exit sway and end your Wayland session' \ | |
'floating:Make focused view floating or non-floating:$subcmd_edt' \ | |
'focus:Set focus:$swaycmd_focus' \ | |
'fullscreen:Make focused view fullscreen or non-fullscreen:$swaycmd_fullscreen' \ | |
'gaps:Set workspace gaps:$swaycmd_gaps' \ | |
'inhibit_idle:Set or unset an idle inhibitor for the view:$swaycmd_inhibit_idle' \ | |
'layout:Set the layout mode for the focused container:$swaycmd_layout' \ | |
'move:Rearrange containers in workspaces and outputs:$swaycmd_move' \ | |
'reload:Reload the sway config file and apply any changes' \ | |
'rename:Rename workspaces:$swaycmd_rename_workspace' \ | |
'resize:Resize containers:$swaycmd_resize' \ | |
'scratchpad:Show windows from the scratchpad:$swaycmd_scratchpad' \ | |
'shortcuts_inhibitor:Enable or disable the ability of clients to inhibit keyboard shortcuts:$swaycmd_ed' \ | |
'split:Split the current container:$swaycmd_split' \ | |
'sticky:Stick a floating window to the current output:$subcmd_edt' \ | |
'swap:Swap the position and geometry of two containers:$swaycmd_swap' \ | |
'title_format:Set the window title format:$subcmd_string' \ | |
'assign:Assign views matching criteria to a workspace:$swaycmd_assign' \ | |
'bindsym:Bind key combo to execute the given sway command (by keysym):$swaycmd_bindsym' \ | |
'bindcode:Bind key combo to execute the given sway command (by keycode):$swaycmd_bindsym' \ | |
'bindswitch:Bind switch to execute the given sway command on state changes:$swaycmd_bindswitch' \ | |
'default_border:Set default border style for new windows:$swaycmd_default_border' \ | |
'default_floating_border:Set default border style for new floating windows:$swaycmd_default_border' \ | |
'exec:Execute a shell command with sh:$swaycmd_exec' \ | |
'exec_always:Like exec, but also execute after reload:$swaycmd_exec' \ | |
'floating_maximum_size:Set the maximum size of all floating windows:$swaycmd_floating_size' \ | |
'floating_minimum_size:Set the minimum size of all floating windows:$swaycmd_floating_size' \ | |
'floating_modifier:Set the modifier for manipulating floating windows:$swaycmd_floating_modifier' \ | |
'focus_follows_mouse:Set the focus behavior on mouse movement:$swaycmd_focus_follows_mouse' \ | |
'focus_on_window_activate:Set the behavior for when xwayland clients request activation:$swaycmd_fowa' \ | |
'focus_wrapping:Set focus wrapping behavior:$swaycmd_focus_wrapping' \ | |
'font:Set the font to use for title bars' \ | |
'force_display_urgency_hint:Set a timeout before clearing the urgency hint on a focused window' \ | |
'titlebar_border_thickness:Set the thickness of the titlebar border in pixels:$subcmd_number' \ | |
'titlebar_padding:Set the padding of text in the titlebar:$swaycmd_titlebar_padding' \ | |
'for_window:Set a list of commands to run whenever a window matching criteria appear:$swaycmd_for_window' \ | |
'hide_edge_borders:Hide window borders adjacent to the screen edges:$swaycmd_hide_edge_borders' \ | |
'input:Configure input devices:$swaycmd_input' \ | |
'seat:Configure seats:$swaycmd_seat' \ | |
'kill:Close a window and its children' \ | |
'smart_borders:Set smart borders:$swaycmd_smart_borders' \ | |
'smart_gaps:Set smart gaps:$subcmd_onoff' \ | |
'mark:Add or remove marks:$swaycmd_mark' \ | |
'mode:Switch mode:$subcmd_binding_mode' \ | |
'mouse_warping:Set cursor behavior on focus change:$swaycmd_mouse_warping' \ | |
'no_focus:Prevent windows matching criteria from being focused on creation:$subcmd_criteria' \ | |
'output:Configure output devices:$swaycmd_output' \ | |
'popup_during_fullscreen:Set popup behavior for fullscreen views:$swaycmd_popup_during_fullscreen' \ | |
'set:Set variables to use in future commands' \ | |
'show_marks:Display marks in window borders' \ | |
'opacity:Adjust window opacity:$swaycmd_opacity' \ | |
'tiling_drag:Enable or disable tiling drag:$subcmd_edt' \ | |
'tiling_drag_threshold:Set tiling drag threshold:$subcmd_number' \ | |
'title_align:Set the title alignment:$swaycmd_title_align' \ | |
'unbindswitch:Remove a switch binding:$swaycmd_unbindswitch' \ | |
'unbindsym:Remove a keysym binding:$swaycmd_unbindsym' \ | |
'unbindcode:Remove a keycode binding:$swaycmd_unbindcode' \ | |
'unmark:Remove a mark:$subcmd_mark' \ | |
'urgent:Set or unset a window urgent state:$swaycmd_urgent' \ | |
'workspace:Switch workspaces:$swaycmd_workspace' \ | |
'workspace_auto_back_and_forth:Allow repeating a workspace switch command:$swaycmd_workspace_auto_back_and_forth' \ | |
'workspace_layout:Set the default layout for new workspaces:$swaycmd_workspace_layout' \ | |
'bar:Configure status bars:$swaycmd_bar' | |
swaycmd=( | |
/$'[^\0]#\0'/ | |
"(" $subcmd_criteria "|" ")" | |
"$reply[@]" | |
) | |
_regex_arguments _swaycmd "$swaycmd[@]" | |
# }}} | |
# _swaymsg | |
(( $+functions[_swaymsg_payload] )) || | |
_swaymsg_payload() { | |
case ${(Lv)opt_args[(I)-t|--type]:-command} in | |
"subscribe") | |
_sway_ipc_events | |
;; | |
"command") | |
_swaycmd | |
;; | |
"get_bar_config") | |
(( $CURRENT == 2 )) && _sway_bars | |
;; | |
*) | |
_message "no arguments" | |
;; | |
esac | |
} | |
_arguments -S -s\ | |
'(-h --help)'{-h,--help}'[Show help message and quit]' \ | |
'(-v --version)'{-v,--version}'[Print the version (of swaymsg) and quit]' \ | |
'(-m --monitor)'{-m,--monitor}'[Monitor for responses until killed instead of exiting after the first response]' \ | |
'(-p --pretty)'{-p,--pretty}'[Use raw output even when not using a tty]' \ | |
'(-q --quiet)'{-q,--quiet}'[Send the IPC message but do not print the response from sway]' \ | |
'(-r --raw)'{-r,--raw}'[Use raw output even if using a tty]' \ | |
'(-s --socket)'{-s,--socket=}'[Use the specified socket path]:socket:_files -g "*(=)"' \ | |
'(-t --type)'{-t,--type=}'[Specify the type of IPC message]:ipc type:_sway_ipc_types' \ | |
'*::sway command:= _swaymsg_payload' | |
# vim: set fdm=marker: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks it has been very useful