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 optioncatch_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) :
- diff --git a/misc/donnatella.conf b/misc/donnatella.conf
- index 39ac154..d45fd98 100644
- --- a/misc/donnatella.conf
- +++ b/misc/donnatella.conf
- @@ -5,7 +5,7 @@
- #
- [layouts]
- -std=paneH(!treeview:tree@230,treeview:list)
- +std=paneH(!treeview:tree@230,paneV(treeview:list@230,terminal:term))
- dp=paneH(!treeview:tree@230,paneV(treeview:foo,treeview:list))
- tm=paneV(paneH(!treeview:tree@230,paneV(treeview:list,treeview:list2))@300,!treeview:tm)
- @@ -38,6 +38,10 @@ prefix=~
- is_home_dir=true
- [donna/prefixes/]
- +prefix=:
- +replacement=exec::
- +
- +[donna/prefixes/]
- prefix=>
- replacement=exec:>
- @@ -61,10 +65,10 @@ replacement=command:
- # ALIASES
- [donna/aliases/g]
- -replacement=exec:>git
- +replacement=exec:!git
- [donna/aliases/m]
- -replacement=exec:>man
- +replacement=exec:!man
- [donna/aliases/f]
- replacement=exec:<find
- @@ -771,12 +775,21 @@ trigger=command:node_trigger(@ask_text(Enter FL to trigger))
- [key_modes/donna/key_slash]
- trigger=command:tv_start_interactive_search (%o)
- +# F2 to rename
- +[key_modes/donna/key_F2]
- +trigger=command:tv_column_edit (%o, %n, name)
- # F6 to edit focused item (vim in a terminal)
- [key_modes/donna/key_F6]
- -trigger=exec:>vim %:n
- +trigger=exec:!vim %:n
- # F9 to view focused item (less in a terminal)
- [key_modes/donna/key_F9]
- -trigger=exec:>less %:n
- +trigger=exec:!less %:n
- +
- +# Terminals
- +[key_modes/donna/key_t]
- +trigger=exec:!bash
- +[key_modes/donna/key_T]
- +trigger=exec:>bash
- # selection stuff -- note that this required a patched GTK (to invert range)
- [key_modes/donna/key_v]
- @@ -1105,7 +1118,32 @@ not_active_list=true
- #
- [providers/exec]
- -terminal=urxvt -hold -e
- +default_mode:exec-mode=exec
- +prefix_exec=&
- +prefix_exec_and_wait=:
- +prefix_terminal=>
- +prefix_embedded_terminal=!
- +prefix_parse_output=<
- +[providers/exec/terminal]
- +cmdline=urxvt -e
- +[providers/exec/terminal/]
- +prefix=>
- +cmdline=urxvt -hold -e
- +[providers/exec/embedded_terminal]
- +terminal=term
- +[providers/exec/embedded_terminal/]
- +prefix=!
- +terminal=term
- +terminal_cmdline=:hold
- +
- +
- +#
- +# TERMINALS
- +#
- +
- +[terminals/term]
- +cmdline=urxvt -embed %w -e
- +cmdline_hold=urxvt -embed %w -hold -e
- #
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.