1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-11-23 23:34:12 +03:00
kakoune/rc/windowing/detection.kak
DixiE 0048e9f488 Support focus Within Sway WM
While Wayland offers nothing general to help us support `focus` on all
window managers, WM-specific implementations are generally possible.
Sway is a tiling window manager that mimics i3, and has a reasonably
powerful CLI that can help us achieve this.

In addition to supporting `focus` for Sway, this change paves the way
for additional WM-specific Wayland functionality by adding a detection
step to wayland.kak, in a similar fashion to detection.kak.
2022-06-02 10:57:28 +01:00

42 lines
1.6 KiB
Plaintext

# Attempt to detect the windowing environment we're operating in
#
# We try to load modules from the windowing_modules str-list option in order,
# stopping when one of the modules loads successfully. This ensures that only
# a single module is loaded by default.
#
# On load each module must attempt to detect the environment it's appropriate
# for, and if the environment isn't appropriate it must fail with an error.
# In addition, each module must check for the length of the windowing_modules
# str-list option defined below, and must /not/ check for an appropriate
# environment if the list is empty. An example of this test:
#
# evaluate-commands %sh{
# [ -z "${kak_opt_windowing_modules}" ] || [ -n "$TMUX" ] || echo 'fail tmux not detected'
# }
#
# Each module is expected to define at least two aliases:
# * terminal - create a new terminal with sensible defaults
# * focus - focus the specified client, defaulting to the current client
#
declare-option -docstring \
"Ordered list of windowing modules to try and load. An empty list disables
both automatic module loading and environment detection, enabling complete
manual control of the module loading." \
str-list windowing_modules 'tmux' 'screen' 'kitty' 'iterm' 'sway' 'wayland' 'x11'
hook -group windowing global KakBegin .* %{
evaluate-commands %sh{
set -- ${kak_opt_windowing_modules}
if [ $# -gt 0 ]; then
echo 'try %{ '
while [ $# -gt 1 ]; do
echo "require-module ${1} } catch %{ "
shift
done
echo "require-module ${1} }"
fi
}
}