git import default tip
authoragaric <agaric@protonmail.com>
Tue, 09 Mar 2021 07:18:07 +0000
changeset 0 5f04caa7212d
git import
.hgignore
LICENSE
README.org
config.mk
include/goose.h
include/layers.h
makefile
protocols/idle.xml
protocols/wlr-input-inhibitor-unstable-v1.xml
protocols/wlr-layer-shell-unstable-v1.xml
protocols/wlr-output-power-management-unstable-v1.xml
src/bump.tcl
src/goose.c
src/goosebump.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgignore	Tue Mar 09 07:18:07 2021 +0000
@@ -0,0 +1,3 @@
+\.git/
+\.gitignore
+^build/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LICENSE	Tue Mar 09 07:18:07 2021 +0000
@@ -0,0 +1,8 @@
+(c) 2021, agaric <agaric@protonmail.com>
+Copyright (c) 2016-2017 Drew DeVault
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/README.org	Tue Mar 09 07:18:07 2021 +0000
@@ -0,0 +1,48 @@
+* goose
+
+*Status:* pre-alpha
+
+Goose is a wayland compositor written in c and tcl/tk.
+
+Aspired features include:
+- good use of wlroots (device detection, multi-monitor, screensharing, etc.)
+- control, configuration, hackability via tcl, json
+- gui hackability via tk
+- stacked windows by default
+- grouping (tabs, piles, concats)
+- tagging (workspace-like behavior)
+- marking (for quick focusing)
+- overview (mac's exposé, spaces, mosaic, etc.; an extended alt-tab; a graphical configuration tool)
+
+
+Terms:
+- input: mouse, keyboard, etc.
+- output: monitor, etc.
+- root: structure of all frames
+- view: visible space, contains subset of root
+- frame: contains windows
+  - tab: laid out in tabs, front window totally visible, the rest totally hidden
+  - pile: laid out in piles, front window totally visible, the rest partially/totally hidden
+  - concat: laid out flat and adjoined, all windows totally visible
+- window: an application's immediate graphical representation
+- tag: an index on frames for visibility-toggling
+- mark: an index on frames for focus-toggling
+- get: state query (by a client)
+- set: state modification request (by a client)
+
+** Build
+
+1. ~cd goose/~
+1. ~$EDITOR config.mk~ and ~make~
+1. ~./build/goose~
+
+
+** Why
+
+- want some practice with c + tcl and shipping a complete program
+- tcl and tk are awesome
+- wayland seems to hold a bright future
+- yet to see a stacking wayland window manager (at least packaged for the distro that I use) that works intuitively, that works in a way that I like by default (cwm, openbox), and whose near-core behavior is easily customisable
+- want to experiment with seemingly cool ui, layout, ipc ideas
+- called "goose" because when you get tcl'd, you get goose-bumps
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/config.mk	Tue Mar 09 07:18:07 2021 +0000
@@ -0,0 +1,8 @@
+bdir = build
+CC = clang
+PREFIX = /usr/local
+# default compile flags (overridable by environment)
+CFLAGS ?= -g -Wall -Wextra -Werror -Wno-unused-parameter -Wno-sign-compare -Wno-unused-function -Wno-unused-variable -Wdeclaration-after-statement
+# uncomment for xwayland support
+CFLAGS += -DXWAYLAND
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/goose.h	Tue Mar 09 07:18:07 2021 +0000
@@ -0,0 +1,184 @@
+#ifndef _GOOSE_SERVER_H
+#define _GOOSE_SERVER_H
+
+#include <wlr/backend.h>
+#include <wlr/backend/headless.h>
+#include <wlr/backend/multi.h>
+#include <wlr/backend/noop.h>
+#include <wlr/backend/session.h>
+#include <wlr/render/wlr_renderer.h>
+#include <wlr/types/wlr_data_device.h>
+#include <wlr/types/wlr_data_control_v1.h>
+#include <wlr/types/wlr_export_dmabuf_v1.h>
+#include <wlr/types/wlr_foreign_toplevel_management_v1.h>
+#include <wlr/types/wlr_gamma_control_v1.h>
+#include <wlr/types/wlr_idle.h>
+#include <wlr/types/wlr_idle_inhibit_v1.h>
+#include <wlr/types/wlr_input_method_v2.h>
+#include <wlr/types/wlr_layer_shell_v1.h>
+#include <wlr/types/wlr_output_management_v1.h>
+#include <wlr/types/wlr_output_power_management_v1.h>
+#include <wlr/types/wlr_pointer_constraints_v1.h>
+#include <wlr/types/wlr_presentation_time.h>
+#include <wlr/types/wlr_primary_selection_v1.h>
+#include <wlr/types/wlr_relative_pointer_v1.h>
+#include <wlr/types/wlr_screencopy_v1.h>
+#include <wlr/types/wlr_seat.h>
+#include <wlr/types/wlr_server_decoration.h>
+#include <wlr/types/wlr_text_input_v3.h>
+#include <wlr/types/wlr_viewporter.h>
+#include <wlr/types/wlr_xdg_shell.h>
+#include <wlr/types/wlr_xdg_decoration_v1.h>
+#ifdef XWAYLAND
+#include <xcb/xcb.h>
+#include <wlr/xwayland.h>
+#endif
+
+
+/* macros ********************************************************************/
+
+#define ME "goose"
+
+
+/* structures ****************************************************************/
+
+typedef enum {
+  LOG_QUIET = 0,
+  LOG_ERROR = 1,
+  LOG_INFO = 2,
+  LOG_DEBUG = 3,
+  LOG_LAST,
+} Verbosity;
+
+
+enum XwaylandAtom {
+  NET_WM_WINDOW_TYPE_NORMAL,
+  NET_WM_WINDOW_TYPE_DIALOG,
+  NET_WM_WINDOW_TYPE_UTILITY,
+  NET_WM_WINDOW_TYPE_TOOLBAR,
+  NET_WM_WINDOW_TYPE_SPLASH,
+  NET_WM_WINDOW_TYPE_MENU,
+  NET_WM_WINDOW_TYPE_DROPDOWN_MENU,
+  NET_WM_WINDOW_TYPE_POPUP_MENU,
+  NET_WM_WINDOW_TYPE_TOOLTIP,
+  NET_WM_WINDOW_TYPE_NOTIFICATION,
+  NET_WM_STATE_MODAL,
+  ATOM_LAST,
+};
+
+
+struct Xwayland {
+  struct wlr_xwayland* xwayland;
+  struct wlr_xcursor_manager* xcursor_manager;
+  xcb_atom_t atoms[ATOM_LAST];
+};
+
+
+struct Server {
+  struct wl_display*                      display;
+  struct wl_event_loop*                   event_loop;
+  const char*                             socket;
+  struct wlr_backend*                     backend;
+  struct wlr_backend*                     noop_backend;
+  struct wlr_backend*                     headless_backend;
+  struct wlr_compositor*                  compositor;
+  struct wl_listener                      compositor_new_surface;
+  struct wlr_data_device_manager*         data_device_manager;
+  // input_manager
+  struct wl_listener                      new_output;
+  //struct wl_listener                      output_layout_change;
+  struct wlr_idle*                        idle;
+  //struct wlr_idle_inhibit_v1*             idle_inhibit;
+  struct wlr_layer_shell_v1*              layer_shell;
+  struct wl_listener                      layer_shell_surface;
+  struct wlr_xdg_shell*                   xdg_shell;
+  struct wl_listener                      xdg_shell_surface;
+  #ifdef XWAYLAND
+  struct Xwayland                         xwayland;
+  struct wl_listener                      xwayland_surface;
+  struct wl_listener                      xwayland_ready;
+  #endif
+  struct wlr_relative_pointer_manager_v1* relative_pointer_manager;
+  struct wlr_server_decoration_manager*   server_decoration_manager;
+  struct wl_listener                      server_decoration;
+  struct wl_list                          server_decorations;
+  struct wlr_xdg_decoration_manager_v1*   xdg_decoration_manager;
+  struct wl_listener                      xdg_decoration;
+  struct wl_list                          xdg_decorations;
+  struct wlr_presentation*                presentation;
+  struct wlr_pointer_constraints_v1*      pointer_constraints;
+  struct wl_listener                      pointer_constraint;
+  struct wlr_output_manager_v1*           output_manager;
+  struct wl_listener                      output_manager_apply;
+  struct wl_listener                      output_manager_test;
+  struct wlr_output_power_manager_v1*     output_power_manager;
+  struct wl_listener                      output_power_manager_set_mode;
+  struct wlr_input_method_manager_v2*     input_method_manager;
+  struct wlr_text_input_manager_v3*       text_input_manager;
+  struct wlr_foreign_toplevel_manager_v1* foreign_toplevel_manager;
+  size_t txn_timeout_ms;
+  //list_t* dirty_nodes;
+};
+
+
+/* functions *****************************************************************/
+
+/* program */
+
+int argue(int argc, char** argv);
+void help(char* me, int code);
+void version(char* me);
+void handle_signal(int signal);
+
+/* log */
+
+void handle_error(int signal);
+void init_time(void);
+void init_log(Verbosity v);
+void honk(Verbosity v, const char* format, ...);
+void honk_va(Verbosity v, const char* format, va_list args);
+void _honk(Verbosity v, const char* format, va_list args);
+
+/* spawn */
+
+void spawn(char* child);
+
+/* bump */
+
+/* server */
+
+bool init_all(void);
+bool drop_root(void);
+bool prep_init(void);
+bool init_server(void);
+void init_ipc(struct Server* server);
+bool start_server(struct Server* server);
+void run_server(struct Server* server);
+void quit(int code);
+void fin_server(struct Server* server);
+
+/* desktop */
+
+void handle_destroy(struct wl_listener* listener, void* data);
+void handle_compositor_new_surface(struct wl_listener* listener, void* data);
+void handle_new_output(struct wl_listener* listener, void* data);
+void handle_output_layout_change(struct wl_listener* listener, void* data);
+void handle_layer_shell_surface(struct wl_listener* listener, void* data);
+void handle_xdg_shell_surface(struct wl_listener* listener, void* data);
+void handle_server_decoration(struct wl_listener* listener, void* data);
+void handle_xdg_decoration(struct wl_listener* listener, void* data);
+void handle_pointer_constraint(struct wl_listener* listener, void* data);
+void handle_output_manager_apply(struct wl_listener *listener, void *data);
+void handle_output_manager_test(struct wl_listener *listener, void *data);
+void handle_output_power_manager_set_mode(
+  struct wl_listener *listener, void *data);
+
+/* xwayland */
+
+#ifdef XWAYLAND
+void handle_xwayland_surface(struct wl_listener* listener, void* data);
+void handle_xwayland_ready(struct wl_listener* listener, void* data);
+#endif
+
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/layers.h	Tue Mar 09 07:18:07 2021 +0000
@@ -0,0 +1,59 @@
+#ifndef _GOOSE_LAYERS_H
+#define _GOOSE_LAYERS_H
+#include <stdbool.h>
+#include <wlr/types/wlr_box.h>
+#include <wlr/types/wlr_surface.h>
+#include <wlr/types/wlr_layer_shell_v1.h>
+
+enum layer_parent {
+	LAYER_PARENT_LAYER,
+	LAYER_PARENT_POPUP,
+};
+
+struct goose_layer_surface {
+	struct wlr_layer_surface_v1 *layer_surface;
+	struct wl_list link;
+
+	struct wl_listener destroy;
+	struct wl_listener map;
+	struct wl_listener unmap;
+	struct wl_listener surface_commit;
+	struct wl_listener output_destroy;
+	struct wl_listener new_popup;
+	struct wl_listener new_subsurface;
+
+	struct wlr_box geo;
+	enum zwlr_layer_shell_v1_layer layer;
+};
+
+struct goose_layer_popup {
+	struct wlr_xdg_popup *wlr_popup;
+	enum layer_parent parent_type;
+	union {
+		struct goose_layer_surface *parent_layer;
+		struct goose_layer_popup *parent_popup;
+	};
+	struct wl_listener map;
+	struct wl_listener unmap;
+	struct wl_listener destroy;
+	struct wl_listener commit;
+	struct wl_listener new_popup;
+};
+
+struct goose_layer_subsurface {
+	struct wlr_subsurface *wlr_subsurface;
+	struct goose_layer_surface *layer_surface;
+
+	struct wl_listener map;
+	struct wl_listener unmap;
+	struct wl_listener destroy;
+	struct wl_listener commit;
+};
+
+struct goose_output;
+void arrange_layers(struct goose_output *output);
+
+struct goose_layer_surface *layer_from_wlr_layer_surface_v1(
+	struct wlr_layer_surface_v1 *layer_surface);
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/makefile	Tue Mar 09 07:18:07 2021 +0000
@@ -0,0 +1,63 @@
+include config.mk
+idir = include
+pdir = protocols
+wpdir = /usr/share/wayland-protocols
+prtc = \
+	$(wpdir)/stable/xdg-shell/xdg-shell \
+	$(wpdir)/unstable/xdg-output/xdg-output-unstable-v1 \
+	$(pdir)/wlr-layer-shell-unstable-v1 \
+	$(pdir)/wlr-input-inhibitor-unstable-v1
+prts = \
+	$(wpdir)/unstable/pointer-constraints/pointer-constraints-unstable-v1 \
+	$(pdir)/idle \
+	$(pdir)/wlr-output-power-management-unstable-v1
+deps = \
+	gdk-pixbuf-2.0 \
+	json-c \
+	libevdev \
+	libinput \
+	pangocairo \
+	pixman-1 \
+	wayland-client \
+	wayland-cursor \
+	wayland-egl \
+	wayland-protocols \
+	wayland-server \
+	wlroots \
+	xcb \
+	xkbcommon
+CFLAGS += -std=c17 -I./$(idir) -I./$(bdir) -DWLR_USE_UNSTABLE
+CFLAGS += $(foreach p,$(deps),$(shell pkg-config --cflags $(p)))
+LDLIBS += $(foreach p,$(deps),$(shell pkg-config --libs $(p)))
+
+.DEFAULT_GOAL = all
+.PHONY: all clean prep scan
+
+all: prep goose
+
+prep:
+	if test ! -d $(bdir); then mkdir $(bdir); fi
+
+scan:
+	$(foreach p,$(prts),$(shell \
+		wayland-scanner private-code $(p).xml \
+			$(bdir)/$(shell basename $(p))-protocol.c; \
+		wayland-scanner server-header $(p).xml \
+			$(bdir)/$(shell basename $(p))-protocol.h))
+	$(foreach p,$(prtc),$(shell \
+		wayland-scanner private-code $(p).xml \
+			$(bdir)/$(shell basename $(p))-protocol.c; \
+		wayland-scanner server-header $(p).xml \
+			$(bdir)/$(shell basename $(p))-protocol.h; \
+		wayland-scanner client-header $(p).xml \
+			$(bdir)/$(shell basename $(p))-client-protocol.h))
+
+goose: scan goosebump
+	$(CC) $(CFLAGS) src/$@.c $(LDLIBS) -o $(bdir)/$@
+
+goosebump:
+	$(CC) $(CFLAGS) src/$@.c -shared -o $(bdir)/$@.so
+
+clean:
+	if test -d $(bdir); then rm -R $(bdir); fi
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/protocols/idle.xml	Tue Mar 09 07:18:07 2021 +0000
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<protocol name="idle">
+  <copyright><![CDATA[
+    Copyright (C) 2015 Martin Gräßlin
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU Lesser General Public License as published by
+    the Free Software Foundation, either version 2.1 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+  ]]></copyright>
+  <interface  name="org_kde_kwin_idle" version="1">
+      <description summary="User idle time manager">
+        This interface allows to monitor user idle time on a given seat. The interface
+        allows to register timers which trigger after no user activity was registered
+        on the seat for a given interval. It notifies when user activity resumes.
+
+        This is useful for applications wanting to perform actions when the user is not
+        interacting with the system, e.g. chat applications setting the user as away, power
+        management features to dim screen, etc..
+      </description>
+      <request name="get_idle_timeout">
+        <arg name="id" type="new_id" interface="org_kde_kwin_idle_timeout"/>
+        <arg name="seat" type="object" interface="wl_seat"/>
+        <arg name="timeout" type="uint" summary="The idle timeout in msec"/>
+      </request>
+  </interface>
+  <interface name="org_kde_kwin_idle_timeout" version="1">
+      <request name="release" type="destructor">
+        <description summary="release the timeout object"/>
+      </request>
+      <request name="simulate_user_activity">
+          <description summary="Simulates user activity for this timeout, behaves just like real user activity on the seat"/>
+      </request>
+      <event name="idle">
+          <description summary="Triggered when there has not been any user activity in the requested idle time interval"/>
+      </event>
+      <event name="resumed">
+          <description summary="Triggered on the first user activity after an idle event"/>
+      </event>
+  </interface>
+</protocol>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/protocols/wlr-input-inhibitor-unstable-v1.xml	Tue Mar 09 07:18:07 2021 +0000
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<protocol name="wlr_input_inhibit_unstable_v1">
+  <copyright>
+    Copyright © 2018 Drew DeVault
+
+    Permission to use, copy, modify, distribute, and sell this
+    software and its documentation for any purpose is hereby granted
+    without fee, provided that the above copyright notice appear in
+    all copies and that both that copyright notice and this permission
+    notice appear in supporting documentation, and that the name of
+    the copyright holders not be used in advertising or publicity
+    pertaining to distribution of the software without specific,
+    written prior permission.  The copyright holders make no
+    representations about the suitability of this software for any
+    purpose.  It is provided "as is" without express or implied
+    warranty.
+
+    THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+    SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+    FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+    SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+    WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+    AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+    ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+    THIS SOFTWARE.
+  </copyright>
+
+  <interface name="zwlr_input_inhibit_manager_v1" version="1">
+    <description summary="inhibits input events to other clients">
+      Clients can use this interface to prevent input events from being sent to
+      any surfaces but its own, which is useful for example in lock screen
+      software. It is assumed that access to this interface will be locked down
+      to whitelisted clients by the compositor.
+    </description>
+
+    <request name="get_inhibitor">
+      <description summary="inhibit input to other clients">
+        Activates the input inhibitor. As long as the inhibitor is active, the
+        compositor will not send input events to other clients.
+      </description>
+      <arg name="id" type="new_id" interface="zwlr_input_inhibitor_v1"/>
+    </request>
+
+    <enum name="error">
+      <entry name="already_inhibited" value="0" summary="an input inhibitor is already in use on the compositor"/>
+    </enum>
+  </interface>
+
+  <interface name="zwlr_input_inhibitor_v1" version="1">
+    <description summary="inhibits input to other clients">
+      While this resource exists, input to clients other than the owner of the
+      inhibitor resource will not receive input events. The client that owns
+      this resource will receive all input events normally. The compositor will
+      also disable all of its own input processing (such as keyboard shortcuts)
+      while the inhibitor is active.
+
+      The compositor may continue to send input events to selected clients,
+      such as an on-screen keyboard (via the input-method protocol).
+    </description>
+
+    <request name="destroy" type="destructor">
+      <description summary="destroy the input inhibitor object">
+        Destroy the inhibitor and allow other clients to receive input.
+      </description>
+    </request>
+  </interface>
+</protocol>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/protocols/wlr-layer-shell-unstable-v1.xml	Tue Mar 09 07:18:07 2021 +0000
@@ -0,0 +1,390 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<protocol name="wlr_layer_shell_unstable_v1">
+  <copyright>
+    Copyright © 2017 Drew DeVault
+
+    Permission to use, copy, modify, distribute, and sell this
+    software and its documentation for any purpose is hereby granted
+    without fee, provided that the above copyright notice appear in
+    all copies and that both that copyright notice and this permission
+    notice appear in supporting documentation, and that the name of
+    the copyright holders not be used in advertising or publicity
+    pertaining to distribution of the software without specific,
+    written prior permission.  The copyright holders make no
+    representations about the suitability of this software for any
+    purpose.  It is provided "as is" without express or implied
+    warranty.
+
+    THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+    SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+    FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+    SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+    WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+    AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+    ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+    THIS SOFTWARE.
+  </copyright>
+
+  <interface name="zwlr_layer_shell_v1" version="4">
+    <description summary="create surfaces that are layers of the desktop">
+      Clients can use this interface to assign the surface_layer role to
+      wl_surfaces. Such surfaces are assigned to a "layer" of the output and
+      rendered with a defined z-depth respective to each other. They may also be
+      anchored to the edges and corners of a screen and specify input handling
+      semantics. This interface should be suitable for the implementation of
+      many desktop shell components, and a broad number of other applications
+      that interact with the desktop.
+    </description>
+
+    <request name="get_layer_surface">
+      <description summary="create a layer_surface from a surface">
+        Create a layer surface for an existing surface. This assigns the role of
+        layer_surface, or raises a protocol error if another role is already
+        assigned.
+
+        Creating a layer surface from a wl_surface which has a buffer attached
+        or committed is a client error, and any attempts by a client to attach
+        or manipulate a buffer prior to the first layer_surface.configure call
+        must also be treated as errors.
+
+        After creating a layer_surface object and setting it up, the client
+        must perform an initial commit without any buffer attached.
+        The compositor will reply with a layer_surface.configure event.
+        The client must acknowledge it and is then allowed to attach a buffer
+        to map the surface.
+
+        You may pass NULL for output to allow the compositor to decide which
+        output to use. Generally this will be the one that the user most
+        recently interacted with.
+
+        Clients can specify a namespace that defines the purpose of the layer
+        surface.
+      </description>
+      <arg name="id" type="new_id" interface="zwlr_layer_surface_v1"/>
+      <arg name="surface" type="object" interface="wl_surface"/>
+      <arg name="output" type="object" interface="wl_output" allow-null="true"/>
+      <arg name="layer" type="uint" enum="layer" summary="layer to add this surface to"/>
+      <arg name="namespace" type="string" summary="namespace for the layer surface"/>
+    </request>
+
+    <enum name="error">
+      <entry name="role" value="0" summary="wl_surface has another role"/>
+      <entry name="invalid_layer" value="1" summary="layer value is invalid"/>
+      <entry name="already_constructed" value="2" summary="wl_surface has a buffer attached or committed"/>
+    </enum>
+
+    <enum name="layer">
+      <description summary="available layers for surfaces">
+        These values indicate which layers a surface can be rendered in. They
+        are ordered by z depth, bottom-most first. Traditional shell surfaces
+        will typically be rendered between the bottom and top layers.
+        Fullscreen shell surfaces are typically rendered at the top layer.
+        Multiple surfaces can share a single layer, and ordering within a
+        single layer is undefined.
+      </description>
+
+      <entry name="background" value="0"/>
+      <entry name="bottom" value="1"/>
+      <entry name="top" value="2"/>
+      <entry name="overlay" value="3"/>
+    </enum>
+
+    <!-- Version 3 additions -->
+
+    <request name="destroy" type="destructor" since="3">
+      <description summary="destroy the layer_shell object">
+        This request indicates that the client will not use the layer_shell
+        object any more. Objects that have been created through this instance
+        are not affected.
+      </description>
+    </request>
+  </interface>
+
+  <interface name="zwlr_layer_surface_v1" version="4">
+    <description summary="layer metadata interface">
+      An interface that may be implemented by a wl_surface, for surfaces that
+      are designed to be rendered as a layer of a stacked desktop-like
+      environment.
+
+      Layer surface state (layer, size, anchor, exclusive zone,
+      margin, interactivity) is double-buffered, and will be applied at the
+      time wl_surface.commit of the corresponding wl_surface is called.
+
+      Attaching a null buffer to a layer surface unmaps it.
+
+      Unmapping a layer_surface means that the surface cannot be shown by the
+      compositor until it is explicitly mapped again. The layer_surface
+      returns to the state it had right after layer_shell.get_layer_surface.
+      The client can re-map the surface by performing a commit without any
+      buffer attached, waiting for a configure event and handling it as usual.
+    </description>
+
+    <request name="set_size">
+      <description summary="sets the size of the surface">
+        Sets the size of the surface in surface-local coordinates. The
+        compositor will display the surface centered with respect to its
+        anchors.
+
+        If you pass 0 for either value, the compositor will assign it and
+        inform you of the assignment in the configure event. You must set your
+        anchor to opposite edges in the dimensions you omit; not doing so is a
+        protocol error. Both values are 0 by default.
+
+        Size is double-buffered, see wl_surface.commit.
+      </description>
+      <arg name="width" type="uint"/>
+      <arg name="height" type="uint"/>
+    </request>
+
+    <request name="set_anchor">
+      <description summary="configures the anchor point of the surface">
+        Requests that the compositor anchor the surface to the specified edges
+        and corners. If two orthogonal edges are specified (e.g. 'top' and
+        'left'), then the anchor point will be the intersection of the edges
+        (e.g. the top left corner of the output); otherwise the anchor point
+        will be centered on that edge, or in the center if none is specified.
+
+        Anchor is double-buffered, see wl_surface.commit.
+      </description>
+      <arg name="anchor" type="uint" enum="anchor"/>
+    </request>
+
+    <request name="set_exclusive_zone">
+      <description summary="configures the exclusive geometry of this surface">
+        Requests that the compositor avoids occluding an area with other
+        surfaces. The compositor's use of this information is
+        implementation-dependent - do not assume that this region will not
+        actually be occluded.
+
+        A positive value is only meaningful if the surface is anchored to one
+        edge or an edge and both perpendicular edges. If the surface is not
+        anchored, anchored to only two perpendicular edges (a corner), anchored
+        to only two parallel edges or anchored to all edges, a positive value
+        will be treated the same as zero.
+
+        A positive zone is the distance from the edge in surface-local
+        coordinates to consider exclusive.
+
+        Surfaces that do not wish to have an exclusive zone may instead specify
+        how they should interact with surfaces that do. If set to zero, the
+        surface indicates that it would like to be moved to avoid occluding
+        surfaces with a positive exclusive zone. If set to -1, the surface
+        indicates that it would not like to be moved to accommodate for other
+        surfaces, and the compositor should extend it all the way to the edges
+        it is anchored to.
+
+        For example, a panel might set its exclusive zone to 10, so that
+        maximized shell surfaces are not shown on top of it. A notification
+        might set its exclusive zone to 0, so that it is moved to avoid
+        occluding the panel, but shell surfaces are shown underneath it. A
+        wallpaper or lock screen might set their exclusive zone to -1, so that
+        they stretch below or over the panel.
+
+        The default value is 0.
+
+        Exclusive zone is double-buffered, see wl_surface.commit.
+      </description>
+      <arg name="zone" type="int"/>
+    </request>
+
+    <request name="set_margin">
+      <description summary="sets a margin from the anchor point">
+        Requests that the surface be placed some distance away from the anchor
+        point on the output, in surface-local coordinates. Setting this value
+        for edges you are not anchored to has no effect.
+
+        The exclusive zone includes the margin.
+
+        Margin is double-buffered, see wl_surface.commit.
+      </description>
+      <arg name="top" type="int"/>
+      <arg name="right" type="int"/>
+      <arg name="bottom" type="int"/>
+      <arg name="left" type="int"/>
+    </request>
+
+    <enum name="keyboard_interactivity">
+      <description summary="types of keyboard interaction possible for a layer shell surface">
+        Types of keyboard interaction possible for layer shell surfaces. The
+        rationale for this is twofold: (1) some applications are not interested
+        in keyboard events and not allowing them to be focused can improve the
+        desktop experience; (2) some applications will want to take exclusive
+        keyboard focus.
+      </description>
+
+      <entry name="none" value="0">
+        <description summary="no keyboard focus is possible">
+          This value indicates that this surface is not interested in keyboard
+          events and the compositor should never assign it the keyboard focus.
+
+          This is the default value, set for newly created layer shell surfaces.
+
+          This is useful for e.g. desktop widgets that display information or
+          only have interaction with non-keyboard input devices.
+        </description>
+      </entry>
+      <entry name="exclusive" value="1">
+        <description summary="request exclusive keyboard focus">
+          Request exclusive keyboard focus if this surface is above the shell surface layer.
+
+          For the top and overlay layers, the seat will always give
+          exclusive keyboard focus to the top-most layer which has keyboard
+          interactivity set to exclusive. If this layer contains multiple
+          surfaces with keyboard interactivity set to exclusive, the compositor
+          determines the one receiving keyboard events in an implementation-
+          defined manner. In this case, no guarantee is made when this surface
+          will receive keyboard focus (if ever).
+
+          For the bottom and background layers, the compositor is allowed to use
+          normal focus semantics.
+
+          This setting is mainly intended for applications that need to ensure
+          they receive all keyboard events, such as a lock screen or a password
+          prompt.
+        </description>
+      </entry>
+      <entry name="on_demand" value="2" since="4">
+        <description summary="request regular keyboard focus semantics">
+          This requests the compositor to allow this surface to be focused and
+          unfocused by the user in an implementation-defined manner. The user
+          should be able to unfocus this surface even regardless of the layer
+          it is on.
+
+          Typically, the compositor will want to use its normal mechanism to
+          manage keyboard focus between layer shell surfaces with this setting
+          and regular toplevels on the desktop layer (e.g. click to focus).
+          Nevertheless, it is possible for a compositor to require a special
+          interaction to focus or unfocus layer shell surfaces (e.g. requiring
+          a click even if focus follows the mouse normally, or providing a
+          keybinding to switch focus between layers).
+
+          This setting is mainly intended for desktop shell components (e.g.
+          panels) that allow keyboard interaction. Using this option can allow
+          implementing a desktop shell that can be fully usable without the
+          mouse.
+        </description>
+      </entry>
+    </enum>
+
+    <request name="set_keyboard_interactivity">
+      <description summary="requests keyboard events">
+        Set how keyboard events are delivered to this surface. By default,
+        layer shell surfaces do not receive keyboard events; this request can
+        be used to change this.
+
+        This setting is inherited by child surfaces set by the get_popup
+        request.
+
+        Layer surfaces receive pointer, touch, and tablet events normally. If
+        you do not want to receive them, set the input region on your surface
+        to an empty region.
+
+        Keyboard interactivity is double-buffered, see wl_surface.commit.
+      </description>
+      <arg name="keyboard_interactivity" type="uint" enum="keyboard_interactivity"/>
+    </request>
+
+    <request name="get_popup">
+      <description summary="assign this layer_surface as an xdg_popup parent">
+        This assigns an xdg_popup's parent to this layer_surface.  This popup
+        should have been created via xdg_surface::get_popup with the parent set
+        to NULL, and this request must be invoked before committing the popup's
+        initial state.
+
+        See the documentation of xdg_popup for more details about what an
+        xdg_popup is and how it is used.
+      </description>
+      <arg name="popup" type="object" interface="xdg_popup"/>
+    </request>
+
+    <request name="ack_configure">
+      <description summary="ack a configure event">
+        When a configure event is received, if a client commits the
+        surface in response to the configure event, then the client
+        must make an ack_configure request sometime before the commit
+        request, passing along the serial of the configure event.
+
+        If the client receives multiple configure events before it
+        can respond to one, it only has to ack the last configure event.
+
+        A client is not required to commit immediately after sending
+        an ack_configure request - it may even ack_configure several times
+        before its next surface commit.
+
+        A client may send multiple ack_configure requests before committing, but
+        only the last request sent before a commit indicates which configure
+        event the client really is responding to.
+      </description>
+      <arg name="serial" type="uint" summary="the serial from the configure event"/>
+    </request>
+
+    <request name="destroy" type="destructor">
+      <description summary="destroy the layer_surface">
+        This request destroys the layer surface.
+      </description>
+    </request>
+
+    <event name="configure">
+      <description summary="suggest a surface change">
+        The configure event asks the client to resize its surface.
+
+        Clients should arrange their surface for the new states, and then send
+        an ack_configure request with the serial sent in this configure event at
+        some point before committing the new surface.
+
+        The client is free to dismiss all but the last configure event it
+        received.
+
+        The width and height arguments specify the size of the window in
+        surface-local coordinates.
+
+        The size is a hint, in the sense that the client is free to ignore it if
+        it doesn't resize, pick a smaller size (to satisfy aspect ratio or
+        resize in steps of NxM pixels). If the client picks a smaller size and
+        is anchored to two opposite anchors (e.g. 'top' and 'bottom'), the
+        surface will be centered on this axis.
+
+        If the width or height arguments are zero, it means the client should
+        decide its own window dimension.
+      </description>
+      <arg name="serial" type="uint"/>
+      <arg name="width" type="uint"/>
+      <arg name="height" type="uint"/>
+    </event>
+
+    <event name="closed">
+      <description summary="surface should be closed">
+        The closed event is sent by the compositor when the surface will no
+        longer be shown. The output may have been destroyed or the user may
+        have asked for it to be removed. Further changes to the surface will be
+        ignored. The client should destroy the resource after receiving this
+        event, and create a new surface if they so choose.
+      </description>
+    </event>
+
+    <enum name="error">
+      <entry name="invalid_surface_state" value="0" summary="provided surface state is invalid"/>
+      <entry name="invalid_size" value="1" summary="size is invalid"/>
+      <entry name="invalid_anchor" value="2" summary="anchor bitfield is invalid"/>
+      <entry name="invalid_keyboard_interactivity" value="3" summary="keyboard interactivity is invalid"/>
+    </enum>
+
+    <enum name="anchor" bitfield="true">
+      <entry name="top" value="1" summary="the top edge of the anchor rectangle"/>
+      <entry name="bottom" value="2" summary="the bottom edge of the anchor rectangle"/>
+      <entry name="left" value="4" summary="the left edge of the anchor rectangle"/>
+      <entry name="right" value="8" summary="the right edge of the anchor rectangle"/>
+    </enum>
+
+    <!-- Version 2 additions -->
+
+    <request name="set_layer" since="2">
+      <description summary="change the layer of the surface">
+        Change the layer that the surface is rendered on.
+
+        Layer is double-buffered, see wl_surface.commit.
+      </description>
+      <arg name="layer" type="uint" enum="zwlr_layer_shell_v1.layer" summary="layer to move this surface to"/>
+    </request>
+  </interface>
+</protocol>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/protocols/wlr-output-power-management-unstable-v1.xml	Tue Mar 09 07:18:07 2021 +0000
@@ -0,0 +1,128 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<protocol name="wlr_output_power_management_unstable_v1">
+  <copyright>
+    Copyright © 2019 Purism SPC
+
+    Permission is hereby granted, free of charge, to any person obtaining a
+    copy of this software and associated documentation files (the "Software"),
+    to deal in the Software without restriction, including without limitation
+    the rights to use, copy, modify, merge, publish, distribute, sublicense,
+    and/or sell copies of the Software, and to permit persons to whom the
+    Software is furnished to do so, subject to the following conditions:
+
+    The above copyright notice and this permission notice (including the next
+    paragraph) shall be included in all copies or substantial portions of the
+    Software.
+
+    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+    THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+    DEALINGS IN THE SOFTWARE.
+  </copyright>
+
+  <description summary="Control power management modes of outputs">
+    This protocol allows clients to control power management modes
+    of outputs that are currently part of the compositor space. The
+    intent is to allow special clients like desktop shells to power
+    down outputs when the system is idle.
+
+    To modify outputs not currently part of the compositor space see
+    wlr-output-management.
+
+    Warning! The protocol described in this file is experimental and
+    backward incompatible changes may be made. Backward compatible changes
+    may be added together with the corresponding interface version bump.
+    Backward incompatible changes are done by bumping the version number in
+    the protocol and interface names and resetting the interface version.
+    Once the protocol is to be declared stable, the 'z' prefix and the
+    version number in the protocol and interface names are removed and the
+    interface version number is reset.
+  </description>
+
+  <interface name="zwlr_output_power_manager_v1" version="1">
+    <description summary="manager to create per-output power management">
+      This interface is a manager that allows creating per-output power
+      management mode controls.
+    </description>
+
+    <request name="get_output_power">
+      <description summary="get a power management for an output">
+        Create a output power management mode control that can be used to
+        adjust the power management mode for a given output.
+      </description>
+      <arg name="id" type="new_id" interface="zwlr_output_power_v1"/>
+      <arg name="output" type="object" interface="wl_output"/>
+    </request>
+
+    <request name="destroy" type="destructor">
+      <description summary="destroy the manager">
+        All objects created by the manager will still remain valid, until their
+        appropriate destroy request has been called.
+      </description>
+    </request>
+  </interface>
+
+  <interface name="zwlr_output_power_v1" version="1">
+    <description summary="adjust power management mode for an output">
+      This object offers requests to set the power management mode of
+      an output.
+    </description>
+
+    <enum name="mode">
+      <entry name="off" value="0"
+             summary="Output is turned off."/>
+      <entry name="on" value="1"
+             summary="Output is turned on, no power saving"/>
+    </enum>
+
+    <enum name="error">
+      <entry name="invalid_mode" value="1" summary="inexistent power save mode"/>
+    </enum>
+
+    <request name="set_mode">
+      <description summary="Set an outputs power save mode">
+        Set an output's power save mode to the given mode. The mode change
+        is effective immediately. If the output does not support the given
+        mode a failed event is sent.
+      </description>
+      <arg name="mode" type="uint" enum="mode" summary="the power save mode to set"/>
+    </request>
+
+    <event name="mode">
+      <description summary="Report a power management mode change">
+        Report the power management mode change of an output.
+
+        The mode event is sent after an output changed its power
+        management mode. The reason can be a client using set_mode or the
+        compositor deciding to change an output's mode.
+        This event is also sent immediately when the object is created
+        so the client is informed about the current power management mode.
+      </description>
+      <arg name="mode" type="uint" enum="mode"
+           summary="the output's new power management mode"/>
+    </event>
+
+    <event name="failed">
+      <description summary="object no longer valid">
+        This event indicates that the output power management mode control
+        is no longer valid. This can happen for a number of reasons,
+        including:
+        - The output doesn't support power management
+        - Another client already has exclusive power management mode control
+          for this output
+        - The output disappeared
+
+        Upon receiving this event, the client should destroy this object.
+      </description>
+    </event>
+
+    <request name="destroy" type="destructor">
+      <description summary="destroy this power management">
+        Destroys the output power management mode control object.
+      </description>
+    </request>
+  </interface>
+</protocol>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/bump.tcl	Tue Mar 09 07:18:07 2021 +0000
@@ -0,0 +1,6 @@
+#! /usr/bin/env tclsh
+
+load ./goosebump[info sharedlibextension]
+set foo [hello]
+puts $foo
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/goose.c	Tue Mar 09 07:18:07 2021 +0000
@@ -0,0 +1,608 @@
+#define _POSIX_C_SOURCE 201710L
+#include <fcntl.h>
+#include <getopt.h>
+#include <pango/pangocairo.h>
+#include <signal.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include "goose.h"
+
+
+/* globals *******************************************************************/
+
+struct Server   _server = {0};
+int             _ipc_socket = -1;
+struct timespec _start_time = {-1, -1};
+Verbosity       _verbosity = LOG_LAST;
+bool            _colored = true;
+
+const char* log_colors[] = {
+  [LOG_QUIET] = "",
+  [LOG_ERROR] = "\x1B[1;31m",
+  [LOG_INFO]  = "\x1B[1;32m",
+  [LOG_DEBUG] = "\x1B[1;34m",
+};
+const char* log_tags[] = {
+  [LOG_QUIET] = "",
+  [LOG_ERROR] = "[ERROR]",
+  [LOG_INFO]  = "[INFO]",
+  [LOG_DEBUG] = "[DEBUG]",
+};
+
+
+/* entry *********************************************************************/
+
+int
+main(int argc, char** argv)
+{
+  int a;
+  if (0 != (a = argue(argc, argv))) {
+    exit(0 > a ? EXIT_FAILURE : EXIT_SUCCESS);
+  }
+  if (!init_all()) {
+    exit(EXIT_FAILURE);
+  }
+  if (!start_server(&_server)) {
+    quit(EXIT_FAILURE);
+  }
+  spawn("imv");
+  run_server(&_server);
+  quit(EXIT_SUCCESS);
+}
+
+
+int
+argue(int argc, char** argv)
+{
+  int opt;
+  struct option longs[] = {
+    { "help", 0, NULL, 'h' },
+    { "quiet", 0, NULL, 'q' },
+    { "verbose", 0, NULL, 'v' },
+    { "version", 0, NULL, 'V' }
+  };
+
+  while ((opt = getopt_long(argc, argv, "hv", longs, NULL)) != -1) {
+    if ('h' == opt) {
+      help(argv[0], EXIT_SUCCESS);
+      return 1;
+    } else if ('q' == opt) {
+      _verbosity = LOG_QUIET;
+    } else if ('v' == opt) {
+      _verbosity = LOG_INFO;
+      // count 'v's: debug
+    } else if ('V' == opt) {
+      version(argv[0]);
+      return 1;
+    } else {
+      help(argv[0], EXIT_FAILURE);
+      return -1;
+    }
+  }
+  if (optind < argc) {
+    help(argv[0], EXIT_FAILURE);
+    return -1;
+  }
+  return 0;
+}
+
+
+void
+help(char* me, int code)
+{
+  fprintf(EXIT_SUCCESS == code ? stdout : stderr,
+          "Usage: %s -[hv]\n\
+  -h --help     show this help\n\
+  -v --version  show version", me);
+}
+
+
+void
+version(char* me)
+{
+  fprintf(stdout, "%s 0.1", me);
+}
+
+
+void
+handle_signal(int signal)
+{
+  quit(EXIT_SUCCESS);
+}
+
+
+/* log ***********************************************************************/
+
+void
+init_log()
+{
+  init_time();
+  // TODO
+}
+
+
+void
+init_time(void)
+{
+  if (0 <= _start_time.tv_sec) {
+    return;
+  }
+  clock_gettime(CLOCK_MONOTONIC, &_start_time);
+}
+
+
+void
+honk(Verbosity v, const char* format, ...)
+{
+  va_list args;
+  va_start(args, format);
+  _honk(v, format, args);
+  va_end(args);
+}
+
+
+void
+honk_va(Verbosity v, const char* format, va_list args)
+{
+  _honk(v, format, args);
+}
+
+
+void
+_honk(Verbosity v, const char* format, va_list args)
+{
+  init_time();
+  if (v > _verbosity) {
+    return;
+  }
+  unsigned c = (LOG_LAST > v) ? v : LOG_LAST - 1;
+  bool colored = _colored && isatty(STDERR_FILENO);
+  if (colored) {
+    fprintf(stderr, "%s", log_colors[c]);
+  }
+  fprintf(stderr, "%s%s ", ME, log_tags[c]);
+  vfprintf(stderr, format, args);
+  if (colored) {
+    fprintf(stderr, "\x1B[0m");
+  }
+  fprintf(stderr, "\n");
+}
+
+
+/* spawn *********************************************************************/
+
+void
+spawn(char* c)
+{
+  honk(LOG_DEBUG, "spawning child: %s", c);
+  int p[2];
+  if (0 != pipe(p)) {
+    honk(LOG_ERROR, "cannot create pipe for fork");
+  }
+  pid_t pid = -1;
+  pid_t child = -1;
+  if (0 == (pid = fork())) {
+    setsid();
+    sigset_t set;
+    sigemptyset(&set);
+    sigprocmask(SIG_SETMASK, &set, NULL);
+    close(p[0]);
+    if (0 == (child = fork())) {
+      close(p[1]);
+      honk(LOG_DEBUG, "starting imv");
+      execl("/bin/sh", "/bin/sh", "-c", c, (void*)NULL);
+      exit(0);
+    }
+    close(p[1]);
+    exit(0);
+  } else if (0 > pid) {
+    close(p[0]);
+    close(p[1]);
+    honk(LOG_ERROR, "cannot fork");
+    return;
+  }
+  close(p[1]);
+  close(p[0]);
+  waitpid(pid, NULL, 0);
+  if (0 < child) {
+    honk(LOG_DEBUG, "child created with pid: %d", child);
+  }
+}
+
+
+/* bump **********************************************************************/
+
+
+/* up ************************************************************************/
+
+bool
+init_all(void) {
+  init_log(_verbosity);
+
+  if (!getenv("XDG_RUNTIME_DIR")) {
+    honk(LOG_ERROR, "XDG_RUNTIME_DIR must be set");
+    return false;
+  }
+
+  if (!drop_root()) {
+    return false;
+  }
+
+  signal(SIGTERM, handle_signal);
+  signal(SIGINT, handle_signal);
+  signal(SIGPIPE, SIG_IGN);
+
+  prep_init();
+  init_server();
+  init_ipc(&_server);
+  setenv("WAYLAND_DISPLAY", _server.socket, true);
+
+  return true;
+}
+
+
+bool
+drop_root(void)
+{
+  if (getuid() != geteuid() || getgid() != getegid()) {
+    // set gid first
+    if (0 != setgid(getgid())) {
+      honk(LOG_ERROR, "cannot drop root group");
+      return false;
+    }
+    if (0 != setuid(getuid())) {
+      honk(LOG_ERROR, "cannot drop root user");
+      return false;
+    }
+  }
+  if (-1 != setgid(0) || -1 != setuid(0)) {
+    honk(LOG_ERROR, "cannot drop root");
+    return false;
+  }
+  return true;
+}
+
+
+bool
+prep_init(void)
+{
+  honk(LOG_DEBUG, "preparing server init");
+  _server.display = wl_display_create();
+  _server.event_loop = wl_display_get_event_loop(_server.display);
+  _server.backend = wlr_backend_autocreate(_server.display, NULL);
+  if (!_server.backend) {
+    honk(LOG_ERROR, "cannot create backend");
+    return false;
+  }
+  return true;
+}
+
+
+bool
+init_server(void)
+{
+  honk(LOG_DEBUG, "initialising server");
+  struct wlr_renderer* renderer = wlr_backend_get_renderer(_server.backend);
+  // TODO: what if no renderer?
+  wlr_renderer_init_wl_display(renderer, _server.display);
+  _server.compositor = wlr_compositor_create(_server.display, renderer);
+  _server.compositor_new_surface.notify = handle_compositor_new_surface;
+  wl_signal_add(&_server.compositor->events.new_surface,
+                &_server.compositor_new_surface);
+  _server.data_device_manager =
+    wlr_data_device_manager_create(_server.display);
+  wlr_gamma_control_manager_v1_create(_server.display);
+  _server.new_output.notify = handle_new_output;
+  wl_signal_add(&_server.backend->events.new_output, &_server.new_output);
+  //_server.output_layout_change.notify = handle_output_layout_change;
+  //wlr_xdg_output_manager_v1_create(_server.display);
+  _server.idle = wlr_idle_create(_server.display);
+  //_server.idle_inhibit_manager = sway_
+  _server.layer_shell = wlr_layer_shell_v1_create(_server.display);
+  wl_signal_add(&_server.layer_shell->events.new_surface,
+                &_server.layer_shell_surface);
+  _server.layer_shell_surface.notify = handle_layer_shell_surface;
+  _server.xdg_shell = wlr_xdg_shell_create(_server.display);
+  wl_signal_add(&_server.xdg_shell->events.new_surface,
+                &_server.xdg_shell_surface);
+  _server.xdg_shell_surface.notify = handle_xdg_shell_surface;
+  _server.server_decoration_manager =
+    wlr_server_decoration_manager_create(_server.display);
+  wlr_server_decoration_manager_set_default_mode(
+    _server.server_decoration_manager,
+    WLR_SERVER_DECORATION_MANAGER_MODE_SERVER);
+  wl_signal_add(&_server.server_decoration_manager->events.new_decoration,
+                &_server.server_decoration);
+  _server.server_decoration.notify = handle_server_decoration;
+  wl_list_init(&_server.server_decorations);
+  _server.xdg_decoration_manager =
+    wlr_xdg_decoration_manager_v1_create(_server.display);
+  wl_signal_add(
+    &_server.xdg_decoration_manager->events.new_toplevel_decoration,
+    &_server.xdg_decoration);
+  _server.xdg_decoration.notify = handle_xdg_decoration;
+  wl_list_init(&_server.xdg_decorations);
+  _server.relative_pointer_manager =
+    wlr_relative_pointer_manager_v1_create(_server.display);
+  _server.pointer_constraints =
+    wlr_pointer_constraints_v1_create(_server.display);
+  _server.pointer_constraint.notify = handle_pointer_constraint;
+  wl_signal_add(&_server.pointer_constraints->events.new_constraint,
+                &_server.pointer_constraint);
+  _server.presentation =
+    wlr_presentation_create(_server.display, _server.backend);
+  _server.output_manager =
+    wlr_output_manager_v1_create(_server.display);
+  _server.output_manager_apply.notify = handle_output_manager_apply;
+  wl_signal_add(&_server.output_manager->events.apply,
+                &_server.output_manager_apply);
+  _server.output_manager_test.notify = handle_output_manager_test;
+  wl_signal_add(&_server.output_manager->events.test,
+                &_server.output_manager_test);
+  _server.output_power_manager =
+    wlr_output_power_manager_v1_create(_server.display);
+  _server.output_power_manager_set_mode.notify =
+    handle_output_power_manager_set_mode;
+  wl_signal_add(&_server.output_power_manager->events.set_mode,
+                &_server.output_power_manager_set_mode);
+  _server.input_method_manager =
+    wlr_input_method_manager_v2_create(_server.display);
+  _server.text_input_manager =
+    wlr_text_input_manager_v3_create(_server.display);
+  _server.foreign_toplevel_manager =
+    wlr_foreign_toplevel_manager_v1_create(_server.display);
+  wlr_export_dmabuf_manager_v1_create(_server.display);
+  wlr_screencopy_manager_v1_create(_server.display);
+  wlr_data_control_manager_v1_create(_server.display);
+  wlr_primary_selection_v1_device_manager_create(_server.display);
+  wlr_viewporter_create(_server.display);
+
+  char name[16];
+  for (int i = 1; i <= 32; ++i) {
+    sprintf(name, "wayland-%d", i);
+    if (0 <= wl_display_add_socket(_server.display, name)) {
+      _server.socket = strdup(name);
+      break;
+    }
+  }
+  if (!_server.socket) {
+    honk(LOG_ERROR, "cannot open wayland socket");
+    wlr_backend_destroy(_server.backend);
+    return false;
+  }
+
+  _server.noop_backend = wlr_noop_backend_create(_server.display);
+  struct wlr_output* output = wlr_noop_add_output(_server.noop_backend);
+  _server.headless_backend =
+    wlr_headless_backend_create_with_renderer(_server.display, renderer);
+  if (!_server.headless_backend) {
+    honk(LOG_INFO, "cannot create headless backend, starting without");
+  } else {
+    wlr_multi_backend_add(_server.backend, _server.headless_backend);
+  }
+
+  if (!_server.txn_timeout_ms) {
+    _server.txn_timeout_ms = 200;
+  }
+  //_server.dirty_nodes = create_list();
+  //_server.input = input_manager_create(_server);
+  //input_manager_get_default_seat();
+
+  return true;
+}
+
+
+void
+init_ipc(struct Server* server)
+{
+  _ipc_socket = socket(AF_UNIX, SOCK_STREAM, 0);
+  if (-1 == _ipc_socket) {
+    honk(LOG_ERROR, "cannot create ipc socket");
+    quit(EXIT_FAILURE);
+  }
+  if (-1 == fcntl(_ipc_socket, F_SETFD, FD_CLOEXEC)) {
+    honk(LOG_ERROR, "cannot set CLOEXEC on ipc socket");
+    quit(EXIT_FAILURE);
+  }
+  if (-1 == fcntl(_ipc_socket, F_SETFL, O_NONBLOCK)) {
+    honk(LOG_ERROR, "cannot set NONBLOCK on ipc socket");
+    quit(EXIT_FAILURE);
+  }
+}
+
+
+bool
+start_server(struct Server* server)
+{
+#ifdef XWAYLAND
+  server->xwayland.xwayland =
+    wlr_xwayland_create(server->display, server->compositor,
+                        false); // XWAYLAND_MODE_LAZY
+  if (!server->xwayland.xwayland) {
+    honk(LOG_ERROR, "cannot start xwayland");
+    unsetenv("DISPLAY");
+  } else {
+    wl_signal_add(&server->xwayland.xwayland->events.new_surface,
+                  &server->xwayland_surface);
+    server->xwayland_surface.notify = handle_xwayland_surface;
+    wl_signal_add(&server->xwayland.xwayland->events.ready,
+                  &server->xwayland_ready);
+    server->xwayland_ready.notify = handle_xwayland_ready;
+    setenv("DISPLAY", server->xwayland.xwayland->display_name, true);
+    /* xcursor configured by default seat */
+  }
+#endif
+  honk(LOG_INFO, "starting backend on display: %s", server->socket);
+  if (!wlr_backend_start(server->backend)) {
+    honk(LOG_INFO, "cannot start backend");
+    wlr_backend_destroy(server->backend);
+    return false;
+  }
+  return true;
+}
+
+
+void
+run_server(struct Server* server)
+{
+  honk(LOG_INFO, "running %s on display: %s", ME, server->socket);
+  wl_display_run(server->display);
+}
+
+
+/* down **********************************************************************/
+
+void
+quit(int code) {
+  if (!_server.display) {
+    // ipc client
+    exit(code);
+  }
+  // server
+  wl_display_terminate(_server.display);
+  honk(LOG_INFO, "stopping %s on display: %s", ME, _server.socket);
+  fin_server(&_server);
+  pango_cairo_font_map_set_default(NULL);
+  exit(code);
+}
+
+
+void
+fin_server(struct Server* server) {
+#ifdef XWAYLAND
+  wlr_xwayland_destroy(server->xwayland.xwayland);
+#endif
+  wl_display_destroy_clients(server->display);
+  wl_display_destroy(server->display);
+}
+
+
+/* desktop *******************************************************************/
+
+void
+handle_destroy(struct wl_listener* listener, void* data) {
+  // TODO
+}
+
+
+void
+handle_compositor_new_surface(struct wl_listener* listener, void* data) {
+  struct wlr_surface* surface = data;
+  // TODO
+}
+
+
+void
+handle_new_output(struct wl_listener* listener, void* data) {
+  struct wlr_output* output = data;
+  // TODO
+}
+
+
+void
+handle_output_layout_change(struct wl_listener* listener, void* data) {
+  //struct Server* server =
+  //  wl_container_of(listener, server, output_layout_change);
+}
+
+
+void
+handle_layer_shell_surface(struct wl_listener* listener, void* data) {
+  struct wlr_layer_surface_v1* surface = data;
+  // TODO
+}
+
+
+void
+handle_xdg_shell_surface(struct wl_listener* listener, void* data) {
+  struct wlr_xdg_surface* surface = data;
+  // TODO
+}
+
+
+void
+handle_server_decoration(struct wl_listener* listener, void* data) {
+  struct wlr_server_decoration* decoration = data;
+  // TODO
+}
+
+
+void
+handle_xdg_decoration(struct wl_listener* listener, void* data) {
+  struct wlr_xdg_toplevel_decoration_v1* decoration = data;
+  // TODO
+}
+
+
+void
+handle_pointer_constraint(struct wl_listener* listener, void* data) {
+  struct wlr_pointer_constraint_v1* coinstraint = data;
+  // TODO
+}
+
+
+void
+handle_output_manager_apply(struct wl_listener *listener, void *data) {
+  struct wlr_output_configuration_v1* config = data;
+  // TODO
+}
+
+
+void
+handle_output_manager_test(struct wl_listener *listener, void *data) {
+  struct wlr_output_configuration_v1* config = data;
+  // TODO
+}
+
+
+void
+handle_output_power_manager_set_mode(
+  struct wl_listener *listener, void *data
+) {
+  struct wlr_output_power_v1_set_mode_event* event = data;
+  // TODO
+}
+
+
+/* xwayland ******************************************************************/
+
+// TODO: return object
+void
+create_unmanaged(struct wlr_xwayland_surface* surface)
+{
+  return;
+}
+
+
+// TODO: return object
+void
+create_xwayland_view(struct wlr_xwayland_surface* surface)
+{
+  return;
+}
+
+
+void
+handle_xwayland_surface(struct wl_listener* listener, void* data)
+{
+  struct wlr_xwayland_surface* surface = data;
+  if (surface->override_redirect) {
+    honk(LOG_DEBUG, "new xwayland unmanaged surface");
+    create_unmanaged(surface);
+    return;
+  }
+  create_xwayland_view(surface);
+}
+
+
+void
+handle_xwayland_ready(struct wl_listener* listener, void* data)
+{
+  struct Server* server = wl_container_of(listener, server, xwayland_ready);
+  struct Xwayland* xwayland = &server->xwayland;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/goosebump.c	Tue Mar 09 07:18:07 2021 +0000
@@ -0,0 +1,22 @@
+#include <tcl.h>
+
+#define USE_TCL_STUBS
+
+static int
+Hello_Cmd(ClientData data, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[])
+{
+  Tcl_SetObjResult(interp, Tcl_NewStringObj("Hello, World!", -1));
+  return TCL_OK;
+}
+
+int DLLEXPORT
+Goosebump_Init(Tcl_Interp* interp)
+{
+  if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL
+      || Tcl_PkgProvide(interp, "Hello", "1.0") == TCL_ERROR) {
+    return TCL_ERROR;
+  }
+  Tcl_CreateObjCommand(interp, "hello", Hello_Cmd, NULL, NULL);
+  return TCL_OK;
+}
+