Giter VIP home page Giter VIP logo

home-service-dwl-guile's Introduction

A dwl-guile home service for GNU Guix

This repository contains a Guix Home service which installs and configures dwl-guile , a patched version of dwl that is configured in GNU Guile. You can install our home service with the help of the Guix channel below.

The main goal of dwl-guile is to serve as a minimal dwm-like Wayland compositor for those who use GNU Guix System — a GNU/Linux distribution in which the user can customize and configure their entire system in GNU Guile.

With dwl-guile, we can integrate the window manager customization with that of the rest of the system, which allows for a dynamic, programmable and reproducible configuration for our entire computing environment — all in Guile.

This is a work in progress — please report bugs to us and (if applicable) to upstream dwl!

Features

This Guix Home service can:

  • install dwl-guile
  • automatically start dwl-guile on the first TTY you log in to
  • set necessary environment variables for Wayland support in GTK, Java, etc
  • apply (some) other common dwl patches dynamically
  • configure all options in dwl (in an Emacs-esque way) with Guile

Guix channel

We provide home-service-dwl-guile in a Guix channel.

Add the channel to your ~/.config/guix/channels.scm:

(channel
  (name 'home-service-dwl-guile)
  (url "https://github.com/engstrand-config/home-service-dwl-guile")
  (branch "main")
  (introduction
    (make-channel-introduction
      "314453a87634d67e914cfdf51d357638902dd9fe"
      (openpgp-fingerprint
        "C9BE B8A0 4458 FDDF 1268 1B39 029D 8EB7 7E18 D68C"))))

Afterwards, run guix pull.

Usage

Home service configuration

home-service-dwl-guile is enabled by adding it to your list of home services.

;; Import the service
(use-modules (dwl-guile home-service)
             (dwl-guile patches)) ; import if you want to apply patches dynamically

;; Create and add the dwl-guile home service to your home configuration.
(service home-dwl-guile-service-type
         ;; If you wish to configure the home service further, you can pass in
         ;; a configuration to the service. All options listed below are optional.
         (home-dwl-guile-configuration
          ;; Use a custom dwl-guile package.
          (package my-custom-dwl)

          ;; If you want to dynamically apply patches, you can create a new
          ;; modified package definition (multiple patches can be applied).
          ;; Note that some patches might have conflicts.
          ;;
          ;; (package
          ;;  (patch-dwl-guile-package dwl-guile
          ;;                           #:patches (list %patch-xwayland)))

          ;; Environment variables to set for Wayland compatibility with applications.
          ;; By default, native Wayland rendering will be enabled for most applications.
          ;; Native rendering of QT-applications is enabled using the @code{native-qt?}
          ;; option. This is because it requires the qtwayland package.
          ;;
          ;; Set it to an empty list to skip setting environment variables:
          ;; (environment-variables '())
          ;;
          ;; Or extend the default environment variables:
          ;; (environment-variables
          ;;  (append `(("var" . "value")) %dwl-guile-base-env-variables))

          ;; A string containing a command to execute after starting dwl-guile.
          ;; This is the equivalent of specifying a script to the '-s' flag of dwl.
          ;; The gexp's will be executed in the same order as in the list.
          ;;
          ;; The preferred way of running commands/applications (that does not need
          ;; to access the stdout of dwl) on startup is by using the
          ;; dwl:startup-hook in your Guile config.
          ;;
          ;; By default, this option is not used.
          (startup-command "foot --server <&-")

          ;; If QT-applications should be rendered natively. Enabled by default.
          ;; This will set QT_QPA_PLATFORM="wayland-egl" and install
          ;; the "qtwayland" package to enable support for Wayland.
          (native-qt? #t)

          ;; If dwl-guile should auto-start on first login. Enabled by default.
          (auto-start? #t)

          ;; If the dwl-guile config should be automatically reloaded on change.
          ;; This will allow you to see (most of) the effects of your config changes
          ;; dynamically, without restarting dwl-guile.
          (reload-config-on-change? #t)

          ;; Create a custom configuration for dwl.
          (config '())

Shepherd service

After enabling the dwl-guile home service and reconfiguring, a new Shepherd service will be added. This allows you to control the dwl-guile executable using herd.

For example:

herd start dwl-guile
herd stop dwl-guile
herd restart dwl-guile

Using these commands, dwl-guile will start with the correct options. Logs are available at $XDG_LOG_HOME/dwl-guile.log. If the XDG environment variable is not set, the log will be saved to your HOME directory.

Runtime evaluation of Guile expressions

As of v2.0.0, you can execute arbitrary GNU Guile expressions in the context of dwl-guile during runtime. This allows for some scripting capabilities, as well as dynamic changes of the config.

Executing an expression is done using the dwl-guile executable, like so:

dwl-guile -e "(dwl:reload-config)"

The result of the evaluation will be shown in stdout, or in stderr if an error occured. These types of evaluations will be executed in their thread, which means that it will not block dwl-guile. In other words, you can safely run commands that run for a longer time. Note that the expression is not evaluated in a shell context, which means that procedures such as system* will not work, but you can always use dwl:shcmd or dwl:spawn instead.

Using the Guile REPL for interacting with dwl-guile

During runtime, it is possible to use the Guile REPL to interact with dwl-guile. In order to do this, you need to explicitly start the REPL server in your config by calling (dwl:start-repl-server). You can then connect to the server in e.g. Emacs using Geiser.

For more information, see the man pages (man dwl-guile).

Configuring dwl-guile

Using dwl-guile, all configuration is done in Guile by providing an alist of (Emacs-like) commands to the config field of the home service configuration.

A minimal set of keybindings will automatically be loaded, unless inhibitied using (setq inhibit-defaults? #t). You can see the defaults in /share/defaults.scm of this repo. There are also some utilities that can be used in your config defined in /share/init.scm.

For more information, see the man pages (man dwl-guile).

C-bindings for dwl

All functions that allow you to interact with dwl are exposed using the libguile API in dwl-guile. Each binding is prefixed with dwl: and uses kebab-case as naming scheme, e.g. dwl:toggle-fullscreen. There are currently no documentation for these bindings, other than the definitions and implementations here.

Patches

%patch-attachabove

Puts newly spawned clients above the currently selected client. This is useful when you want to be able to spawn new clients without changing the master client.

%patch-focusmonpointer

Move cursor with monitor focus. This will teleport your mouse to the center of focused monitor.

%patch-monitor-config

Allows configuration of monitor resolution, refresh rate and adaptive sync, directly in your dwl config.

%patch-movestack

Move clients up and down the stack. Exposes the dwl:move-stack binding that can be used to move clients up or down.

%patch-swallow

Allows applications such as terminals to render launched applications in the same window. For example, opening a PDF using zathura will (if enabled) render zathura on top of the terminal, in the same client. Adds additional options to the dwl-rule record.

Note that swallowing does not work for XWayland clients.

%patch-xwayland

Enable xwayland support.

Extending the home service

You can extend the home service in order to extend the configuration. This is especially useful if you use something like rde .

Consider the following example that adds two new keybindings that dismiss notifications from mako :

(simple-service
 'add-mako-dwl-keybindings
 home-dwl-guile-service-type
 `((set-keys ,dismiss-key
             (lambda () (dwl:shcmd ,(file-append mako "/bin/makoctl") "dismiss"))
             ,dismiss-all-key
             (lambda () (dwl:shcmd ,(file-append mako "/bin/makoctl")
                                   "dismiss" "--all")))))

You can find more examples of this in our GNU Guix configuration, mainly in the engstrand/features/wayland.scm file.

home-service-dwl-guile's People

Contributors

frewacom avatar johanengstrand avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

home-service-dwl-guile's Issues

setq calls aren't properly formatted in the config generated by the guix-home service

Hey there!
I'm currently setting up a Guix system, and I wrote a full config for dwl-guile by following the instructions in the README.
Unfortunately, I can't start up the dwl-guile service if any setq commands were used, such as:

  • (setq inhibit-defaults? #t)
  • (setq border-px 2)
  • (setq focus-color "#112233")

Confused, I checked dwl-guile.log to find this:

guile: uncaught exception
Syntax error:
unknown location: source expression failed to match any pattern in form setq

Seeing that nobody else has reported this as an issue, this seems to be a problem on my end.
I did try to use dwl-guile without the service, but I just get a segmentation fault whenever I specify my config file.

If there's anything I left out that you need to know, please let me know!

README is outdated

README should be updated to show configuration options and setup for dwl-guile v2.0.0.

dwl-guile crashes when closing foot

I have found that if I use foot as a terminal with dwl-guile that any time that I close foot dwl-guile will crash.

This is with the current version of foot from guix

Is this a known issue?

I see no errors show up on the console after the termination so this is a bit confusing.

Alacriity works as expected.

dwl-guile hanging because of stdout filling up

I've hit the status problem described in the dwl FAQ with the dwl-guile home server. My dwl-guile instance, when started by the home server shepherd, hangs when stdout fills up. I can show this by ssh'ing into the machine, and doing a cat /proc/$(pidof dwl-guile)/1 -- dwl-guile starts up again.

I'm guessing this is because shepherd is not sending the stdout of dwl-guile somewhere in my setup -- should it default to a logfile somewhere?

extraneous field initializers (tty-number)

Hi!

The standard configuration works in a vanilla guix installation when I start dwl-guile with dwl-guile -c %config path%. besides this build time error:
Loading /gnu/store/wnfrnn1ax6sfqxlpg2hk8mfdijmpphic-shepherd.conf. herd: exception caught while executing 'load' on service 'root':
nice!

When I want to auto-start dwl-guile on a tty with the
(service home-dwl-guile-service-type (home-dwl-guile-configuration (tty-number 2) (native-qt? #t)))))) directive in my home config the following error is produced on build-time:
couldn't create backend xxxx@guix_gnu ~$ guix home reconfigure src/guix-config/home-configuration.scm /home/xxxx/src/guix-config/home-configuration.scm:39:2: error: (%home-dwl-guile-configuration (tty-number 2) (native-qt? #t)): extraneous field initializers (tty-number)

Is this a bug or am I missing something ? Thanks.

Upstreaming to community channels

Hey, I've recently given dwl-guile a spin on my local machine and it works great, thank you! Have you thought about upstreaming this home service + feature to RDE, as well as the dwl-guile package to Guix upstream?

Rewrite configuration into an Emacs-like configuration

The current configuration is too complex and is essentially unusable without using the home service. A much better option would be to implement an Emacs-like approach to the configuration, where variables can be set/unset/updated using something like setq.

Obviously, it should not be anywhere near as advanced as Emacs, but it should support the most basic operations. A config for dwl-guile might look like this:

`((setq border-px 2)
  (setq root-color "#FFFFFF")
  (global-set-key 
    (kbd "C-s-<enter>")
    (lambda () (...)))
  (...))

adding custom patches to dwl-guile

I really like the looks of dwl-guile but am new to guix packages in general.

Is there an easy way to add a patch that is not included n your lisf of patches as there are a few things that I would like to add

An example in the readme would be help full if possible

Sending signal to dwl-guile using pkill is inconsistent

Instead of sending signals, the dscm protocol should be extended, allowing clients to request the config to be reloaded. This way, a separate utility can be added which connects to the compositor and sends such an event. This should prevent all inconsistency with reloading the config.

Install dwl-guile package directly from source

There is really no reason to patch default dwl instead of simply compiling and installing the latest release from Github. One downside of patching dwl is that it relies on dwl 0.2.1 being the default version in Guix.

Applying the Xwayland patch

Hi, I have two questions:

  1. I tried following the example in the comment which was (patch-dwl-guile-package dwl-guile #:patches '(%patch-xwayland)) and that gave me the following error:
Backtrace:
In guix/store.scm:
   1996:8 19 (_ _)
In guix/gexp.scm:
   299:22 18 (_ _)
In guix/store.scm:
   1996:8 17 (_ _)
In guix/packages.scm:
  1971:11 16 (_ _)
In guix/gexp.scm:
   1180:2 15 (_ #<store-connection 256.99 ffff71e59280>)
   1046:2 14 (_ _)
    892:4 13 (_ _)
In guix/store.scm:
  2053:12 12 (_ #<store-connection 256.99 ffff71e59280>)
  1380:11 11 (map/accumulate-builds #<store-connection 256.99 ffff7…> …)
   1298:8 10 (call-with-build-handler #<procedure ffff71539f30 at g…> …)
  2168:25  9 (run-with-store #<store-connection 256.99 ffff71e59280> …)
In guix/gexp.scm:
   897:13  8 (_ _)
In guix/store.scm:
   1996:8  7 (_ _)
In guix/gexp.scm:
   299:22  6 (_ _)
In guix/packages.scm:
   2092:7  5 (_ _)
   954:17  4 (patch-and-repack #<derivation /gnu/store/xjwdca6bp36w…> …)
In srfi/srfi-1.scm:
   586:17  3 (map1 (%patch-xwayland))
In guix/packages.scm:
    940:4  2 (instantiate-patch _)
In ice-9/boot-9.scm:
  1685:16  1 (raise-exception _ #:continuable? _)
  1685:16  0 (raise-exception _ #:continuable? _)

ice-9/boot-9.scm:1685:16: In procedure raise-exception:
Throw to key `match-error' with args `("match" "no matching pattern" %patch-xwayland)'.

which made me think that I might need the value rather than the '%patch-xwayland symbol. Changing it to (list %patch-xwayland) got rid of the error. Is that right, or should it be a symbol that I'm not importing?

  1. My current service definition is
(service home-dwl-guile-service-type
                 (home-dwl-guile-configuration
                  (package
                   (patch-dwl-guile-package dwl-guile
                                            #:patches (list %patch-xwayland)))
                  (reload-config-on-change? #t)))

Wayland apps work fine, but X apps still do not launch. Do I need to do any extra steps?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.