yazeed1s / zwm

X11 tiling window manager
BSD 2-Clause "Simplified" License
73 stars 4 forks source link

handle_exec_cmd():890 error #1

Closed ranjandatta closed 5 months ago

ranjandatta commented 5 months ago

2024-06-11/01:28:04 PM [ERROR] [src/config_parser.c:handle_exec_cmd():890] execlp failed

How do i figure out what in config caused the issue? My config is as below

exec = ["polybar", "--reload", "main"]

border_width = 2
active_border_color = 0x83a598
normal_border_color = 0x30302f
window_gap = 10
virtual_desktops = 7
focus_follow_pointer = true

; run processes on some keys
bind = super + return -> run("alacritty")
bind = super + p -> run(["rofi", "-show", "drun"])

; kill the focused window
bind = super + x -> func(kill)

; switch to specific virtual desktops
bind = super + 1 -> func(switch_desktop:1)
bind = super + 2 -> func(switch_desktop:2)
bind = super + 3 -> func(switch_desktop:3)
bind = super + 4 -> func(switch_desktop:4)
bind = super + 5 -> func(switch_desktop:5)
bind = super + 6 -> func(switch_desktop:6)
bind = super + 7 -> func(switch_desktop:7)

; resize the focused window
bind = super + l -> func(resize:grow)
bind = super + h -> func(resize:shrink)

; toggle fullscreen mode
bind = super + f -> func(fullscreen)

; swap the focused window with its sibling
bind = super + s -> func(swap)

; cycle focus between windows
bind = super + up -> func(cycle_window:up)
bind = super + right -> func(cycle_window:right)
bind = super + left -> func(cycle_window:left)
bind = super + down -> func(cycle_window:down)

; cycle through virtual desktops
bind = super|shift + left -> func(cycle_desktop:left)
bind = super|shift + right -> func(cycle_desktop:right)

; transfer the focused window to another virtual desktop
bind = super|shift + 1 -> func(transfer_node:1)
bind = super|shift + 2 -> func(transfer_node:2)
bind = super|shift + 3 -> func(transfer_node:3)
bind = super|shift + 4 -> func(transfer_node:4)
bind = super|shift + 5 -> func(transfer_node:5)
bind = super|shift + 6 -> func(transfer_node:6)
bind = super|shift + 7 -> func(transfer_node:7)

; change the layout
bind = super|shift + m -> func(layout:master)
bind = super|shift + s -> func(layout:stack)
bind = super|shift + d -> func(layout:default)

; traverse the stack layout
bind = super|shift + k -> func(traverse:up)
bind = super|shift + j -> func(traverse:down)

; flip the orientation of the window
bind = super|shift + f -> func(flip)

; reload the configuration file
bind = super|shift + r -> func(reload_config)
yazeed1s commented 5 months ago

@ranjandatta Yeah i see it now. I am wondering why it does not work. I will look into it soon and see what's happening

yazeed1s commented 5 months ago

@ranjandatta Can you do me a favor and remove the != 0 check in config_parser.c line 867 and recompile the code. After looking at the code using my phone i see that for some reasons it's bypassing that check and jumping to the else block. It should not do that, and 0 should be comparable to NULL, but maybe it has to do with the gcc version.

ranjandatta commented 5 months ago

Commenting Line 867 gives me error while compiling

src/config_parser.c:893:11: error: expected identifier or ‘(’ before ‘else’
  893 |         } else if (pid < 0) {
      |           ^~~~
src/config_parser.c:897:1: error: expected identifier or ‘(’ before ‘}’ token
  897 | }
      | ^
