2019-03-13 21:15:59 +03:00
|
|
|
# x11
|
|
|
|
|
|
|
|
provide-module x11 %{
|
|
|
|
|
2020-07-05 05:02:59 +03:00
|
|
|
# ensure that we're running in the right environment
|
|
|
|
evaluate-commands %sh{
|
2020-07-06 14:55:54 +03:00
|
|
|
[ -z "${kak_opt_windowing_modules}" ] || [ -n "$DISPLAY" ] || echo 'fail DISPLAY is not set'
|
2020-07-05 05:02:59 +03:00
|
|
|
}
|
|
|
|
|
2018-04-19 20:28:32 +03:00
|
|
|
# termcmd should be set such as the next argument is the whole
|
2014-04-10 22:40:52 +04:00
|
|
|
# command line to execute
|
2017-11-03 10:34:41 +03:00
|
|
|
declare-option -docstring %{shell command run to spawn a new terminal
|
2018-04-19 20:28:32 +03:00
|
|
|
A shell command is appended to the one set in this option at runtime} \
|
2017-05-16 14:35:43 +03:00
|
|
|
str termcmd %sh{
|
2017-06-08 20:02:44 +03:00
|
|
|
for termcmd in 'alacritty -e sh -c' \
|
2018-06-19 10:38:15 +03:00
|
|
|
'kitty sh -c' \
|
2017-06-08 20:02:44 +03:00
|
|
|
'termite -e ' \
|
2015-11-06 10:14:50 +03:00
|
|
|
'urxvt -e sh -c' \
|
|
|
|
'rxvt -e sh -c' \
|
2019-06-07 22:16:49 +03:00
|
|
|
'st -e sh -c' \
|
2015-11-06 10:14:50 +03:00
|
|
|
'xterm -e sh -c' \
|
|
|
|
'roxterm -e sh -c' \
|
|
|
|
'mintty -e sh -c' \
|
2017-07-25 11:26:52 +03:00
|
|
|
'sakura -x ' \
|
2015-11-06 10:14:50 +03:00
|
|
|
'gnome-terminal -e ' \
|
2019-03-06 12:58:57 +03:00
|
|
|
'xfce4-terminal -e ' \
|
|
|
|
'konsole -e '; do
|
2015-11-06 10:14:50 +03:00
|
|
|
terminal=${termcmd%% *}
|
2017-05-16 15:18:45 +03:00
|
|
|
if command -v $terminal >/dev/null 2>&1; then
|
2018-05-07 00:29:52 +03:00
|
|
|
printf %s\\n "$termcmd"
|
2015-11-06 10:14:50 +03:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
done
|
2012-12-26 20:52:17 +04:00
|
|
|
}
|
|
|
|
|
2018-12-21 20:14:28 +03:00
|
|
|
define-command x11-terminal -params 1.. -shell-completion -docstring '
|
|
|
|
x11-terminal <program> [<arguments>]: create a new terminal as an x11 window
|
|
|
|
The program passed as argument will be executed in the new terminal' \
|
2018-12-02 15:59:45 +03:00
|
|
|
%{
|
2020-01-13 07:23:35 +03:00
|
|
|
evaluate-commands -save-regs 'a' %{
|
|
|
|
set-register a %arg{@}
|
|
|
|
evaluate-commands %sh{
|
|
|
|
if [ -z "${kak_opt_termcmd}" ]; then
|
|
|
|
echo "fail 'termcmd option is not set'"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
setsid ${kak_opt_termcmd} "$kak_quoted_reg_a" < /dev/null > /dev/null 2>&1 &
|
|
|
|
}
|
2018-12-02 15:59:45 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
define-command x11-focus -params ..1 -client-completion -docstring '
|
|
|
|
x11-focus [<kakoune_client>]: focus a given client''s window
|
|
|
|
If no client is passed, then the current client is used' \
|
|
|
|
%{
|
|
|
|
evaluate-commands %sh{
|
2016-10-11 10:03:41 +03:00
|
|
|
if [ $# -eq 1 ]; then
|
2018-12-02 15:59:45 +03:00
|
|
|
printf "evaluate-commands -client '%s' focus" "$1"
|
2015-11-18 01:25:33 +03:00
|
|
|
else
|
|
|
|
xdotool windowactivate $kak_client_env_WINDOWID > /dev/null
|
|
|
|
fi
|
2018-12-02 15:59:45 +03:00
|
|
|
}
|
|
|
|
}
|
2015-11-18 01:25:33 +03:00
|
|
|
|
|
|
|
alias global focus x11-focus
|
2018-12-02 15:59:45 +03:00
|
|
|
alias global terminal x11-terminal
|
2019-03-13 21:15:59 +03:00
|
|
|
|
|
|
|
}
|