regolith-linux / regolith-desktop

Meta package for the Regolith Desktop Environment
1.51k stars 31 forks source link

Cannot change win and alt keys with Xresources #504

Open hugorichard opened 3 years ago

hugorichard commented 3 years ago

Describe the bug A clear and concise description of what the bug is. New installation of Regolith Change alt and key using Xresource as described in https://regolith-linux.org/docs/getting-started/configuration/ Get i3 config error

To Reproduce Steps to reproduce the behavior:

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Configuration file(s) Please attach or mention any customization you've done to configuration files which might have an impact on the bug you are describing. It'll help us determine the root cause of your issue.

Installation Details

Additional context Add any other context about the problem here.

moritzheiber commented 3 years ago

I'm sorry, but could you please add a little more detail to this bug report and make sure your issue isn't covered by the documentation? Otherwise I'll be forced to close it.

Thanks!

hugorichard commented 3 years ago

I am pretty sure this issue is not covered by the documentation. I recently upgraded from 1.3 to 1.5 by cleaning everything and re-install everything as said in the Reinstallation section of https://regolith-linux.org/docs/getting-started/install/ Everything seems to work fine. Then I create the file ~/.config/regolith/Xresources and add the lines

i3-wm.mod: Mod1
i3-wm.alt: Mod4

save and press windows-shift-r to reload the configuration.

I get: "You have an error in your i3 config file!"

When I click on "show error" I get

"ERROR: Duplicate keybinding in config file:
  state mask 0x8 with keysym space, command "exec rofi -show find -modi find:/usr/share/rofi/modi/finder.sh"
ERROR: Duplicate keybinding in config file:
  state mask 0x8 with keysym l, command "focus right"
ERROR: Duplicate keybinding in config file:
  state mask 0x8 with keysym Right, command "workspace next"
ERROR: Duplicate keybinding in config file:
  state mask 0x8 with keysym Left, command "workspace prev"
ERROR: Duplicate keybinding in config file:
  state mask 0x8 with keysym grave, command "exec --no-startup-id /usr/share/i3xrocks/next-workspace --startnum 1 --move-window-and-follow"
ERROR: FYI: You are using i3 version 4.18.2 (2020-07-26)
ERROR: Received ConfigureNotify for unknown window 0x02e00000
ERROR: Received ConfigureNotify for unknown window 0x02e00003
ERROR: Received ExposeEvent for unknown window 0x02e00003
ERROR: Received ConfigureNotify for unknown window 0x02e00003
ERROR: Received ConfigureNotify for unknown window 0x02e00006
ERROR: Received ExposeEvent for unknown window 0x02e00006
ERROR: Received ConfigureNotify for unknown window 0x02e00006
ERROR: Received ConfigureNotify for unknown window 0x02e00009
ERROR: Received ExposeEvent for unknown window 0x02e00009
ERROR: Received ConfigureNotify for unknown window 0x02e00009
ERROR: Received ConfigureNotify for u/run/user/1001/i3/errorlog.3106
"
kgilmer commented 3 years ago

Hi @hugorichard , looks like you've uncovered a new bug. We've expanded upon how keybindings are defined such that in more cases, users can use overrides to change keybindings, rather than a full i3 copy. However some of the defaults in the i3 file conflict if alt and super are swapped.

A general fix will take some time, but for now making your ~/.config/regolith/Xresources file look like this should resolve the errors you have reported:

i3-wm.mod: Mod1
i3-wm.alt: Mod4
i3-wm.binding.file_search: Mod4
i3-wm.binding.ws_next2: Mod4+Right
i3-wm.binding.ws_prev2: Mod4+Left
i3-wm.binding.take_next_free: Mod4+grave
i3-wm.binding.look_selector: Mod4+l

I would appreciate knowing if you apply this fix and it does or does not resolve the issue for you.

hugorichard commented 3 years ago

Hi thanks for your answer. I took a deeper look at it yesterday night and I changed the default i3 config file by replacing alt with $alt and then did i3-wm.mod: Mod1 i3-wm.alt: Mod4 in the Xresources file. I think your solution would also work but now that I have changed the default i3 file i cannot try it anymore.

e4r7hbug commented 3 years ago

I'm experiencing this issue as well. To help verify the suggested workaround, my ~/.config/regolith/Xresources before:

! ~/.config/regolith/Xresources
i3-wm.alt: Mod4
i3-wm.mod: Mod1

Produces errors that look the same:

ERROR: Duplicate keybinding in config file:
  state mask 0x8 with keysym space, command "exec rofi -show find -modi find:/usr/share/rofi/modi/finder.sh"
