ebeem / guile-swayer

Extensible Guile bindings for SwayWM
MIT License
62 stars 3 forks source link

sway-gaps dispatches invalid command if called according to the docstring in the sway-gaps function #4

Open corn-flake opened 1 week ago

corn-flake commented 1 week ago

Hi, I think there is a bug in the sway-gaps function. I installed guile-swayer using the GNU Guix package, the package definition for which can be found here: https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/packages/guile-xyz.scm#n1032 I'm running version 0.3.0. I wrote this code to set the inner gaps of all workspaces to 10px, but it gives an error when run from the Guile REPL and does not set the gaps when placed in my guile swayer config file:

(sway-gaps SWAY-GAPS-OPTION-INNER SWAY-GAPS-WORKSPACE-ALL 10)

Here is the full output of the Guile REPL:

GNU Guile 3.0.9
Copyright (C) 1995-2023 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.

Enter `,help' for help.
scheme@(guile-user)> (use-modules (oop goops)
             (srfi srfi-18)
             (modules workspace-groups)
             (modules workspace-grid)
             (modules general)
             (ice-9 pretty-print)
             (swayipc))

(sway-connect-sockets!)
$1 = #t
scheme@(guile-user)> (sway-gaps SWAY-GAPS-OPTION-INNER SWAY-GAPS-WORKSPACE-ALL 10)
dispatching: gaps inner all 10
$2 = (#<<sway-tick> success: #f parse-error: #t error: "Expected 'gaps inner|outer|horizontal|vertical|top|right|bottom|left current|all set|plus|minus|toggle <px>' or 'gaps inner|outer|horizontal|vertical|top|right|bottom|left <px>'">)

According to the docstring and declaration of the sway-gaps function, I called it correctly to do what I want it to do:

(define* (sway-gaps option workspace amount #:key (exec #t))
  "Changes the inner or outer gaps for either all workspaces or the current workspace.
  parameters:
    - option: `SWAY-GAPS-OPTION-INNER`, `SWAY-GAPS-OPTION-OUTER`, `SWAY-GAPS-OPTION-HORIZONTAL`,
              `SWAY-GAPS-OPTION-VERTICAL`, `SWAY-GAPS-OPTION-TOP`, `SWAY-GAPS-OPTION-RIGHT`,
              `SWAY-GAPS-OPTION-BOTTOM`, `SWAY-GAPS-OPTION-LEFT`
    - workspace: `SWAY-GAPS-WORKSPACE-ALL`, `SWAY-GAPS-WORKSPACE-CURRENT`, `SWAY-GAPS-WORKSPACE-SET`,
                 `SWAY-GAPS-WORKSPACE-PLUS`, `SWAY-GAPS-WORKSPACE-MINUS`, `SWAY-GAPS-WORKSPACE-TOGGLE`
    - amount: amount of gap (number)

I called the function with the correct parameters, but it didn't do what I expected. Judging by the error message, it seems like this can be fixed by adding another parameter to the function that matches with the set | plus | minus | toggle option expected by sway. Then you could just add that parameter into the call to format. I haven't tested this idea yet but I will update when I do it and if it works.

I don't think this is an issue with my setup, since all other code in my guile-swayer config works as expected.

ebeem commented 1 week ago

Thanks for testing the project and taking the time to analyze and report this bug! It seems like the format is invalid as you mentioned, I will work on fixing that, there are 2 formats for gaps in sway. guile-swayer implements those as sway-gaps and sway-default-gaps

sway-default-gaps will change default gaps of new workspaces sway-gaps will change gaps on selected workspaces

It seems like only sway-gaps needs fixing, I will push an update and let you know

corn-flake commented 1 week ago

Thanks for responding so quickly! I really appreciate that. Thanks for taking a look. I really love this project, great job!

ebeem commented 1 week ago

I just pushed a commit c09e4b16d9fcfad79937bdccff4808ef039b451a, it should fix the sway-gaps function now, a new parameter is introduced sway-gaps-type. Happy hacking!

(sway-gaps SWAY-GAPS-OPTION-INNER SWAY-GAPS-WORKSPACE-ALL SWAY-GAPS-TYPE-SET 10)
corn-flake commented 1 week ago

Amazing! If It's necessary (idk if it is, I think guix's build farms automatically do this, or maybe it's written into the package itself that it pulls from github when updated) I'll contact the maintainer of the guix package about this commit so they can update the package if need be. Happy hacking to you too!

ebeem commented 1 week ago

The definition in guix is pointing now at v0.3.0 You can see this here

             (commit (string-append "v" version))))

If I am not mistaken, guix also accepts a commit, for example

             (commit "c09e4b16d9fcfad79937bdccff4808ef039b451a")))

Note: the sha256 signature will also have to be updated.

In case needed, I can release v0.3.1 if the commit solved your problem