make: *** [Makefile:19: src/config_parser.o] Error 1```
Update:
Commented the code as follows:
if (pid == 0) {
    // if (strchr(cmd, ',') != 0) {
        trim(cmd, SQUARE_BRACKET);
        int    count = 0;
        char **s     = split_string(cmd, ',', &count);
        if (s == NULL)
            return;
        const char *args[count + 1];
        for (int i = 0; i < count; ++i) {
            trim(s[i], WHITE_SPACE);
            trim(s[i], QUOTATION);
            args[i] = s[i];

ifdef _DEBUG__

            _LOG_(INFO, "arg exec = %s", s[i]);

endif

        }
        args[count] = NULL;
        execvp(args[0], (char *const *)args);
        free_tokens(s, count);
        _LOG_(ERROR, "execvp failed");
        exit(EXIT_FAILURE);
    // } else {
    //  trim(cmd, QUOTATION);
    //  execlp(cmd, cmd, (char *)NULL);
    //  _LOG_(ERROR, "execlp failed");
    //  exit(EXIT_FAILURE);
    // }
} else if (pid < 0) {
    _LOG_(ERROR, "fork failed");
    exit(EXIT_FAILURE);

Compiles ok, but log file says
`2024-06-11/01:28:04 PM [ERROR] [src/config_parser.c:handle_exec_cmd():890] execlp failed
`
yazeed1s commented 5 months ago

Yeah you don't need to comment the line out. Instead, replace it with this line

- if (strchr(cmd, ',') != 0){
+ if (strchr(cmd, ',')){

Just delete the != 0 condition.

ranjandatta commented 5 months ago

Yeah you don't need to comment the line out. Instead, replace it with this line

- if (strchr(cmd, ',') != 0){
+ if (strchr(cmd, ',')){

Just delete the != 0 condition.

Changed line as above and compile. Compiled fine, Logged into zwm session, polybar loads, but no key binds work bind = super + return -> run("alacritty") bind = super + p -> run(["rofi", "-show", "drun"])

yazeed1s commented 5 months ago

Okay cool. What OS are you using? And are those processes installed in your machine?

ranjandatta commented 5 months ago

Using Arch Linux, Both alacritty and rofi are installed as i use them daily on dk wm

yazeed1s commented 5 months ago

Okay, I see that dk wm requires a keyboard daemon like sxhkd to be installed. Make sure sxhkd isn't running in the background as it may clash with zwm. Keyboard shortcuts are tested in few different machines and they work just fine.

ranjandatta commented 5 months ago

sxhkd is not running

ranjandatta commented 5 months ago

are there any dependencies i am missing?

yazeed1s commented 5 months ago

If other keybindings are working then it's not a dependency issue. But i will look into it soon and figure out what's wrong. It could be a simple stupid problem, if you wanna find out what specifically is causing the issue in the meantime you can build zwm with the debug flags 'sudo make debug install' and see what is generated when you try to launch alacritty or rofi.

ranjandatta commented 5 months ago

No keybindings work. When i log into zwm session i get just polybar. I am unable to launch anything. Here is the log with debug option compile

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = () key = () value = ((null))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = (exec) key = (exec) value = (["polybar", "--reload", "main"])

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:handle_exec_cmd():861] exec command = (["polybar", "--reload", "main"])
2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = () key = () value = ((null))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = (border_width) key = (border_width) value = (2)

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = (active_border_color) key = (active_border_color) value = (0x83a598)

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = (normal_border_color) key = (normal_border_color) value = (0x30302f)

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = (window_gap) key = (window_gap) value = (10)

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = (virtual_desktops) key = (virtual_desktops) value = (7)

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = (focus_follow_pointer) key = (focus_follow_pointer) value = (true)

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = () key = () value = ((null))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = () key = () value = ((null))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = (bind) key = (bind) value = (super + return -> run("alacritty"))

2024-06-12/05:21:17 AM [INFO] [src/config_parser.c:handle_exec_cmd():879] arg exec = polybar
2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_mod_key():529] recieved mod key = (super)
2024-06-12/05:21:17 AM [INFO] [src/config_parser.c:handle_exec_cmd():879] arg exec = --reload
2024-06-12/05:21:17 AM [INFO] [src/config_parser.c:construct_key():712] found run func run("alacritty"), ...

2024-06-12/05:21:17 AM [INFO] [src/config_parser.c:handle_exec_cmd():879] arg exec = main
2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = (bind) key = (bind) value = (super + p -> run(["rofi", "-show", "drun"]))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_mod_key():529] recieved mod key = (super)
2024-06-12/05:21:17 AM [INFO] [src/config_parser.c:construct_key():712] found run func run(["rofi", "-show", "drun"]), ...

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = () key = () value = ((null))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = (bind) key = (bind) value = (super + x -> func(kill))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_mod_key():529] recieved mod key = (super)
2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = () key = () value = ((null))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = (bind) key = (bind) value = (super + 1 -> func(switch_desktop:1))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_mod_key():529] recieved mod key = (super)
2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = (bind) key = (bind) value = (super + 2 -> func(switch_desktop:2))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_mod_key():529] recieved mod key = (super)
2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = (bind) key = (bind) value = (super + 3 -> func(switch_desktop:3))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_mod_key():529] recieved mod key = (super)
2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = (bind) key = (bind) value = (super + 4 -> func(switch_desktop:4))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_mod_key():529] recieved mod key = (super)
2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = (bind) key = (bind) value = (super + 5 -> func(switch_desktop:5))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_mod_key():529] recieved mod key = (super)
2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = (bind) key = (bind) value = (super + 6 -> func(switch_desktop:6))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_mod_key():529] recieved mod key = (super)
2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = (bind) key = (bind) value = (super + 7 -> func(switch_desktop:7))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_mod_key():529] recieved mod key = (super)
2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = () key = () value = ((null))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = (bind) key = (bind) value = (super + l -> func(resize:grow))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_mod_key():529] recieved mod key = (super)
2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = (bind) key = (bind) value = (super + h -> func(resize:shrink))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_mod_key():529] recieved mod key = (super)
2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = () key = () value = ((null))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = (bind) key = (bind) value = (super + f -> func(fullscreen))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_mod_key():529] recieved mod key = (super)
2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = () key = () value = ((null))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = (bind) key = (bind) value = (super + s -> func(swap))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_mod_key():529] recieved mod key = (super)
2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = () key = () value = ((null))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = (bind) key = (bind) value = (super + up -> func(cycle_window:up))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_mod_key():529] recieved mod key = (super)
2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = (bind) key = (bind) value = (super + right -> func(cycle_window:right))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_mod_key():529] recieved mod key = (super)
2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = (bind) key = (bind) value = (super + left -> func(cycle_window:left))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_mod_key():529] recieved mod key = (super)
2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = (bind) key = (bind) value = (super + down -> func(cycle_window:down))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_mod_key():529] recieved mod key = (super)
2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = () key = () value = ((null))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = (bind) key = (bind) value = (super|shift + left -> func(cycle_desktop:left))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_mod_key():529] recieved mod key = (super|shift)
2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = (bind) key = (bind) value = (super|shift + right -> func(cycle_desktop:right))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_mod_key():529] recieved mod key = (super|shift)
2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = () key = () value = ((null))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = (bind) key = (bind) value = (super|shift + 1 -> func(transfer_node:1))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_mod_key():529] recieved mod key = (super|shift)
2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = (bind) key = (bind) value = (super|shift + 2 -> func(transfer_node:2))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_mod_key():529] recieved mod key = (super|shift)
2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = (bind) key = (bind) value = (super|shift + 3 -> func(transfer_node:3))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_mod_key():529] recieved mod key = (super|shift)
2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = (bind) key = (bind) value = (super|shift + 4 -> func(transfer_node:4))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_mod_key():529] recieved mod key = (super|shift)
2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = (bind) key = (bind) value = (super|shift + 5 -> func(transfer_node:5))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_mod_key():529] recieved mod key = (super|shift)
2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = (bind) key = (bind) value = (super|shift + 6 -> func(transfer_node:6))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_mod_key():529] recieved mod key = (super|shift)
2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = (bind) key = (bind) value = (super|shift + 7 -> func(transfer_node:7))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_mod_key():529] recieved mod key = (super|shift)
2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = () key = () value = ((null))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = (bind) key = (bind) value = (super|shift + m -> func(layout:master))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_mod_key():529] recieved mod key = (super|shift)
2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = (bind) key = (bind) value = (super|shift + s -> func(layout:stack))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_mod_key():529] recieved mod key = (super|shift)
2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = (bind) key = (bind) value = (super|shift + d -> func(layout:default))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_mod_key():529] recieved mod key = (super|shift)
2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = () key = () value = ((null))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = (bind) key = (bind) value = (super|shift + k -> func(traverse:up))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_mod_key():529] recieved mod key = (super|shift)
2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = (bind) key = (bind) value = (super|shift + j -> func(traverse:down))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_mod_key():529] recieved mod key = (super|shift)
2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = () key = () value = ((null))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = (bind) key = (bind) value = (super|shift + f -> func(flip))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_mod_key():529] recieved mod key = (super|shift)
2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = () key = () value = ((null))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = (bind) key = (bind) value = (super|shift + r -> func(reload_config))

2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_mod_key():529] recieved mod key = (super|shift)
2024-06-12/05:21:17 AM [DEBUG] [src/config_parser.c:parse_config():918] config line = () key = () value = ((null))

2024-06-12/05:21:17 AM [DEBUG] [src/zwm.c:handle_configure_request():3136] window 8388610  name polybar-main_HDMI-1 wants to be at 0x0 with 3440x32

2024-06-12/05:21:17 AM [DEBUG] [src/zwm.c:handle_configure_request():3136] window 8388610  name polybar-main_HDMI-1 wants to be at 0x0 with 3440x32

2024-06-12/05:21:22 AM [DEBUG] [src/zwm.c:handle_enter_notify():2753] recieved enter notify for 1404, name (null) 
2024-06-12/05:21:24 AM [DEBUG] [src/zwm.c:handle_enter_notify():2753] recieved enter notify for 1404, name (null) 
2024-06-12/05:21:25 AM [DEBUG] [src/zwm.c:handle_client_message():3015] recieved client message for 1404, name (null) 
2024-06-12/05:21:26 AM [DEBUG] [src/zwm.c:handle_client_message():3015] recieved client message for 1404, name (null) 
2024-06-12/05:21:27 AM [DEBUG] [src/zwm.c:handle_client_message():3015] recieved client message for 1404, name (null) 
2024-06-12/05:21:28 AM [DEBUG] [src/zwm.c:handle_client_message():3015] recieved client message for 1404, name (null) 
2024-06-12/05:21:28 AM [DEBUG] [src/zwm.c:handle_client_message():3015] recieved client message for 1404, name (null) 
2024-06-12/05:21:29 AM [DEBUG] [src/zwm.c:handle_client_message():3015] recieved client message for 1404, name (null) 
2024-06-12/05:21:30 AM [DEBUG] [src/zwm.c:handle_client_message():3015] recieved client message for 1404, name (null) 
2024-06-12/05:21:31 AM [DEBUG] [src/zwm.c:handle_enter_notify():2753] recieved enter notify for 1404, name (null) 
yazeed1s commented 5 months ago

The log file doesn't show what happens when you try to use any of the keybindings. If something is wrong when you do press keys, it should be logged. I suspect a dependency issue because if zwm encounters an error while loading keybindings from the config file, it defaults to a predefined array of keys in zwm.c. This fallback mechanism is implemented to prevent problems with the keybindings. In your case, the keys are not even recognized, it could be a dependency issue or zwm could be clashing with other keyboard daemons. I will look into it this weekend and fix it. Thanks for reporting this!

yazeed1s commented 5 months ago

@ranjandatta I think I figured out the issue. Can you share your .xinitrc here pls

ranjandatta commented 5 months ago

Hi I am not using a .xinitrc to log into zwm session, I am instead using xsessions file zwm.desktop

 [Desktop Entry]
 Name=zwm
 Comment=zwm tiling window manager
 Exec=zwm
 Type=XSession
yazeed1s commented 5 months ago

Okay np. I know the issue and i will fix it as soon as i get access to my laptop. The issue is that zwm grabs the keyboard on the first mapping notify event, and this event is generated first when zwm runs if you set the keyboard layout to US in .xinirc. The solution is to grab the keyboard inside zwm code and not to leave this to the mapping notify handler. The fix should soon be in upstream.

yazeed1s commented 5 months ago

@ranjandatta the issue should now be fixed!

ranjandatta commented 5 months ago

thanks! appreciate the work!