ERROR: Duplicate keybinding in config file:
  state mask 0x8 with keysym l, command "focus right"
ERROR: Duplicate keybinding in config file:
  state mask 0x8 with keysym Right, command "workspace next"
ERROR: Duplicate keybinding in config file:
  state mask 0x8 with keysym Left, command "workspace prev"
ERROR: Duplicate keybinding in config file:
  state mask 0x8 with keysym grave, command "exec --no-startup-id /usr/share/i3xrocks/next-workspace --startnum 1 --move-window-and-follow"
ERROR: FYI: You are using i3 version 4.18.2 (2020-07-26)
/run/user/1000/i3/errorlog.8245 (END)

No more errors after adding the configurations.

  1. Adding the suggested block to ~/.config/regolith/Xresources from https://github.com/regolith-linux/regolith-desktop/issues/504#issuecomment-725814257
    ! ~/.config/regolith/Xresources
    i3-wm.mod: Mod1
    i3-wm.alt: Mod4
    i3-wm.binding.file_search: Mod4
    i3-wm.binding.ws_next2: Mod4+Right
    i3-wm.binding.ws_prev2: Mod4+Left
    i3-wm.binding.take_next_free: Mod4+grave
    i3-wm.binding.look_selector: Mod4+l
  2. Logging out
  3. Logging in
  4. No more errors pop up

Thank you for the workaround configuration!

kgilmer commented 3 years ago

FWIW the root of this issue is: "Variables are directly replaced in the file when parsing. Variables expansion is not recursive so it is not possible to define a variable with a value containing another variable."

The only solution I can see is to pull all references to modifier keys directly into the keybinding expression. The downside of this change is that for those keybindings, the modifier key sequences cannot be overridden by Xresource settings and will need direct edits to the config file. However, I see this as less serious as that limitation is already the case in the sense that Mod/Alt cannot be selectively changed without changing the config file itself. I guess the question becomes, what will occur more often: users wanting to swap alt and super, or users wanting tochange the keybindings for the 5 sequences above that happen to use both alt and super?

kgilmer commented 3 years ago

Given that this change will result in breaking changes for i3 config customizers, this fix will be moved to the next major version release.

a-crate commented 2 years ago

@kgilmer Have you given any thought to dynamically setting the comments above each keybinding so that they're updated for the swap? If it was part of a script (regolith-look swap-mod-keys or regolith-look set-primary-modkey Mod1 something) it could edit comments as well as make the swap easier for users.

kgilmer commented 2 years ago

A script would probably work, but would need to write into the user directory. Another approach is to provide an alternative set of i3 config partials specifically to handle alt as super. Actually, with config partials it may be possible to achieve this by swapping out a single partial. I'll have to experiment but if it works probably the best approach.

GlenHenshaw commented 2 years ago

I just tried this, and I still get an error even after the suggested modification to Xresources. Specifically, I am getting a single duplicate keybinding:

  state mask 0x8 with keysym space, command "exec rofi -show find -modi find:/usr/share/rofi/modi/finder.sh"

My Xresource file:

i3-wm.mod: Mod1
i3-wm.alt: Mod4
i3-wm.binding.file-search: Mod4
i3-wm.binding.ws_next2: Mod4+Right
i3-wm.binding.ws_prev2: Mod4+Left
i3-wm.binding.take_next_free: Mod4+grave
i3-wm.binding.look_selector: Mod4+l
kgilmer commented 2 years ago

are you on Regolith 2 @GlenHenshaw?

GlenHenshaw commented 2 years ago

1.6. Installed with the ppa on top of Ubuntu Server 20.04 on a Raspberry Pi.


Glen @.***

"Let us think the unthinkable, let us do the undoable, let us prepare to grapple with the ineffable itself, and see if we may not eff it after all.”

On Apr 12, 2022, at 1:49 AM, Ken Gilmer @.***> wrote:

 are you on Regolith 2 @GlenHenshaw?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.

GlenHenshaw commented 2 years ago

I'm going to need some help to solve this. I've been trying random key binding combinations for an hour now, and the error message I get back is always exactly the same. Clearly I'm missing something.

kgilmer commented 2 years ago

@GlenHenshaw ,

state mask 0x8 with keysym space, command "exec rofi -show find -modi find:/usr/share/rofi/modi/finder.sh"

The line associated with this error: https://github.com/regolith-linux/regolith-i3-gaps-config/blob/master/config#L124

You're overriding i3-wm.binding.file-search. The keybinding by default is: Mod1+space and you're setting it to just Mod4, making the complete keybinding Mod1+Mod4 which I am not sure is supported by i3. You'll need to set it to something that is not already used and (I think) need ot use a key other than a modifier key. If that doesn't help unravel the problem kindly share your i3 config file.

