Skip to content

Commit

Permalink
FvwmMFL: Fvwm Module Front Loader
Browse files Browse the repository at this point in the history
This introduces a new module which exposes internal Fvwm events as JSON
objects.  This module is intended to provide information from Fvwm in a
language-agnostic way, allowing Fvwm modules to be written in any
language.
  • Loading branch information
ThomasAdam committed Jul 7, 2020
1 parent 0e76119 commit 48dd509
Show file tree
Hide file tree
Showing 11 changed files with 846 additions and 6 deletions.
5 changes: 4 additions & 1 deletion .disabled-travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
language: c
sudo: false
dist: bionic
branches:
except:
- todo
Expand All @@ -19,6 +20,8 @@ addons:
- file
- fontconfig
- gettext
- libbson-dev
- libevent-dev
- libfontconfig-dev
- libfreetype6-dev
- libfribidi-dev
Expand All @@ -37,7 +40,7 @@ addons:
- libxt-dev
- sharutils
- xsltproc
script: (./autogen.sh && CFLAGS= ./configure) && make
script: (./autogen.sh && CFLAGS= ./configure --disable-silent-rules) && make
notifications:
irc:
channels:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
run: 'docker build -t fvwm3 .'

notification:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
name: notifications
steps:
- name: irc push
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ modules/FvwmRearrange/FvwmTile
modules/FvwmScript/FvwmScript
modules/FvwmScript/Scripts/FvwmScript-ComExample
modules/FvwmScroll/FvwmScroll
modules/fmd/fmd
perllib/FVWM/Module.pm
stamp-h1
tags
Expand Down
29 changes: 28 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -524,9 +524,34 @@ AC_CHECK_HEADER(X11/XKBlib.h, AC_DEFINE(HAVE_X11_XKBLIB_H))
AH_TEMPLATE([HAVE_TAILQ],[Check if tailq is present.])
AC_CHECK_HEADER(queue.h, AC_DEFINE(HAVE_TAILQ))

# libbson
AH_TEMPLATE([HAVE_LIBBSON],[Define if libbson is used.])
PKG_CHECK_MODULES([libbson], [libbson-1.0],
[
AC_DEFINE(HAVE_LIBBSON)
libbson_LIBS=-lbson-1.0
],
[
AC_MSG_ERROR([*** libnson not found. Install its header files. ***])
])
AC_SUBST(libbson_LIBS)
AC_SUBST(libbson_CFLAGS)

# libevent
AH_TEMPLATE([HAVE_LIBEVENT],[Define if libevent is used.])
PKG_CHECK_MODULES([libevent], [libevent >= 2.0],
[
AC_DEFINE(HAVE_LIBEVENT)
libevent_LIBS=-levent
],
[
AC_MSG_ERROR([*** libevent >=2 not found. Install its header files. ***])
])
AC_SUBST(libevent_LIBS)
AC_SUBST(libevent_CFLAGS)

