Skip to content

Make the emulation of tmux-like prefix keys more consistent#831

Merged
o-sdn-o merged 2 commits intodirectvt:masterfrom
o-sdn-o:gui-bridge
Oct 18, 2025
Merged

Make the emulation of tmux-like prefix keys more consistent#831
o-sdn-o merged 2 commits intodirectvt:masterfrom
o-sdn-o:gui-bridge

Conversation

@o-sdn-o
Copy link
Collaborator

@o-sdn-o o-sdn-o commented Oct 18, 2025

Changes

  • Make the emulation of tmux-like prefix keys more consistent.

Keyboard hacking

It is possible to emulate the tmux-like keyboard prefix approach by using a global variable in the Lua-scripting runtime space. As an example, the following configuration adds the keyboard shortcut Ctrl+B as a toggle for an additional keyboard mode (coupled with a user-defined boolean variable named kbmodifier) that allows windows to be moved directly using the arrow keys:

  • ~/.config/vtm/settings.xml:
    <config>
        <events>
            <desktop>
                <script="kbmodifier = not kbmodifier; log('kbmodifier=', kbmodifier);" on="Ctrl+B"/> <!-- Emulate tmux-like prefix key. The expression `log('kbmodifier=', kbmodifier);` is for debugging purposes only (the output is visible in the `Log Monitor`). -->
            </desktop>
            <applet> <!-- Key bindings for the application window. -->
                <KeyFilter="if (not kbmodifier and vtm.gear.Bypass()) then return; end; "/> <!-- `KeyFilter` macro. Do nothing if `kbmodifier` is false. Calling vtm.gear.Bypass() always returns true. -->
                <script=KeyFilter | MoveAppletLeft         prerun=KeyFilter on="LeftArrow"                                  /> <!-- The ` | ` operator concatenates script fragments/macros. If for some reason the keyboard event is not processed by anyone, it will then return and fire on this object, so the KeyFilter is also reused at the beginning of the `script="..."`. -->
                <script=KeyFilter | MoveAppletRight        prerun=KeyFilter on="RightArrow"                                 /> <!-- The `prerun` attribute contains a Lua script that will be executed during pre-polling to filter out key events. -->
                <script=KeyFilter | MoveAppletUp           prerun=KeyFilter on="UpArrow"                                    /> <!-- When kbmodifier is true, you can move windows using the arrow keys. -->
                <script=KeyFilter | MoveAppletDown         prerun=KeyFilter on="DownArrow"                                  /> <!-- Macros like `MoveApplet...` are defined in the default configuration. You can list them with `vtm -l`. -->
                <script=KeyFilter | MoveAppletTopLeft      prerun=KeyFilter on="LeftArrow+UpArrow    | UpArrow+LeftArrow"   /> <!-- Simultaneous key presses should also be processed if supported. -->
                <script=KeyFilter | MoveAppletBottomLeft   prerun=KeyFilter on="LeftArrow+DownArrow  | DownArrow+LeftArrow" /> <!-- It is convenient to specify multiple keyboard shortcuts in one definition separated by `|`. -->
                <script=KeyFilter | MoveAppletTopRight     prerun=KeyFilter on="RightArrow+UpArrow   | UpArrow+RightArrow"  />
                <script=KeyFilter | MoveAppletBottomRight  prerun=KeyFilter on="RightArrow+DownArrow | DownArrow+RightArrow"/>
                <script=KeyFilter | IncreaseAppletWidth    prerun=KeyFilter on="Ctrl+RightArrow"                            />
                <script=KeyFilter | DecreaseAppletWidth    prerun=KeyFilter on="Ctrl+LeftArrow"                             />
                <script=KeyFilter | IncreaseAppletHeight   prerun=KeyFilter on="Ctrl+DownArrow"                             />
                <script=KeyFilter | DecreaseAppletHeight   prerun=KeyFilter on="Ctrl+UpArrow"                               />
                <script=KeyFilter | FocusPrevWindow        prerun=KeyFilter on="PageUp"                                     />
                <script=KeyFilter | FocusNextWindow        prerun=KeyFilter on="PageDown"                                   />
            </applet>
        </events>
    </config>

@o-sdn-o o-sdn-o merged commit fbcaef4 into directvt:master Oct 18, 2025
8 checks passed
@o-sdn-o o-sdn-o deleted the gui-bridge branch October 18, 2025 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant