donnatella adds embedded terminals

Freshly pushed to the branch next on donnatella's github are a few commits, some fixes and other improvements here and there of course, but mostly the addition of embedded terminals.

Let's rewind a bit: you could already run external process in donna by using the domain exec which supports a few modes: simply run the specified command line, run & wait for it to be over, run it in a(n external) terminal, or capture its output and process it as search results.

This was done using prefixes, e.g. exec:>foobar would run foobar inside a terminal, as indicated by the greater than sign.

First of all: you can now define which prefixes to use for each modes: a few options have been added in providers/exec so you can define the prefix for each mode, as well as the default mode to use (i.e. when no prefix was used).

Support multiple terminals

In addition, for the mode "terminal" you can also use a "secondary prefix" to specify which terminal to use. This might be of interest if you'd like to use different terminal emulators from time to time, or to use different options (e.g. whether or not the terminal should automatically close its window after the process ended or not, often an option -hold or similar).

The command line prefix to start the terminal is defined under option providers/exec/terminal/cmdline Let's say you set it to use urxvt as your default terminal.

Now you want to be able to start some process in another terminal, e.g. xterm. Then you would simply add a secondary prefix - e.g. xt: - for this case. An example configuration could be:

[providers/exec]
prefix_terminal=>
[providers/exec/terminal]
cmdline=urxvt -e
[providers/exec/terminal/]
prefix=xt:
cmdline=xterm -e

With such a config, you can start something in urxvt or xterm simply by using either exec:>foobar (urxvt) or exec:>xt:foobar (xterm).

Embedded terminals

The other addition in the support of embedded terminals. Once again, donna will let you use the terminal of your choice, so embedding terminals is done via the XEMBED protocol (supported, for example, by urxvt or xterm).

To use an embedded terminal, you first need to add it to your layout. This is done simply by adding a new componement "terminal" Much like for treeviews, it should be followed by a colon and a name, identifying it & defining where its configuration will be found (namely, under terminals/<NAME>.

After that, you can start a process in the embedded terminal using command terminal_add_tab() Embedded terminals are indeed automatically tabbed, so when starting a new process within a new embedded terminal, a new tab is added to donna's terminal component (which is only visible if there's at least one tab).

The command takes a few arguments, besides the actual terminal (name) to use: The command line of the process to start of course, but also optionally the command line for starting the terminal emulator.

If not specified, option terminals/<NAME>/cmdline will be used. And as a facility, it can also be a string starting with a colon, to load an alternative option. For example with ":foobar" option terminals/<NAME>/cmdline_foobar would be used.

This command line must contain %w which will be parsed to the window id to be used by the terminal emulator, as per XEMBED protocol.

Options

Terminals support a few options:

  • option always_show_tabs will determine whether the tab bar is visible even if there's only one tab (true), or only when there are at least 2 tabs (false, the default).

Double clicking a tab will send the focus to the embedded terminal. By default, clicking in a terminal should also give it focus. Note that for this to work, donna needs to do some work & handle mouse events on its own, as (most) terminal emulators do not implement a click-to-focus model. If this is causing issue with your terminal, you can disable it by setting boolean option catch_events to false.

  • option focusing_click makes it that a left click on the terminal will only focus it, but the click (button press) won't be sent to the terminal. This can be disabled by setting it to false. Also note that this obviously only works when option catch_events is true.

As usual, options can be set under terminals/<TERMINAL>/ for terminal-specific options, or under defaults/terminals for options common to all terminals.

By default, tabs will use the command line as title. donna will then update the title as a window manager would, relying on the properties _NET_WM_NAME (or WM_NAME) set on the window by the emulator.

Via the exec domain

Of course you can also use embedded terminals via the exec domain, since a new prefix/option cas been added: "embedded_terminal"

Option providers/exec/embedded_terminal/terminal must be set to the name of the terminal component to use; And you can also use option terminal_cmdline to specify the command line to use to start the terminal emulator.

Again, via the use of secondary prefixes this will allow to specify which emulator to use, of use different options.

Updating your config to benefit from all of this

Now, there's still work to do when it comes to upgrades in donna. Specifically, there isn't currently a way to update/import new defaults, so that is a manual operation. Archers, think of this as some king of .pacnew handling! ;)

