Commit graph

522 commits

Author SHA1 Message Date
Daniel Eklöf
c4d9f8a8ff
osc: kitty notifications: implement the 'close' request
Add a new config option, desktop-notifications.close, defining what to
execute to close a notification. It has a single template parameter,
${id}, that is expanded to the external notification ID foot may have
picked up from the notification helper.

notify-send does not support closing notifications, and it appears
impossible to pass an *unsigned* integer as argument to gdbus. Hence
no default value for the new 'close' option.

Example:

    printf '\e]99;i=123;this is a notification\e\\'
    printf '\e]99;i=123:p=close;\e\\'
2024-07-25 19:24:28 +02:00
Daniel Eklöf
f56da385fe
notify: try to read the daemon assigned notification ID from stdout
And document the things we recognize in the notification helper's
stdout.
2024-07-24 16:02:19 +02:00
Daniel Eklöf
e271027c0c
config: notify-send: it's "action=label", not "action,label" 2024-07-24 16:01:42 +02:00
Daniel Eklöf
ecbec57a47
notify: split up the ${action} template parameter
Split it up into two, ${action-name} and ${action-label}.

Dunstify, for example, has a different syntax compared to notify-send:

notify-send: default=foobar
dunstify: default,foobar
2024-07-23 19:08:21 +02:00
Daniel Eklöf
511d4817d3
doc: foot.ini: desktop-notification: remove 'notification dismissal' 2024-07-23 16:52:18 +02:00
Daniel Eklöf
045ead985c
notify: don't focus/report on notification dismissal
Only do it when the notification was activated.

Here, activated means the 'click to activate' notification action was
triggered.

How do we tie everything together?

First, we add a new template parameter, ${action}. It's intended to be
used with e.g. notify-send's --action option.

When the action is triggered, notify-send prints its name on stdout,
on a separate line. Look for this in stdout. Only if we've seen it do
we focus/report the notification.
2024-07-23 16:41:52 +02:00
Daniel Eklöf
b319618af1
notify: XDG token is now expected to be prefixed with xdgtoken=
This patch modifies our stdout reader to consume input as we go,
instead of all at once when stdout is closed. This will make it easier
to add support for reading e.g. the daemon assigned notification ID in
the future, and also ensures we see the XDG activation token "as soon
as possible".

Furthermore, to be more future proof, require the XDG activation token
to be prefixed with 'xdgtoken=', and ignore other lines.

Thus, instead of treating *all* of stdout as the XDG activation token,
parse stdout line-by-line, and ignore everything that does not begin
with 'xdgtoken='. Everything (on that line) following 'xdgtoken=' is
treated as the activation token.
2024-07-23 09:33:18 +02:00
Daniel Eklöf
5905ea0d84
osc: kitty notifications: implement focus|report
This patch adds support for window focusing, and sending events back
to the client application when a notification is closed.

* Refactor notification related configuration options:
    - add desktop-notifications sub-section
    - deprecate 'notify' in favor of 'desktop-notifications.command'
    - deprecate 'notify-focus-inhibit' in favor of
      'desktop-notifications.inhibit-when-focused'
* Refactor: rename 'struct kitty_notification' to 'struct
  notification'
* Pass a 'struct notification' to notify_notify(), instead of many
  arguments.
* notify_notify() now registers a reaper callback. When the notifier
  process has terminated, the notification is considered closed, and we
  either try to focus (activate) the window, or send an event to the
  client application, depending on the notification setting.
* For the window activation, we need an XDG activation token. For now,
  assume *everything* written on stdout is part of the token.
* Refactor: remove much of the warnings from OSC-99; we don't
  typically log anything when an OSC/CSI has invalid values.
* Add icon support to OSC-99. This isn't part of the upstream
  spec. Foot's implementation:
    - uses the 'I' parameter
    - the value is expected to be a symbolic icon name
    - a quick check for absolute paths is done, and such icon requests
      are ignored.
* Added ${icon} to the 'desktop-notifications.command' template. Uses
  the icon specified in the notification, or ${app-id} if not set.
2024-07-23 07:17:21 +02:00
Daniel Eklöf
b0bf8ca5f7
osc/notify: add support for OSC-99, kitty desktop notifications
This adds limited support for OSC-99, kitty desktop notifications[^1]. We
support everything defined by the "protocol", except:

* 'a': action to perform on notification activation. Since we don't
  trigger the notification ourselves (over D-Bus), we don't know a)
  which ID the notification got, or b) when it is clicked.
