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

Configure initial state for numlock/capslock #2330

Merged
merged 5 commits into from
Jul 25, 2018

Conversation

progandy
Copy link
Contributor

Set numlock state to enabled by default, keep capslock disabled and make this configurable.

The initial state of numlock and capslock can be set with
input ... xkb_numlock|xkb_capslock disable|enable

Implements #2311

Note: This relies wlr_keyboard_notify_modifiers which is not meant to be called by the compositor, but I found no other option to reliably set the modifiers.

I used the xkb_ prefix to indicate that setting the state will reload the keyboard configuration.
The commands use enabled/disabled instead of off/on to match the other boolean input commands.

@ddevault
Copy link
Contributor

Can you update the man page and address the build failure?

@ddevault
Copy link
Contributor

(still missing man page updates)

@progandy
Copy link
Contributor Author

progandy commented Jul 23, 2018

Now everything should be there. I had to clean up my local clone first.
I am a bit unsure about the "on sway startup", maybe "and reloads the keyboard layout" would be better?

@ddevault ddevault requested a review from RedSoxFan July 23, 2018 13:31

*input* <identifier> xkb\_numlock enabled|disabled
Enables or disables NumLock on sway startup, the default is enabled.
Only meaningful if sway controls the keyboard.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line can probably be removed from both.

@RedSoxFan
Copy link
Member

Since the implementation is not restricted to startup, you could change the man page to Enables or disables CapsLock/NumLock. The default on startup is disabled/enabled.

@progandy
Copy link
Contributor Author

I can do that. Should I somehow document that changing the value for NumLock resets CapsLock to the value stored in xkb_capslock as well? Maybe a general note that changing one xkb_ value applies all stored xkb_ values again.

@ddevault
Copy link
Contributor

Can't we get the current state of the modifiers and OR/AND them with only the bits we want to flip?

@progandy
Copy link
Contributor Author

The flags are currently set in the keyboard configuration and then applied with apply_keyboard_config / sway_keyboard_configure. There is no way to know which flag change was requested. I think I'd need a way to do different things when

  • sway detects a new keyboard (startup or hotplug)
  • swaymsg is sent for an existing keyboard

@ddevault
Copy link
Contributor

I see. Let's take the easy way out for now and just make it effective in the config file (not at runtime)?

@progandy
Copy link
Contributor Author

Is there a way to do that?

I think I could create a status flag in the input config that the next call should only update the marked modifier, but that feels like dirty code. There shouldn't be status information in a configuration structure.

@ddevault
Copy link
Contributor

Just add it to the appropriate list of commands in commands.c.

@RedSoxFan
Copy link
Member

I think the runtime portion of this can be added to the keyboard part of #1779

@ddevault
Copy link
Contributor

Aye.

@progandy
Copy link
Contributor Author

Somehow I missed that list, it is so short.

Should this stay an individual setting for each keyboard then or simply a global option for all keyboards? I think I'd prefer the global option then.

@ddevault
Copy link
Contributor

I like it individual, if you want global do input * xkb_numlock enable

@progandy
Copy link
Contributor Author

I can't add a subcommand of input to the config_commands list. I'll mark this as WIP and keep on thinking, maybe I'll get a good idea.

@progandy progandy changed the title Configure initial state for numlock/capslock [WIP] Configure initial state for numlock/capslock Jul 23, 2018
@RedSoxFan
Copy link
Member

I can't add a subcommand of input to the config_commands list. I'll mark this as WIP and keep on thinking, maybe I'll get a good idea.

See https:/swaywm/sway/blob/master/sway/commands/bar.c#L38 and
https:/swaywm/sway/blob/master/sway/commands/bar.c#L49

@progandy
Copy link
Contributor Author

I had another idea. What do you think about allowing the swaymsg command and just storing the new value? It will be applied only after hotplugging the keyboard or changing its layout.

@ddevault
Copy link
Contributor

Do whatever you want, just get something mergable. This feature is not that complicated.

After setting the keymap, try to enable NumLock and disable CapsLock.
This only works if sway has the xkb master state and controls the keyboard.
Prepare configuration settings for later use as well.
@progandy progandy changed the title [WIP] Configure initial state for numlock/capslock Configure initial state for numlock/capslock Jul 25, 2018
@progandy
Copy link
Contributor Author

@SirCmpwn, @RedSoxFan, the pull request is ready for review. I kept it restricted to the configuration file for now. Sometimes I try to perfect and polish too much.

PS: I had to rebase it against the current master.

@RedSoxFan RedSoxFan merged commit c8dc9b3 into swaywm:master Jul 25, 2018
@RedSoxFan
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants