Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'include' functionality #35

Open
macxcool opened this issue Oct 23, 2022 · 11 comments
Open

Add 'include' functionality #35

macxcool opened this issue Oct 23, 2022 · 11 comments

Comments

@macxcool
Copy link

It would be very cool if this could handle 'include' statements in the config to pull in other config files with key definitions.

@elder-n00b
Copy link
Contributor

Include statements should work, do you have a case where they don't?
Note that environment variables like $HOME will have to be written ${HOME} in the config file or they won't expand.

@macxcool
Copy link
Author

My include lines look like this:
include includes/keys_workspaces
I'm just specifying the subfolder, not the full path. Is that why there's a problem?

@elder-n00b
Copy link
Contributor

elder-n00b commented Oct 24, 2022

It's a possibility.
See if specifying the correct absolute path makes a difference (after reloading i3/sway config and restarting i3keys).

Just to make sure I understand correctly, your includes/keys_workspaces works in i3/sway but the bindings therein are not detected by i3keys?

I did some quick tests, and relative includes seem to be working fine here, also from a subdirectory.
Things that come to mind:

  • a typo? sway does not complain about missing includes (don't know about i3)
  • i3keys reads the configuration once at start, if it's changed while running it won't notice until restarted
  • perhaps in some cases i3/sway and i3keys disagree about what a relative path is relative to?

By the way, is it i3 or sway you are running? It shouldn't make any difference, but just in case. (sway here)

@macxcool
Copy link
Author

I'm using i3, but yes, the keybindings work just fine but don't show up in i3keys. I'll try the absolute paths later today.
As for your 'things that come to mind' ;-) the first two don't apply, but the 3rd one is certainly plausible. I don't mind putting absolute paths in my configs if needed. It doesn't matter to me.
I love this program, btw! Thanks for it.

@elder-n00b
Copy link
Contributor

Interesting, I'll try look into it some more. If I manage to reproduce the problem, probably I can fix it too and PR.
P.S. thank Rasmus, he wrote it. I'm just passing by.

@RasmusLindroth
Copy link
Owner

I think I've found the problem.
It seems the program only gets the path for sway and not i3

configPath, _ := helpers.GetSwayDefaultConfig()

So the fix should be quite easy, just create a function equal to helpers.GetSwayDefaultConfig() and send the name of the window manager down to the parse function. I'll look into it later and test it, but in the meantime absolute paths should work :)

@macxcool
Copy link
Author

Cool. I'll await your fix and test it on my setup. I'm in no big hurry. ;-)

@RasmusLindroth
Copy link
Owner

@macxcool Do you have sway installed on your computer? Because now that I look at the code it should be picking up i3 folders if you don't have it installed

@RasmusLindroth
Copy link
Owner

Could you test this branch and see it it works?

https://github.com/RasmusLindroth/i3keys/tree/i3-include-test

cd /tmp
git clone https://github.com/RasmusLindroth/i3keys.git
cd i3keys
git checkout i3-include-test
go build
/tmp/i3keys web 8080

@macxcool
Copy link
Author

Yes. I do have sway installed, just for experimenting with. I run i3, normally, though.

I will test that this evening (i.e. in a couple of hours)

@macxcool
Copy link
Author

That works. I see all my configured bindings and my modes and everything! Cool.

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

No branches or pull requests

3 participants