* ... and that's it. Everything else is supported

To be explicit, we *do* support:

* Chunked notifications (d=0|1), allowing the application to append
  data to a notification in chunks, before it's finally displayed.
* Plain UTF-8, or base64-encoded UTF-8 payload (e=0|1).
* Notification identifier (i=xyz).
* Payload type (p=title|body).
* When to honor the notification (o=always|unfocused|invisible), with
  the following quirks:
    - we don't know when the window is invisible, thus it's treated as
      'unfocused'.
    - the foot option 'notify-focus-inhibit' overrides 'always'
* Urgency (u=0|1|2)

[^1]: https://sw.kovidgoyal.net/kitty/desktop-notifications/
2024-07-23 07:17:21 +02:00
Daniel Eklöf
38461eef6f
csi: in-band window resize notifications, private mode 2048
This implements
https://gist.github.com/rockorager/e695fb2924d36b2bcf1fff4a3704bd83,
in-band window resize notifications.

When user enables private mode 2048 (in-band resize
notifications), *always* send current size, even if the mode is
already active.

This ensures applications can rely on getting a reply from the
terminal.
2024-07-19 06:54:32 +02:00
Daniel Eklöf
1136108c97
input: don't map wheel events to BTN_{BACK,FORWARD}
BTN_BACK and BTN_FORWARD are separate buttons. The scroll wheel don't
have any button mappings in libinput/wayland, so make up our own
defines.

This allows us to map them in mouse bindings.

Also expose BTN_WHEEL_{LEFT,RIGHT}. These were already defined, and
used, internally, to handle wheel tilt events. With this, they can
also be used in mouse bindings.

Finally, fix encoding used for BTN_{BACK,FORWARD} when sending mouse
button events to the client application. Before this, they were mapped
to buttons 4/5. But, button 4/5 are for the scroll wheel, and as
mentioned above, BTN_{BACK,FORWARD} are not the same as scroll wheel
"buttons".

Closes #1763
2024-07-13 10:41:10 +02:00
Daniel Eklöf
85b2fb1e32
doc: foot.ini: line-height: add warning about runtime font size changes 2024-07-07 16:31:40 +02:00
Daniel Eklöf
bebd5ce415
doc: foot-ctlseq: document XTPUSHCOLORS, XTPOPCOLORS and XTREPORTCOLORS 2024-07-03 09:47:30 +02:00
Daniel Eklöf
e708d19ea3
csi: implement SGR 21, double underlines 2024-07-03 09:46:41 +02:00
Craig Barnes
ab4b3cbd34 doc: foot-ctlseq: add missing "E" to DECRQSS sequence
This omission seems to have been a typo in commit add530e66d.
2024-07-03 06:09:59 +01:00
Daniel Eklöf
a33954a8f4
doc: foot-ctlseq: add 58/59 (styled + colored underlines) 2024-06-26 18:39:24 +02:00
Daniel Eklöf
519e9b8b5e
doc: foot.ini: fix typos 2024-06-25 08:20:03 +02:00
Daniel Eklöf
911af53c5c
doc: foot.ini: document issues with fractional scaling and initial-window-size-*
Since most compositors don't report the correct scaling factor
until *after* the window has been mapped, these options often do not
work.
2024-06-25 08:12:40 +02:00
Daniel Eklöf
bb2e0d64e1
doc: foot.ini: document pixelsize
People are apparently too lazy to read fontconfig's documentation, and
don't understand how to configure font sizes in foot.
2024-06-07 16:18:28 +02:00
Daniel Eklöf
c4f1380943
config: add cursor.blink-rate option
The default is 500ms, which corresponds to the old, hardcoded default.

Closes #1707
2024-05-20 09:17:42 +02:00
Daniel Eklöf
edb28479cc
doc: foot: simplify example where we run a non-default command
To reduce the risk of people mistakenly believing you have to/should
use "sh -c".
2024-04-20 08:17:02 +02:00
Daniel Eklöf
b400903e25
config: add new key-binding 'quit', unbound by default
Closes #1475
2024-04-11 15:12:45 +02:00
Daniel Eklöf
e5a2ac4b57
config: add cursor.unfocused-style
This option controls how we render the cursor when the terminal window
is unfocused.

Possible values are:

* hollow: the default, and how we rendered the cursor before this
  patch.
* unchanged: render the cursor exactly the same way as when the window
  is focused.
