A simple wrapper for interacting with Hyprland’s IPC using Common Lisp.
;; Porcelain will be added in the future so you don't have to use a raw string
(hyprland-ipc:hyprctl "notify 0 10000 rgb(abcdef) Hi mom!") ; -> "ok"
(gethash "title" (hyprland-ipc:hyprctl "activewindow" t)) ; -> "*sly-mrepl for sbcl*"
(hyprland-ipc:hyprctl-batch '("dispatch workspace 1"
"dispatch killactive"
"dispatch exec kitty"
"dispatch movecursor 100 10"))
Note the singular :active-window
handler with three arguments that handles both
the activewindow
and activewindowv2
events.
(hyprland-ipc:handle-events :open-layer (lambda (namespace)
(declare (ignorable namespace))
(hyprland-ipc:hyprctl "dispatch exec kitty"))
:change-floating-mode (lambda (window-address floating)
(declare (ignorable window-address floating))
(format t
"Your ~A is: damn ~A.~%"
(gethash "class"
(hyprland-ipc:find-client-data window-address))
(if (string= floating "1")
"Floating"
"Not Floating")))
:active-window (lambda (window-class window-title window-address)
(declare (ignorable window-class window-title window-address))
(format t
"Window with title \"~A\" just focused at 0x~A.~%"
window-title
window-address)))
Currently, the only supported Common Lisp implementation is SBCL (if anyone finds an alternative to
sb-bsd-sockets
that doesn’t suck feel free to make a PR).
This system is available on Ultralisp. With Quicklisp installed, run:
(ql-dist:install-dist "http://dist.ultralisp.org/" :prompt nil)
(ql:quickload "cl-hyprland-ipc")
For Nix users, this repository provides a package through a flake. In any flake that wants to make use of this package, add:
inputs.cl-hyprland-ipc = {
url = "github:eriedaberrie/cl-hyprland-ipc";
inputs.nixpkgs.follows = "nixpkgs"; # Advisable to prevent SBCL version mismatches
};
The flake provides the cl-hyprland-ipc
package, for use in
pkgs.sbcl.withPackages
, the lispLibs
attribute of pkgs.sbcl.buildASDFSystem
,
etc. It may be desirable to use something other than the latest sbcl
, in which
case the package’s lispImpl
argument can be overridden (keep in mind that
setting this to anything other than a version of SBCL is most likely not going
to work). The Nixpkgs manual on Common Lisp in Nix.