Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 20 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,34 @@ OFLAGS = -O2
CFLAGS = -std=$(CSTD) $(IFLAGS) $(WFLAGS) $(OFLAGS) -fpic
LDFLAGS = -shared -lX11 -lXft -lXrandr

SWIFLAGS = -p foreign=$(INSTALLDIR_LIB) \
--goal=main --toplevel=halt --stand_alone=true -O -o plwm -c src/plwm.pl
LIB_PATH = /usr/local/lib

INSTALLDIR_BIN = /usr/local/bin
INSTALLDIR_LIB = /usr/local/lib
INSTALLDIR_CNF = /etc/plwm
INSTALLDIR_MAN = /usr/local/share/man/man1
BIN_DIR = bin
PLWM = $(BIN_DIR)/plwm
PLX_O = $(BIN_DIR)/plx.o
PLX_SO = $(BIN_DIR)/plx.so

SWIFLAGS = -p foreign=$(LIB_PATH) \
--goal=main --toplevel=halt --stand_alone=true -O -o $(PLWM) -c src/plwm.pl

#================================== Build =====================================

plwm: plx.so src/*.pl
$(PLWM): src/*.pl $(PLX_SO)
swipl $(SWIFLAGS)

plx.o: src/plx.c
$(PLX_SO): $(PLX_O)
$(CC) $< $(LDFLAGS) -o $@

$(PLX_O): src/plx.c $(BIN_DIR)
$(CC) -c $(CFLAGS) $< -o $@

plx.so: src/plx.o
$(CC) $< $(LDFLAGS) -o $@
$(BIN_DIR):
mkdir $(BIN_DIR)

clean:
rm -f src/plx.o plx.so plwm
rm -f $(BIN_DIR)/*

rebuild: clean plwm
rebuild: clean $(PLWM)

#============================== Static checks =================================

Expand All @@ -59,19 +64,9 @@ test:

#============================ Install/uninstall ===============================

VERSION = ${shell sed -n 's/^version(\([0-9.]\+\))\.$$/\1/p' src/plwm.pl}

install: plwm
install -D --mode=755 plwm $(INSTALLDIR_BIN)/plwm
install -D --mode=755 plx.so $(INSTALLDIR_LIB)/plx.so
install -D --mode=644 -C --backup=numbered config/config.pl $(INSTALLDIR_CNF)/config.pl
mkdir -p $(INSTALLDIR_MAN)
sed 's/VERSION/$(VERSION)/' < docs/plwm.1 > $(INSTALLDIR_MAN)/plwm.1
chmod 644 $(INSTALLDIR_MAN)/plwm.1
install:
tools/install.sh

uninstall:
rm -f $(INSTALLDIR_BIN)/plwm \
$(INSTALLDIR_LIB)/plx.so \
$(INSTALLDIR_MAN)/plwm.1
[ -d $(INSTALLDIR_CNF) ] && echo "Note: $(INSTALLDIR_CNF) is kept" || true
tools/uninstall.sh

File renamed without changes.
37 changes: 20 additions & 17 deletions README.md → docs/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- MIT License, Copyright (c) 2023-2025 Barnabás Zahorán, see LICENSE -->

<p align="center">
<img alt="plwm logo" src="img/logo.png">
<img alt="plwm logo" src="../img/logo.png">
</p>

# plwm - An X11 window manager written in Prolog
Expand Down Expand Up @@ -52,20 +52,23 @@ Powered by [SWI-Prolog](https://www.swi-prolog.org/)

# Installation

**Dependencies:**
**From release**

Download the latest version from the [releases](https://github.com/Seeker04/plwm/releases), extract and run `./install.sh`.

* `xorg` with `libx11-dev`, `libxft-dev`, `libxrandr-dev` (exact package names may vary)
* [SWI-Prolog](https://www.swi-prolog.org/Download.html) (downloadable from most distros' package repos)
**From source**

On Ubuntu 22.04, easiest way to install them is:
Run `make && sudo make install`

`$ sudo apt install xorg-dev swi-prolog`
**Dependencies:**

Run:
* `xorg` with `libx11-dev`, `libxft-dev`, `libxrandr-dev`<br>
(exact package names may vary, `dev` versions are only needed when building from source)
* [SWI-Prolog](https://www.swi-prolog.org/Download.html) (most likely also packaged by your distro)

`$ make && sudo make install`
E.g. on Ubuntu 22.04, easiest way to install them is:

By default, this will install plwm to `/usr/local/bin/`. The location can be adjusted in the [Makefile](Makefile).
`sudo apt install xorg-dev swi-prolog`

## Minimal environment

Expand Down Expand Up @@ -181,7 +184,7 @@ then you'll have a triple stack layout where your windows will be evenly spread

## Configuration

`sudo make install` installs the [default configuration](config/config.pl) to `/etc/plwm/config.pl`. This file can be copied to user config directories.
`sudo make install` installs the [default configuration](../config/config.pl) to `/etc/plwm/config.pl`. This file can be copied to user config directories.

plwm attempts reading configuration when it starts from the first file among
- `$XDG_CONFIG_HOME/plwm/config.pl`
Expand Down Expand Up @@ -226,14 +229,14 @@ While cooking your config, you can use the `-C` flag to quickly and easily check
| `modkey` | shift, lock, ctrl, alt, mod2, mod3, super, mod5<br>**Default:** super | Key you must hold for mouse operations |
| `scroll_up_action` | callable term or 'none'<br>**Default:** switch_workspace(next) | Action to perform on modkey + scroll up |
| `scroll_down_action` | callable term or 'none'<br>**Default:** switch_workspace(prev) | Action to perform on modkey + scroll down |
| `keymaps` | list of (Modifiers + Key -> Action)<br>**Default:** [see here](#default-keybindings) | Modifiers: see values at `modkey`<br/>Key: keycode, [usual X11 names](http://xahlee.info/linux/linux_show_keycode_keysym.html), or [special key](src/xf86names.pl)<br/>Action: callable term |
| `keymaps` | list of (Modifiers + Key -> Action)<br>**Default:** [see here](#default-keybindings) | Modifiers: see values at `modkey`<br/>Key: keycode, [usual X11 names](http://xahlee.info/linux/linux_show_keycode_keysym.html), or [special key](../src/xf86names.pl)<br/>Action: callable term |
| `rules` | list of (Name, Class, Title -> Monitor, Workspace, Mode)<br>**Default:** [] | Auto place and configure matching windows (explained [here](#rules)) |
| `hooks` | list of (Event -> Action)<br>**Default:** `[start -> writeln("plwm starting"), quit -> writeln("plwm quitting")]` | Run custom logic on certain events (explained [here](#hooks)) |

**Tips**

* You can safely remove any setting from your config file, plwm will use the default value for those.
* In `keymaps/1`, the callback predicates can be arbitrary shell commands using `shellcmd/1`, even whole commandlines (some examples are included in the [default config](config/config.pl)).
* In `keymaps/1`, the callback predicates can be arbitrary shell commands using `shellcmd/1`, even whole commandlines (some examples are included in the [default config](../config/config.pl)).
* If you wish to stick to default keymaps mostly, with only a few changes and feel redundant to list the whole table in your config, you can simply omit the `keymaps/1` setting and add your changes as a `start` hook like this:

```Prolog
Expand Down Expand Up @@ -520,15 +523,15 @@ done > /tmp/plwm_fifo

# Screenshots

| ![Screenshot 1](img/screenshot1.png) |
| ![Screenshot 1](../img/screenshot1.png) |
|:--:|
| *default appearance* |

| ![Screenshot 2](img/screenshot2.png) |
| ![Screenshot 2](../img/screenshot2.png) |
|:--:|
| *lmaster / nmaster=1 / mfact=2/3 / 1px borders / 18px inner & outer gaps / goto window menu / polybar / picom / gruvbox colors* |

| ![Screenshot 3](img/screenshot3.png) |
| ![Screenshot 3](../img/screenshot3.png) |
|:--:|
| *bmaster / nmaster=1 / mfact=2/3 / 3px focused border / 26px inner & outer gaps / polybar / picom /w rounded corners & shadows* |

Expand All @@ -552,7 +555,7 @@ If you have a feature request or questions, feel free to [open discussions](http

Any code contribution is also welcome. Especially if it solves some known issue. For brand new ideas, I recommend creating a discussion first.

Please read the [Development Guide](docs/development_guide.md).
Please read the [Development Guide](development_guide.md).

# FAQ

Expand All @@ -566,7 +569,7 @@ Compared to what? C? Yes. Does it matter? No. I've been using dwm for 6 years, s

**Isn't SWI-Prolog non-ISO compliant?**

Interoperability between different Prolog implementations was never really on the table. Their C FFIs are also different, so [plx.c](plx.c) would also need to be rewritten for each kind of Prolog. SWI-Prolog is arguably one of the most popular free and community-driven Prolog implementations, is easily accessible, has good documentation, some LSP support and a lot of libraries. Though, to be honest, plwm's code mostly sticks to fundamentals, so if someone really wanted to, it shouldn't be too hard to port this to another Prolog system...
Interoperability between different Prolog implementations was never really on the table. Their C FFIs are also different, so [plx.c](../src/plx.c) would also need to be rewritten for each kind of Prolog. SWI-Prolog is arguably one of the most popular free and community-driven Prolog implementations, is easily accessible, has good documentation, some LSP support and a lot of libraries. Though, to be honest, plwm's code mostly sticks to fundamentals, so if someone really wanted to, it shouldn't be too hard to port this to another Prolog system...

**Why not Wayland?**

Expand Down
8 changes: 4 additions & 4 deletions docs/development_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,19 +178,19 @@ plwm is currently in a pre-release stage.
Now we simply increment a `0.x` version every 4-6 months.

Current process:
* Increment `version/1` in [plwm.pl](../src/plwm.pl).
* Update [CHANGELOG.md](../CHANGELOG.md) with changes since the latest version based on commit history.
* Increment `version/1` in [plwm.pl](../src/plwm.pl) and in [plwm.1](plwm.1).
* Update [CHANGELOG.md](../docs/CHANGELOG.md) with changes since the latest version based on commit history.
* Create "Version bump to 0.x" commit.
* Create `v0.x` git tag.
* Push commit and tag.
* Create a [new release](https://github.com/Seeker04/plwm/releases/new) from the tag.
* Name: "plwm v0.x"
* Assets: `plwm-v0.x-linux-x86_64.tar.gz` with `bin/plwm` and `lib/plx.so` extracted from a Docker build
* Assets: archive created with [generate_release.sh](../tools/generate_release.sh) from the Docker build
* Description:
```
Version 0.x

See [CHANGELOG.md](CHANGELOG.md)
See [CHANGELOG.md](link to the new section in docs/CHANGELOG.md)

Note: Experimental release (first stable version will be 1.0.0)
```
Expand Down
2 changes: 1 addition & 1 deletion docs/plwm.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH PLWM 1 plwm\-VERSION
.TH PLWM 1 plwm\-0.4
.SH NAME
plwm \- An X11 window manager written in Prolog
.SH SYNOPSIS
Expand Down
2 changes: 1 addition & 1 deletion src/plwm.pl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
%
% plwm - an X11 window manager written in Prolog
%
% See README.md for getting started
% See docs/README.md to get started

version(0.4).

Expand Down
Loading