* none: do not render any cursor at all

Closes #1582
2024-04-10 16:24:10 +02:00
Alyssa Ross
86894a1cd2
Add support for opening an existing PTY
Virtual machine monitor programs (e.g. QEMU, Cloud Hypervisor) expose
guest consoles as PTYs.  With this patch, foot can access these guest
consoles.

Usually, the program used for accessing these PTYs is screen, but
screen is barely developed, doesn't support resizing, and has a bunch
of other unrelated stuff going on.  It would be nice to have a
terminal emulator that properly supported opening an existing PTY.
The VMM controls the master end of the PTY, so to the other end (in
this case foot), it just behaves like any application running in a
directly-opened PTY, and all that's needed is to change foot's code to
support opening an existing PTY rather than creating one.

Co-authored-by: tanto <tanto@ccc.ac>
2024-03-14 07:31:03 +01:00
Daniel Eklöf
6ff307b3b5
doc: ctlseq: DECCARA, DECRARA, DECCRA, DECFRA and DECERA 2024-03-07 16:26:11 +01:00
Daniel Eklöf
9ca84e6b48
config: map Control+wheel to font increase/decrease
This is in addition to the already existing keyboard shortcuts.

Also add missing default keyboard/mouse bindings to readme + foot(1).
2024-02-15 16:55:40 +01:00
Craig Barnes
fa01bf2b75 csi: support DECRQM queries for ECMA-48 (SM/RM) modes
This is in addition to the existing support for DECRQM queries
of DEC private modes.
2024-02-11 15:09:28 +00:00
Daniel Eklöf
69df42c51b
doc: better examples for pipe-* commands 2024-02-07 17:09:01 +01:00
delthas
6c56b04b3f
osc: add support for osc 176 (app ID)
This adds support for a new OSC escape sequence: OSC 176, that lets
terminal programs tell the terminal the name of the app that is
running. foot then sets the app ID of the toplevel to that ID,
which lets the compositor know which app is running, and typically
sets the appropriate icon, window grouping, ...

See: https://gist.github.com/delthas/d451e2cc1573bb2364839849c7117239
2024-02-06 13:50:09 +01:00
Daniel Eklöf
41dc259744
doc: foot-ctlseq: add OSC 133 C/D (command output start/end) 2024-02-06 13:38:08 +01:00
Daniel Eklöf
7999975016
Don't use fancy Unicode quotes, stick to ASCII 2024-02-06 12:36:45 +01:00
Daniel Eklöf
1393942de3
readme, doc/foot.1: document shell-integration:command-output tracking 2024-02-06 12:13:09 +01:00
Daniel Eklöf
0fed2451ea
doc: foot.ini: document pipe-command-output 2024-02-06 12:12:57 +01:00
Andrew J. Hesford
21a8d832ce
feature: add resize-by-cells option to constrain window sizes...
...to multiples of the cell size, and preserve grid size when changing
fonts or display scales in floating windows.
2024-02-05 12:14:53 +01:00
Daniel Eklöf
9da7152f83
slave: don't skip setting environment variables when using a custom environment
When launching footclient with -E,--client-environment the environment
variables that should be set by foot, wasn't.

Those variables are:

* TERM
* COLORTERM
* PWD
* SHELL

and all variables defined by the user in the [environment] section in
foot.ini.

In the same way, we did not *unset* TERM_PROGRAM and
TERM_PROGRAM_VERSION.

This patch fixes it by "cloning" the custom environment, making it
mutable, and then adding/removing the variables above from it.

Instead of calling setenv()/unsetenv() directly, we add the wrapper
functions add_to_env() and del_from_env().

When *not* using a custom environment, they simply call
setenv()/unsetenv().

When we *are* using a custom environment, add_to_env() first loops all
existing variables, looking for a match. If a match is found, it's
updated with the new value. If it's not found, a new entry is added.

del_from_env() loops all entries, and removes it when a match is
found. If no match is found, nothing is done.

The mutable environment is allocated on the heap, but never free:d. We
don't need to free it, since it's only allocated after forking, in the
child process.

