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
services.xserver.imwheel: add module #71052
Conversation
a0de9e5
to
31272dd
Compare
ac08ec6
to
8472a25
Compare
rebased. Any idea who to ask for a review @worldofpeace @infinisil @jhillyerd ? |
I haven't done services yet with NixOS, so I'm probably not the best to review. One comment though: could we make |
I guess that would be an option though I'm not sure if there is not any valid usecases for overriding that flug though I guess there isn't any. |
@jhillyerd I think I found a problem with this. If |
8472a25
to
283454b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
approving w/ a couple nit picks.
3a80908
to
a8e00d9
Compare
'''; | ||
''; | ||
description = ''' | ||
Window's translation rules. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't honestly even know what is the right terminology to use there. Any suggestion for improvements are welcome.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe Window class translation rules.
since that's what is being matched?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I like it
changes based on feedback are implemented but I would still want to try it out on my desktop to be sure it works. |
a8e00d9
to
8416ea4
Compare
Ready for next review. Sorry it took so long. I needed to find some time while I'm on a machine that actually has mouse attached. Example configuration I've tested this with: services.xserver.imwheel = {
enable = true;
rules = {
"chromium-browser" = ''
None, Up, Button4, 8
None, Down, Button5, 8
Shift_L, Up, Shift_L|Button4, 4
Shift_L, Down, Shift_L|Button5, 4
Control_L, Up, Control_L|Button4
Control_L, Down, Control_L|Button5
'';
};
}; I've also tested 2 mouses with multiple buttons to make sure default configuration doesn't break things like back and forward buttons. |
|
||
options = mkOption { | ||
type = types.listOf types.str; | ||
default = ["--detach" "--buttons 45" "--kill"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd do some changes regarding this:
- If users set this to e.g.
["--buttons 45"]
they would override the--detach
option (which actually should be called--no-detach
or so anyways), so the service would fork off, which is not as nicely handled anymore then. So I suggest to add--detach
unconditionally in theExecStart
to prevent this. I don't see any reason anybody would want to change that anyways. - The name
options
is already an overloaded term from the module system, and with above change,extraOptions
is more fitting, which is also the standard naming for such options. - Unless I'm missing something, I don't see a reason
--buttons 45
should be passed by default. Same with--kill
which doesn't make any sense here, or does it? So I'd just makedefault = []
but put some examples inexample = [ "--debug" "--buttons 45" ]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These defaults are based mostly on my experimentation because sadly running IMWheel without flags causes some issues
detach
is by default true so passing--detach
toggles it so it doesn't detach. Which I believe makes more sense when it's ran as a service.kill
meas that any already running IMWheel process will be killed when this one starts. I think this also make sense because otherwise result can be unpredictablebuttons 45
is passed because without this IMWheel breaks functionality of additional mouse buttons like back and forward (tested with Logitech and MAD Rat)
Using defaults make it still possible for user to easily overwrite those things. This is why there is a pkill
https://github.com/NixOS/nixpkgs/pull/71052/files#diff-ea25b843a6681ed1b7711805ec769667R64 so in case --detach
is not passed (and so process is detached) IMWheel is still killed when service stops. This is also related to this comment #71052 (comment) and my reaction #71052 (comment).
so TL;DR:
--detach
is to prevent detaching which imo makes more sense for a service--buttons 45
is to avoid breaking addition mouse buttons with default settings (justenable = true
)--kill
is to avoid multiple IMWheel processes (whenever started manually or by systemd)pkill
is used in cases someone overwrides defaults but doesn't pass--detach
or-d
Which this in mind do you think want to change these defaults @infinisil ?
EDIT: There is also no --no-detach
flag available
EDIT: Passing some aruguments twice disables it so:
imwheel -d -d
has same effect as imwhell
imwheel -d -d -d
has same effect as imwheel -d
This makes it a bit more problematic to make some flags mandatory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry for ping @infinisil I don't want to be too pushy about this. I'm happy to implement any changes, just want to make sure you still feel we want to do them considering the comment above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems regardless of any changes to the defaults, the rename from options
to extraOptions
should happen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm okay I can see the buttons
default being reasonable, but --detach
and maybe --kill
too can imo be added like
{
ExecStart = "${pkgs.imwheel}/bin/imwheel" + escapeShellArgs ([
"--detach"
"--kill"
] ++ cfg.extraOptions);
}
This means even when the user doesn't specify them in extraOptions
, they still get added, and the expectation is that users won't add --detach
in extraOptions
. It should feel like "Extra options in addition to the ones NixOS adds on its own because they always make sense to use"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @infinisil for the feedback. I've incorporate this change. just few remarks:
- I've add space behind
bin/imwheel
because I don't think escapeShellArgs do that. Let me know if that's not right. - There is still the pkill on
ExecStop
. With these additional changes it might make sense to incorporate even change to Simple type - depends of if we want to try to protect user from shooting him/herself in foot (multiple --detach arguments case) or we want to make assumption default is good and if someone overrides it by combination of extraOptions then it's his/her thing to deal with. - I've retested changes with
nixos-rebuild -I ....
8416ea4
to
cbfac1b
Compare
rebased onto master |
0134cec
to
f6832e3
Compare
f6832e3
to
7406c0a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good!
Add IMWheel module.
sandbox
innix.conf
on non-NixOS)nix-shell -p nix-review --run "nix-review wip"
./result/bin/
)nix path-info -S
before and after)Notify maintainers
cc @