danwritecode commented 1 month ago

Hey all, this is still an issue. I cannot swap my my alt and win key as specified above. I also added all the extra lines as also specified above. I'm using regolith3 on ubuntu 24.04 on a brand new install.

I really would love to be able to swap these, not a big fan of using the windows key.

Here is my Xresources file, the changes work, but the error remains of duplicate key bindings.

wm.mod: Mod1
wm.alt: Mod4
wm.binding.file_search: Mod4
wm.binding.ws_next2: Mod4+Right
wm.binding.ws_prev2: Mod4+Left
wm.binding.take_next_free: Mod4+grave
wm.binding.look_selector: Mod4+l
kgilmer commented 1 month ago

Which of those are conflicting in 3.2 @danwritecode ?

KieranReck commented 21 hours ago

Hi all, I just tried this on a fresh regolith3.2 and it is still an issue.

How to recreate

I added the following to my Xresources file and restarted my session:

wm.mod: Mod1
wm.alt: Mod4
wm.binding.file_search: Mod4
wm.binding.ws_next2: Mod4+Right
wm.binding.ws_prev2: Mod4+Left
wm.binding.take_next_free: Mod4+grave
wm.binding.look_selector: Mod4+l 

The i3 error message was long, but it boiled down to this:

state mask 0x8 with keysym 5, command "move container to workspace number 5; workspace number 5"
ERROR: Duplicate keybinding in config file:
  state mask 0x8 with keysym 6, command "move container to workspace number 6; workspace number 6"
ERROR: Duplicate keybinding in config file:
  state mask 0x8 with keysym 7, command "move container to workspace number 7; workspace number 7"
ERROR: Duplicate keybinding in config file:
  state mask 0x8 with keysym 8, command "move container to workspace number 8; workspace number 8"
ERROR: Duplicate keybinding in config file:
  state mask 0x8 with keysym 9, command "move container to workspace number 9; workspace number 9"
ERROR: Duplicate keybinding in config file:
  state mask 0x8 with keysym 0, command "move container to workspace number 10; workspace number 10"
ERROR: Duplicate keybinding in config file:
  state mask 0xc with keysym 1, command "move container to workspace number 11; workspace number 11"
ERROR: Duplicate keybinding in config file:
  state mask 0xc with keysym 2, command "move container to workspace number 12; workspace number 12"
ERROR: Duplicate keybinding in config file:
  state mask 0xc with keysym 3, command "move container to workspace number 13; workspace number 13"
ERROR: Duplicate keybinding in config file:
  state mask 0xc with keysym 4, command "move container to workspace number 14; workspace number 14"
ERROR: Duplicate keybinding in config file:
  state mask 0xc with keysym 5, command "move container to workspace number 15; workspace number 15"
ERROR: Duplicate keybinding in config file:
  state mask 0xc with keysym 6, command "move container to workspace number 16; workspace number 16"
ERROR: Duplicate keybinding in config file:
  state mask 0xc with keysym 7, command "move container to workspace number 17; workspace number 17"
ERROR: Duplicate keybinding in config file:
  state mask 0xc with keysym 8, command "move container to workspace number 18; workspace number 18"
ERROR: Duplicate keybinding in config file:
  state mask 0xc with keysym 9, command "move container to workspace number 19; workspace number 19"
ERROR: FYI: You are using i3 version 4.23 (2023-10-29)
ERROR: Received ConfigureNotify for unknown window 0x01000000
ERROR: Received ExposeEvent for unknown window 0x01000000
ERROR: Received ConfigureNotify for unknown window 0x01000000
ERROR: Received ConfigureNotify for unknown window 0x0100000b
ERROR: Received ExposeEvent for unknown window 0x0100000b
ERROR: Received ConfigureNotify for unknown window 0x0100000b
(END)

Note, I have truncated this error message because all of the error messages were referring to "move container to workspace...". Let me know if you want the full error message

This error still allows you to use Alt as your mod key, but some of the keybindings didnt work (specifically moving a window to a different workspace using <win>+<alt>+$ws)

Possible Solution

I managed to solve this duplication issue, the error seems to stem from /usr/share/regolith/common/config.d/40_workspace-config.

Line 94 mentions Mod1.

To solve the problem I did the following:

Bonus Info

With this fix, it seems that you dont need all of the extra Xresource changes mentioned in the original response, you can get away with just these two:

wm.mod: Mod1
wm.alt: Mod4

Hope this helps, let me know if you need any more info!