kakoune

Fork of kakoune, an acceptable text editor
git clone git://git.laack.co/kakoune.git
Log | Files | Refs

wayland.kak (2254B)


      1 # wayland
      2 
      3 provide-module wayland %{
      4 
      5 # ensure that we're running in the right environment
      6 evaluate-commands %sh{
      7     [ -z "${kak_opt_windowing_modules}" ] || [ -n "$WAYLAND_DISPLAY" ] || echo 'fail WAYLAND_DISPLAY is not set'
      8 }
      9 
     10 # termcmd should be set such as the next argument is the whole
     11 # command line to execute
     12 declare-option -docstring %{shell command run to spawn a new terminal
     13 A shell command is appended to the one set in this option at runtime} \
     14     str termcmd %sh{
     15     for termcmd in 'alacritty      -e sh -c' \
     16                    'kitty             sh -c' \
     17                    'foot              sh -c' \
     18                    'termite        -e      ' \
     19                    'wterm          -e sh -c' \
     20                    'gnome-terminal -e      ' \
     21                    'kgx            -e      ' \
     22                    'xfce4-terminal -e      ' \
     23                    'konsole        -e      '; do
     24         terminal=${termcmd%% *}
     25         if command -v $terminal >/dev/null 2>&1; then
     26             printf %s\\n "$termcmd"
     27             exit
     28         fi
     29     done
     30 }
     31 
     32 define-command wayland-terminal-window -params 1.. -docstring '
     33 wayland-terminal-window <program> [<arguments>]: create a new terminal as a Wayland window
     34 The program passed as argument will be executed in the new terminal' \
     35 %{
     36     evaluate-commands -save-regs 'a' %{
     37         set-register a %arg{@}
     38         evaluate-commands %sh{
     39             if [ -z "${kak_opt_termcmd}" ]; then
     40                 echo "fail 'termcmd option is not set'"
     41                 exit
     42             fi
     43             termcmd=$kak_opt_termcmd
     44             args=$kak_quoted_reg_a
     45             unset kak_opt_termcmd kak_quoted_reg_a
     46             setsid ${termcmd} "$args" < /dev/null > /dev/null 2>&1 &
     47         }
     48     }
     49 }
     50 complete-command wayland-terminal-window shell
     51 
     52 define-command wayland-focus -params ..1 -docstring '
     53 wayland-focus [<kakoune_client>]: focus a given client''s window
     54 If no client is passed, then the current client is used' \
     55 %{
     56     fail 'Focusing specific windows in most Wayland window managers is unsupported'
     57 }
     58 complete-command -menu wayland-focus client
     59 
     60 alias global focus wayland-focus
     61 
     62 # deprecated
     63 define-command -hidden wayland-terminal -params 1.. %{
     64     wayland-terminal-window %arg{@}
     65 }
     66 
     67 }