nix-community / home-manager

Manage a user environment using Nix [maintainer=@rycee]
https://nix-community.github.io/home-manager/
MIT License
6.56k stars 1.73k forks source link

bug: home.keyboard.options does nothing #4841

Open AshleyYakeley opened 7 months ago

AshleyYakeley commented 7 months ago

Are you following the right branch?

Is there an existing issue for this?

Issue description

I have this in my Home Manager config, to disable the caps lock key:

home.keyboard.options = ["caps:none"];

However, it doesn't work. Apparently HM is supposed to create a oneshot user-level systemd unit called setxkbmap to make the call, but I'm not seeing that in systemctl --user list-units or in systemctl --user list-unit-files.

If I call setxkbmap -option caps:none directly it correctly disables the caps lock key, but I want Home Manager to do it.

Related: #3795, however, I am using MATE/Marco rather than Sway.

Maintainer CC

No response

System information

$ nix-info -m
 - system: `"x86_64-linux"`
 - host os: `Linux 6.1.69, NixOS, 23.11 (Tapir), 23.11.20231225.d02d818`
 - multi-user?: `no`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.1`
 - channels(root): `""`
 - channels(ashley): `""`
 - nixpkgs: `not found`
AshleyYakeley commented 7 months ago

Looks like @rycee last touched this part of the code.

stuart-warren commented 7 months ago

I can see a user service

cat .config/systemd/user/setxkbmap.service 
[Install]
WantedBy=graphical-session.target

[Service]
ExecStart=/nix/store/hy9plgqdghxbx6wsn1wa2ivk17qkxkim-setxkbmap-1.3.4/bin/setxkbmap -layout 'us' -variant 'dvorak' -option '' -option 'ctrl:nocaps'
RemainAfterExit=true
Type=oneshot

[Unit]
After=graphical-session-pre.target
Description=Set up keyboard in X
PartOf=graphical-session.target

I can manually enable it

sudo systemctl enable ~/.config/systemd/user/setxkbmap.service

but it fails to run

sudo journalctl -u setxkbmap   
Jan 06 21:06:18 stuartwarren-MacBookPro systemd[1]: Starting Set up keyboard in X...
Jan 06 21:06:18 stuartwarren-MacBookPro setxkbmap[34826]: Cannot open display "default display"
Jan 06 21:06:18 stuartwarren-MacBookPro systemd[1]: setxkbmap.service: Main process exited, code=exited, status=1/FAILURE
Jan 06 21:06:18 stuartwarren-MacBookPro systemd[1]: setxkbmap.service: Failed with result 'exit-code'.
Jan 06 21:06:18 stuartwarren-MacBookPro systemd[1]: Failed to start Set up keyboard in X.
AshleyYakeley commented 7 months ago

Interesting. I can't even see a user service.

$ cat .config/systemd/user/setxkbmap.service
cat: .config/systemd/user/setxkbmap.service: No such file or directory
stuart-warren commented 7 months ago

think you might need:

xsession = {
  enable = true;
};

and then somehow load the ~/.xsession to make it work, though I configure i3 using home-manager https://nix-community.github.io/home-manager/options.xhtml#opt-xsession.windowManager.i3.enable and had to create a /usr/share/xsession/xsession.desktop file

[Desktop Entry]
Name=XSession
Comment=This session uses the custom xsession file
Exec=/etc/X11/Xsession
Type=Application

So it does kind of work if you do all that and manually enable the user systemd units

stale[bot] commented 4 months ago

Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting.

If you are the original author of the issue

* If this is resolved, please consider closing it so that the maintainers know not to focus on this. * If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

If you are not the original author of the issue

* If you are also experiencing this issue, please add details of your situation to help with the debugging process. * If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.

Memorandum on closing issues

Don't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.