# ********* XRandR
AH_TEMPLATE([HAVE_XRANDR],[Define if XRandR library is used.])
AC_MSG_CHECKING([for XRandR...])
PKG_CHECK_MODULES([xrandr], [xrandr >= 1.5],
[
AC_DEFINE(HAVE_XRANDR)
Expand Down Expand Up @@ -1595,6 +1620,7 @@ dnl bin/fvwm-perllib.1
modules/FvwmEvent/FvwmEvent.1
modules/FvwmIconMan/FvwmIconMan.1
modules/FvwmIdent/FvwmIdent.1
modules/FvwmMFL/FvwmMFL.1
modules/FvwmPager/FvwmPager.1
modules/FvwmRearrange/FvwmRearrange.1
modules/FvwmScript/FvwmScript.1
Expand Down Expand Up @@ -1645,6 +1671,7 @@ dnl
modules/FvwmEvent/Makefile
modules/FvwmIconMan/Makefile
modules/FvwmIdent/Makefile
modules/FvwmMFL/Makefile
modules/FvwmPager/Makefile
modules/FvwmPerl/Makefile
modules/FvwmPerl/FvwmPerl
Expand Down
4 changes: 3 additions & 1 deletion dev-docs/INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ dependencies, core or optional.

## Core dependencies

* libbson-dev
* libevent-dev (>= 2.0)
* libx11-dev
* libxrandr-dev
* libxrandr-dev (>= 1.5)
* libxrender-dev
* libxt-dev

Expand Down
2 changes: 1 addition & 1 deletion libs/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ libfvwm3_a_LIBADD = @LIBOBJS@

AM_CPPFLAGS = -I$(top_srcdir) $(xpm_CFLAGS) $(Xft_CFLAGS) $(X_CFLAGS) \
$(iconv_CFLAGS) $(Xrender_CFLAGS) $(Bidi_CFLAGS) $(png_CFLAGS) \
$(rsvg_CFLAGS) $(intl_CFLAGS) $(XRandR_CFLAGS)
$(rsvg_CFLAGS) $(intl_CFLAGS) $(XRandR_CFLAGS) $(libbson_CFLAGS)
122 changes: 122 additions & 0 deletions modules/FvwmMFL/FvwmMFL.1.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
.\" t

.\" @(#)@PACKAGE@-@VERSION@ @RELDATELONG@
.de EX \"Begin example
.ne 5
.if n .sp 1
.if t .sp .5
.nf
.in +.5i
..
.de EE
.fi
.in -.5i
.if n .sp 1
.if t .sp .5
..
.ta .3i .6i .9i 1.2i 1.5i 1.8i
.TH FvwmMFL 1 "@RELDATELONG@ (@VERSION@)" Fvwm "Fvwm Modules"
.UC
.SH NAME
\fIFvwmMFL\fP \- the Fvwm3 front-loader module
.SH SYNOPSIS
\fIFvwmMFL\fP can only be invoked by Fvwm3.
Command line invocation of the \fIFvwmMFL\fP will not work.

This module has no command-line options.

.SH DESCRIPTION
The \fIFvwmMFL\fP module provides access to Fvwm events over a unix-domain
socket. This module is intended to provide externally-written programs
(clients) the ability to receive information from Fvwm and to perform an
action on that event.

The information from Fvwm3 is in the form of JSON packets. Each JSON packet
has different fields, depending on the type requested.

.SH COMMUNICATION
The default unix-domain socket for \fIFvwmMFL\fP is \fI/tmp/fvwm_mfl.sock\fP,
although this can be overriden via an environment variable \fIFVWMMFL_SOCKET\fP.

.SH REGISTERING INTEREST
Commands can be sent to \fIFvwmMFL\fP to control which information is sent the
client. The \fIset\fP command is used for this. The table below shows which
events can be subscribed to.

.TS
allbox tab(:);
l l.
\fIEvent\fP:\fIDescription\fP
new_window:Fired when a new window is mapped and visible.
map:Fired when a window is mapped.
configure_window:Fired when a window is moved or resized.
destroy_window:Fired when a window is closed.
new_page:Fired when a new page is switched to.
new_desk:Fired when a new desk is switched to.
raise_window:Fired when a window is raised (or changes layer).
lower_window:Fired when a window is lowered (or changed layer).
focus_change:Fired when a window loses/gains focus.
enter_window:Fired when a window has the pointer moved into it.
leave_Window:Fired when a window has pointer moved out of it.
window_shade:Fired when a window is shaded.
window_unshade:Fired when a window is unshaded.
window_name:Fired when the window name changes.
visible_name:Fired when the visible window name changes.
res_class:Fired when the class of the window is set.
res_name:Fired when the resource of the window is set.
iconify:Fired when a window is iconified.
deiconify:Fired when a window is deiconified.
icon_name:Fired when the icon name changes.
visible_icon_name:Fired when the icon's visible name changes.
icon_file:Fired when the path to the icon changes.
icon_location:Fired when the icon location changes.
restack:Fired when the window stacking order changes.
.TE

For example, to register an interest in \fInew_window\fP and
\fIfocus_change\fP, the following commands would be set via the socket:

.EX
.I set new_window
.I set focus_change
.EE

To remove interest in an event, use the \fIunset\fP command:

.EX
.I unset focus_change
.EE

.SH JSON FORMAT
Each packet sent to a client is in plain JSON. The information contained in
each packet varies depending on the event.

TODO: document each JSON structure.

.SH EXAMPLE

The following example shows how to monitor for \fIfocus_change\fP events at
the shell, printing the JSON returned:

.EX
.I echo "set focus_change" | nc -U /tmp/fvwm_mfl.sock 2>&1 | jq --unbuffered .
.EE

Outputs:

.EX
{
"focus_change": {
"window": "0x5400022",
"type": 0,
"hilight": {
"text_colour": 16777215,
"bg_colour": 32767
}
}
}
.EE

.SH AUTHORS

This module first appeared in 2020.
Loading

0 comments on commit 48dd509

Please sign in to comment.