regolith-desktop icon indicating copy to clipboard operation
regolith-desktop copied to clipboard

Cannot change win and alt keys with Xresources

Open hugorichard opened this issue 4 years ago • 20 comments

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

  • Regolith Install Type: [ISO/PPA]
  • Regolith Version: [e.g. 1.4]
  • PPA url: [default: ppa:regolith-linux/release]
  • Host OS (for PPA): [e.g. Ubuntu 20.04]

Additional context Add any other context about the problem here.

hugorichard avatar Nov 11 '20 18:11 hugorichard

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!

moritzheiber avatar Nov 11 '20 18:11 moritzheiber

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
"

hugorichard avatar Nov 11 '20 22:11 hugorichard

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.

kgilmer avatar Nov 12 '20 03:11 kgilmer

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.

hugorichard avatar Nov 12 '20 09:11 hugorichard

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!

e4r7hbug avatar Dec 09 '20 01:12 e4r7hbug

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."

  • https://build.i3wm.org/docs/userguide.html

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 avatar Dec 09 '20 04:12 kgilmer

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

kgilmer avatar Dec 26 '20 01:12 kgilmer

@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.

a-crate avatar Dec 05 '21 19:12 a-crate

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.

kgilmer avatar Dec 06 '21 04:12 kgilmer

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

GlenHenshaw avatar Apr 12 '22 00:04 GlenHenshaw

are you on Regolith 2 @GlenHenshaw?

kgilmer avatar Apr 12 '22 05:04 kgilmer

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 avatar Apr 12 '22 12:04 GlenHenshaw

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.

GlenHenshaw avatar Apr 13 '22 01:04 GlenHenshaw

@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.

kgilmer avatar Apr 15 '22 01:04 kgilmer