Skip to content

add support for scryer-prolog#114

Draft
Skgland wants to merge 181 commits intoSeeker04:mainfrom
Skgland:scryer
Draft

add support for scryer-prolog#114
Skgland wants to merge 181 commits intoSeeker04:mainfrom
Skgland:scryer

Conversation

@Skgland
Copy link

@Skgland Skgland commented Sep 4, 2025

This add the option of running plwm with scryer-prolog instead of swi.

Warning

The basics should be working at this stage, see the todo and help wanted section below for what is missing.
When testing I recommend using a VM or at least make sure you are able to change back to a working window manager in case this doesn't.
I.e. be able to switch tty, log into the terminal, and kill scryer-plwm (may need to kill display manager as well).

This splits the plwm binary into plwm-swi and plwm-scryer (the later is actually a script).

Installation on debian based system

Prerequisites

Install scryer-prolog

From CI Artifacts

From https://github.com/mthom/scryer-prolog/actions/runs/18056647934#artifacts

  1. Download the scryer-prolog_ Artifact Zip
  2. Install Scryer
    a. place the scryer-prolog[.exe] binary from the release folder somewhere on your PATH
    b. install the scryer-prolog_<version>-1_<arch>.deb package from the debian folder e.g. apt install scryer-prolog_<version>-1_<arch>.deb

Build from Source

Debian Package
git clone https://github.com/mthom/scryer-prolog.git
cd scryer-prolog
cargo deb
run0 apt install ./target/debian/*.deb
Manual
git clone https://github.com/mthom/scryer-prolog.git
cd scryer-prolog
cargo build --release

Then place ./target/release/scryer-prolog[.exe] somewhere on your PATH

Build & Install plwm-{core,swi,scryer}

git clone https://github.com/Skgland/plwm.git --branch scryer
cd plwm
make install-debs

Help Wanted

Try everything and find out whats broken

I am not used to tiling window manager and plwm in general.
So I am having a hard time testing things as at this point the bugs are often more subtle and I often don't known if some behavior is due to

  • a bug in the prolog port
  • I am not using it correctly
  • a bug already present in stock swi plwm

Also using features that I haven't tried or don't know how to use would be helpful as this might
reveal more predicates that are assumed present from swi but that are missing in scryer and havent been implemented/stubbed in the port.

Signal handling

This requires some work in scryer-prolog as it currently doesn't have a way to handle signals besides hardcoded Ctr+C handling.

Some notes:

  • The signal handler function itself should likely be relatively small i.e. check the signal configuration and abort the process, ignore the signal, flag the signal as received to the machine.
  • In the case a custom predicate is to be evaluated on receiving a signal the machine needs to be adjusted to monitor these flags and cause the goal to be evaluated.
  • Can this be done while scryer-prolog is still single threaded? How would that work while the machine is stuck evaluating an ffi call?

Run Tests (SWI-prolog)

I would like some help with set + (defaults can be set) as that test appears to pass on main but fails here in a weird way.

Note: a false has been inserted into the test to stop it from breaking other tests that needs to be removed when trying to search for the root cause.

warn_invalid_arg and global_key_newvalue - (nonassoc_g) appear to also fail on master so I will ignore them as pre-existing failures.

Command Line Argument Handling

Two ways to go about this:

  1. contribute a command-line parsing module to scryer-prolog and use it here (idealy compatible with swi-prolog)
  2. implement the required parsing in the scryer stubs here.

Improve stub files

I think this is best discussed in #113

TODO

@Skgland
Copy link
Author

Skgland commented Nov 7, 2025

Rebased to cleanup the one fixup! commit and merged main to resolve merge conflicts.

While I generally prefer rebasing over merge and I also originally planed to do more cleanup of the commit history, due to the shear size of this I don't think that will be possible.
So I think this is a lose-lose situation and I will either have to live with it as is or squash everything down losing all history and resulting in a single huge commit.

@Seeker04
Copy link
Owner

Seeker04 commented Nov 8, 2025

Rebased to cleanup the one fixup! commit and merged main to resolve merge conflicts.

While I generally prefer rebasing over merge and I also originally planed to do more cleanup of the commit history, due to the shear size of this I don't think that will be possible. So I think this is a lose-lose situation and I will either have to live with it as is or squash everything down losing all history and resulting in a single huge commit.

I think a single commit could be acceptable. Especially if we can keep the fork and its branch for some time in case we needed this history.

@Seeker04
Copy link
Owner

Seeker04 commented Nov 8, 2025

I get this error right after launching plwm-scryer:

/usr/local/bin/scryer-prolog
"scryer/init.pl initialized"
main causes: error(syntax_error(incomplete_reduction),read_term/3:188)

Rust and Scryer versions are up to date:

rustc --version
rustc 1.91.0 (f8297e351 2025-10-28)

scryer-prolog --version
v0.10.0-17-ge4d96925

Have you encountered this or do you have some idea where this might originate from?

@Skgland
Copy link
Author

Skgland commented Nov 8, 2025

I get this error right after launching plwm-scryer:

/usr/local/bin/scryer-prolog
"scryer/init.pl initialized"
main causes: error(syntax_error(incomplete_reduction),read_term/3:188)

Rust and Scryer versions are up to date:

rustc --version
rustc 1.91.0 (f8297e351 2025-10-28)

scryer-prolog --version
v0.10.0-17-ge4d96925

Have you encountered this or do you have some idea where this might originate from?

I don't get that error and without mthom/scryer-prolog#3133 we don't know which file is the offending one.

src/plwm-scryer 
"scryer/init.pl initialized"
"-c user config loaded"
"Monitor \"XWAYLAND0\" managed"
"Monitor \"XWAYLAND1\" managed"
xerror: fatal X error - request code=2, error code=10
xerror: fatal X error - request code=2, error code=10
"plwm starting"

(The xerrors are due to me running it under WSL2 on windows without X11 being properly setup)

At the point where you're experiencing the crash it should be attempting to load the config file.
Are you using an existing config file? Maybe your config file is not valid in scryer-prolog?
e.g. the keymaps list needs to have parentheses around the entries to disambiguate the -> in scryer.

so we can pin point errros during config loading
@Skgland
Copy link
Author

Skgland commented Nov 8, 2025

Added some print outs before and after the config loading, if the error occurs between these printouts the error should be in your config file.

@triska
Copy link

triska commented Nov 9, 2025

A Prolog syntax error in a file should also be detectable without launching plwm. For instance, can you successfully consult the configuration file (if any) with Scryer Prolog, by specifying it on the command line?

@Seeker04
Copy link
Owner

Seeker04 commented Nov 9, 2025

Oh, sorry. It was indeed my config that was faulty :S

Now plwm-scryer launces on my machine too and core window management functionality works! (tiling, floating windows, fullscreen, workspace switching, etc.)

I see some hiccups withs the hooks and menu operations. Also, sometimes the quit action hangs the process and I have to kill it (I have a hunch this also has to do with a stuck dmenu child process...)

I'll write a proper assessment of the issues I find.

Either way, the core window managment works in Scryer which is awesome! 🍾

@triska
Copy link

triska commented Nov 9, 2025

Awesome, and thank you all a lot!! Also perfectly timed for the meetup! See you soon, let's celebrate this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments