1754256475263550935

· ficd's pastes · raw

expires: 2025-11-01

 1provide-module niri %~
 2
 3# ensure we're actually in niri
 4evaluate-commands %sh{
 5    [ -z "${kak_opt_windowing_modules}" ] || 
 6    [ -n "$NIRI_SOCKET" ] ||
 7    echo 'fail NIRI_SOCKET is not set'
 8}
 9
10require-module wayland
11
12alias global niri-terminal-window wayland-terminal-window
13
14define-command niri-terminal-vertical -params 1.. -docstring '
15    niri-terminal-vertical <program> [<arguments>]: create a new terminal as a Niri window and consume it into the current column
16    The program passed as argument will be executed in the new terminal' \
17%{
18    wayland-terminal-window %arg{@}
19    # niri always opens new windows to the right
20    # and only allows operations on focused windows
21    nop %sh{
22        niri msg action focus-right
23        niri msg action consume-or-expel-window-left
24    }
25}
26complete-command niri-terminal-vertical shell
27
28define-command niri-terminal-horizontal -params 1.. -docstring '
29    niri-terminal-horizontal <program> [<arguments>]: create a new terminal as a Niri window and consume it into the column on the right
30    The program passed as argument will be executed in the new terminal' \
31%{
32    wayland-terminal-window %arg{@}
33    # niri always opens new windows to the right
34    # and only allows operations on focused windows
35    nop %sh{
36        niri msg action focus-right
37        niri msg action consume-or-expel-window-right
38    }
39}
40complete-command niri-terminal-horizontal shell
41
42define-command niri-new-vertical -params .. -docstring '
43new [<commands>]: create a new Kakoune client and consume it into the current column
44The optional arguments are passed as commands to the new client' \
45%{
46    wayland-terminal-window kak -c %val{session} -e "%arg{@}"
47    # niri always opens new windows to the right
48    # and only allows operations on focused windows
49    nop %sh{
50        niri msg action focus-right
51        niri msg action consume-or-expel-window-left
52    }
53}
54complete-command -menu niri-new-vertical command
55
56define-command niri-new-horizontal -params .. -docstring '
57new [<commands>]: create a new Kakoune client and consume it into the column on the right and consume it into the column on the right
58The optional arguments are passed as commands to the new client' \
59%{
60    wayland-terminal-window kak -c %val{session} -e "%arg{@}"
61    # niri always opens new windows to the right
62    # and only allows operations on focused windows
63    nop %sh{
64        niri msg action focus-right
65        niri msg action consume-or-expel-window-right
66    }
67}
68complete-command -menu niri-new-horizontal command
69~