Here's the patch to update your donnatella.conf (from last time) :

  1. diff --git a/misc/donnatella.conf b/misc/donnatella.conf
  2. index 39ac154..d45fd98 100644
  3. --- a/misc/donnatella.conf
  4. +++ b/misc/donnatella.conf
  5. @@ -5,7 +5,7 @@
  6.  #
  7.  
  8.  [layouts]
  9. -std=paneH(!treeview:tree@230,treeview:list)
  10. +std=paneH(!treeview:tree@230,paneV(treeview:list@230,terminal:term))
  11.  dp=paneH(!treeview:tree@230,paneV(treeview:foo,treeview:list))
  12.  tm=paneV(paneH(!treeview:tree@230,paneV(treeview:list,treeview:list2))@300,!treeview:tm)
  13.  
  14. @@ -38,6 +38,10 @@ prefix=~
  15.  is_home_dir=true
  16.  
  17.  [donna/prefixes/]
  18. +prefix=:
  19. +replacement=exec::
  20. +
  21. +[donna/prefixes/]
  22.  prefix=>
  23.  replacement=exec:>
  24.  
  25. @@ -61,10 +65,10 @@ replacement=command:
  26.  #   ALIASES
  27.  
  28.  [donna/aliases/g]
  29. -replacement=exec:>git
  30. +replacement=exec:!git
  31.  
  32.  [donna/aliases/m]
  33. -replacement=exec:>man
  34. +replacement=exec:!man
  35.  
  36.  [donna/aliases/f]
  37.  replacement=exec:<find
  38. @@ -771,12 +775,21 @@ trigger=command:node_trigger(@ask_text(Enter FL to trigger))
  39.  [key_modes/donna/key_slash]
  40.  trigger=command:tv_start_interactive_search (%o)
  41.  
  42. +# F2 to rename
  43. +[key_modes/donna/key_F2]
  44. +trigger=command:tv_column_edit (%o, %n, name)
  45.  # F6 to edit focused item (vim in a terminal)
  46.  [key_modes/donna/key_F6]
  47. -trigger=exec:>vim %:n
  48. +trigger=exec:!vim %:n
  49.  # F9 to view focused item (less in a terminal)
  50.  [key_modes/donna/key_F9]
  51. -trigger=exec:>less %:n
  52. +trigger=exec:!less %:n
  53. +
  54. +# Terminals
  55. +[key_modes/donna/key_t]
  56. +trigger=exec:!bash
  57. +[key_modes/donna/key_T]
  58. +trigger=exec:>bash
  59.  
  60.  # selection stuff -- note that this required a patched GTK (to invert range)
  61.  [key_modes/donna/key_v]
  62. @@ -1105,7 +1118,32 @@ not_active_list=true
  63.  #
  64.  
  65.  [providers/exec]
  66. -terminal=urxvt -hold -e
  67. +default_mode:exec-mode=exec
  68. +prefix_exec=&
  69. +prefix_exec_and_wait=:
  70. +prefix_terminal=>
  71. +prefix_embedded_terminal=!
  72. +prefix_parse_output=<
  73. +[providers/exec/terminal]
  74. +cmdline=urxvt -e
  75. +[providers/exec/terminal/]
  76. +prefix=>
  77. +cmdline=urxvt -hold -e
  78. +[providers/exec/embedded_terminal]
  79. +terminal=term
  80. +[providers/exec/embedded_terminal/]
  81. +prefix=!
  82. +terminal=term
  83. +terminal_cmdline=:hold
  84. +
  85. +
  86. +#
  87. +#       TERMINALS
  88. +#
  89. +
  90. +[terminals/term]
  91. +cmdline=urxvt -embed %w -e
  92. +cmdline_hold=urxvt -embed %w -hold -e
  93.  
  94.  
  95.  #

And with that config (and assuming you have urxvt installed, if not you might want to update things to use whatever emulator you prefer), you can now view a file within donna by pressing F9, and edit it by pressing F6. This will be done usnig less/vim inside an embedded terminal.

You can also start a new shell in the current location, in an embedded terminal by pressing t or in an external terminal via T

Where to get it?

For Arch Linux users, you can use donnatella-git in the AUR to easilly get it. Or simply clone the git repo from github and compile things yourself.

For a a complete list of all changes/bug fixes please refer to the git log.

And in case you read all that and are wondering what donnatella is, or are looking for more information, download links, etc please refer to donnatella.

As always, bug reports, suggestions or any other form of constructive criticism is very much welcome. You can open issues on github, use the thread on Arch Linux forums, or simply email me.

Top of Page