Hello all,
I need help please. I want to turn on numlock at boot please.
I tried the following:
systemd.services.numlock = {
description = "Enable NumLock at startup";
wantedBy = [ "multi-user.target" ]; # Ensure it starts with the system
serviceConfig = {
Type = "oneshot";
RemainAfterExit = "yes";
ExecStart = "${pkgs.kbd}/bin/setleds +num"; # Command to turn on NumLock
};
};
But rebuilding NixOS fails with the following error:
setleds: Unable to read keyboard flags: Inappropriate ioctl for device
When runnging setleds
on a terminal, I get the same error.
Please help
gurkan
September 13, 2024, 2:33pm
2
Never used setleds, numlockx was working fine afair.
If you’re using home-manager:
xsession.numlock.enable
Otherwise, declaring it as user unit via systemd.user.services
might help.
Yes, I am aware of numlockx
. But:
It will not work when we all move to wayland since its only for X.
I want it enabled before X (or wayland for that matter) starts.
Yes, I am aware of the home-manager option. I wanna do it without home-manager.
gurkan
September 13, 2024, 3:47pm
4
Oh I missed this part from your original message:
Looks like another issue.
Could you try redirecting it to a TTY? Here is an example I found on github.
I tried it. Here is the result:
λ sudo setleds +num < /dev/tty1
zsh: permission denied: /dev/tty1
Same without sudo.
gurkan
September 14, 2024, 6:15pm
6
sudo cannot apply after the < part. You can run after switching to root though.
But what I suggested was to declare the systemd unit with setting like TTYPath = "/dev/tty8";
to force-run it on a TTY
gurkan:
TTYPath = "/dev/tty8";
I did what you asked, and the result is the same. Here is how I did it:
systemd.services.numlock = {
description = "Enable NumLock at startup";
wantedBy = [ "multi-user.target" ]; # Ensure it starts with the system
serviceConfig = {
TTYPath = "/dev/tty8";
Type = "oneshot";
RemainAfterExit = "yes";
ExecStart = "${pkgs.kbd}/bin/setleds +num"; # Command to turn on NumLock
};
};
gurkan
September 14, 2024, 7:58pm
8
As a last resort, could you also add:
StandardInput = "tty";
StandardOutput = "tty";
If this also does not work, I will have to give up
Nope. It did not help. But, there is no more error after rebuilding NixOS, but rebooting does not turn on the numlock.
Also, trying sudo systemctl enable numlock
and/or sudo systemctl start numlock
does not spews an error but also does not turn on the numlock.