Closes #1568
2024-01-11 16:37:17 +01:00
xnuk
7ffbb3cc27
man foo.ini.5: Add 'Comma separated list of fonts' example 2023-10-27 16:18:41 +02:00
Daniel Eklöf
ce64da2fe1
doc: foot.ini.5: move flash{,-alpha} to the bottom of the 'colors' section 2023-10-10 08:13:35 +02:00
Daniel Eklöf
0c6a3731c3
doc: foot.ini.5: flash_alpha -> flash-alpha 2023-10-10 08:13:35 +02:00
Daniel Eklöf
8a2a450778
doc: foot.ini: flash: tweak grammar, use consistent formatting 2023-10-10 08:13:35 +02:00
Raimund Sacherer
8273962372
Enable the use of flash as visual bell
With this patch we can configure flash in the bell section. The colors
section allow now to configure the color and translucency of the
flash.
2023-10-10 08:12:48 +02:00
Daniel Eklöf
3e67415e3e
config: add remaining search.scrollback key bindings
All scrollback up/down key bindings are now available in search mode.
2023-10-08 10:38:39 +02:00
Daniel Eklöf
6a708b35ee
foot.ini: document all the new search.extend* bindings 2023-10-08 10:38:39 +02:00
Daniel Eklöf
4eef001d58
csi: implement DECSET/DECRST/DECRQM 2027 - grapheme cluster processing
This implements private mode 2027 - grapheme cluster processing, as
defined in the "Terminal Unicode Core"[1] specification.

Internally, we just flip the already existing option "grapheme
shaping". Since it's now runtime changeable, we need a copy of it in
the terminal struct, rather than referencing the conf object.

[1]: 13fc5a8993/spec/terminal-unicode-core.tex (L50-L53)
2023-09-25 16:50:44 +02:00
Sertonix
a4843ef418 doc: keybings default none 2023-09-20 13:20:48 +00:00
Daniel Eklöf
1719ff93a7
selection: add support for selecting the contents of a quote
This patch changes the default of triple clicking, from selecting the
current logical row, to first trying to select the contents of the
quote under the cursor, and if failing to find a quote, selecting the
current row (like before).

This is implemented by adding a new key binding, 'select-quote'.

It will search for surrounding quote characters, and if one is found
on each side of the cursor, the quote is selected. If not, the entire
row is selected instead.

Subsequent selection operations will behave as if the selection is
either a word selection (a quote was found), or a row selection (no
quote found).

Escaped quote characters are not supported: "foo \" bar" will match
'foo \', and not 'foo " bar'.

Mismatched quotes are not custom handled. They will simply not match.

Nested quotes ("123 'abc def' 456") are supported.

Closes #1364
2023-09-19 16:23:34 +02:00
Daniel Eklöf
fe7aa25ad8
input: make wheel events mappable
Un-grabbed wheel events are now passed through the mouse binding
matching logic, instead of being hardcoded to scrolling the terminal
contents.

They are mappable through the BTN_BACK and BTN_FORWARD buttons.

Since they're not actually button *presses*, they never generate a
click count other than 1. This limitation is documented, but not
checked in the config. This means it's possible to create bindings
like "BTN_BACK+3" (i.e. triple "click"). They will however never
trigger.

The old, hardcoded logic is now accessible through the new
scrollback-up-mouse and scrollback-down-mouse mouse
bindings. They (obiously) default to BTN_BACK and BTN_FORWARD,
respectively.

Example usage: keep the default of scrolling terminal contents with
the wheel, when used without modifiers, but map Control+wheel to font
zoom in/out:

  [mouse-bindings]
  font-increase=Control+BTN_FORWARD
  font-decrease=Control+BTN_BACK

(this also keeps the default key bindings to zoom in/out; ctrl-+ and
ctrl+-)

Closes #1077
2023-09-18 16:36:39 +02:00
Daniel Eklöf
f3c5b82c82
config: add tweak.bold-text-in-bright-amount
By how much to increase the luminance when brightening bold
fonts. This was previously hard-coded to a factor of 1.3, which is now
the default value of the new config option.

Closes #1434
2023-07-28 15:40:07 +02:00
Max Gautier
555edd60d4
Update documentation regarding systemd units 2023-07-21 08:12:55 +02:00
Max Gautier
c12db68363
footclient: fallback logic when socket paths don't exist
Even if WAYLAND_DISPLAY / XDG_RUNTIME_DIR are defined, if we can't
find the corresponding socket, we fallback to the path used when they
are not defined.
2023-07-21 08:12:49 +02:00
Daniel Eklöf
27b4c2ac2d
themes: starlight: update to V4
This also updates the default theme in foot, as well as the
documentation.

Closes #1409
2023-07-18 16:20:33 +02:00