1 |
2014-06-20 9:06 GMT-06:00 Canek Peláez Valdés <caneko@×××××.com>: |
2 |
> On Fri, Jun 20, 2014 at 4:06 AM, <covici@××××××××××.com> wrote: |
3 |
>> Hi. I want to turn numlock automatically, but I am using systemd and I |
4 |
>> am having troubles doing this. At someones suggestion in a previous |
5 |
>> message (I think Canek's) I created |
6 |
>> /etc/systemd/system/getty@service.d/numlock.conf with the following |
7 |
>> contents |
8 |
>> |
9 |
>> [Service] |
10 |
>> ExecStartPost=/usr/bin/setleds -D -num </dev/%I |
11 |
>> |
12 |
>> |
13 |
>> However, setleds dies with the following error: |
14 |
>> Jun 19 14:24:55 ccs.covici.com setleds[4878]: KDGKBLED: Inappropriate |
15 |
>> ioctl for device |
16 |
>> Jun 19 14:24:55 ccs.covici.com setleds[4878]: Error reading current |
17 |
>> flags setting. Maybe you are not on the console? |
18 |
>> |
19 |
>> I tried to fool with chvt to make the console current, but no joy there. |
20 |
>> |
21 |
>> Any assistance would be appreciated. |
22 |
> |
23 |
|
24 |
This has called my attention as it would be nice to activate numlock |
25 |
by default on console(altought not that important for me anyway ) |
26 |
|
27 |
> Could you post the exact invocation for setleds? It should be on the |
28 |
> logs. I think the invocation for setleds shuld be: |
29 |
> |
30 |
> /usr/bin/setleds -D +num < /dev/%i |
31 |
> |
32 |
I have tried this but after skimming trough the manpage |
33 |
systemd.service(5), I've found this command will not work, as a |
34 |
parameter for any of ExecStart* since redirection and pipes(these are |
35 |
mentioned << < | > >> ) are not supported. |
36 |
I'd like to mention also that not executing setleds as follows, with |
37 |
'-' before the binary path : |
38 |
|
39 |
ExecStartPost=-/usr/bin/setleds -D -num </dev/%i |
40 |
|
41 |
breaks the start of the whole getty service, making it unable to login |
42 |
in into any console |
43 |
The way to work around this recommended in the manual is instead |
44 |
invoking a shell and make it run the commands: |
45 |
|
46 |
ExecStartPost=-/bin/sh -c 'setleds -D +num < /dev/%i' |
47 |
|
48 |
This worked pretty well and can be tested without reboot, on tty8 for example : |
49 |
- edit files |
50 |
- run sudo systemctl daemon-reload |
51 |
- run systemctl start getty\@tty8.service |
52 |
Ctrl+Alt+F8 and see what happened . |
53 |
|
54 |
> The difference between %I (capital "i") and %i is only that %i escapes |
55 |
> special symbols, but since it's only the string tty[1-N], I don't |
56 |
> think it matters much. |
57 |
> |
58 |
> The exact invocation of setleds matters, so we can see if the template |
59 |
> unit is generating the correct one. |
60 |
> |
61 |
I leave my 'systemctl stauts -l getty@××××.service' output just for |
62 |
completness of reference of what errors where shown: |
63 |
|
64 |
● getty@××××.service - Getty on tty1 |
65 |
Loaded: loaded |
66 |
(/etc/systemd/system/getty.target.wants/../../../../usr/lib/systemd/system/getty@.service; |
67 |
enabled) |
68 |
Drop-In: /etc/systemd/system/getty@.service.d |
69 |
└─numlock.conf |
70 |
Active: active (running) since vie 2014-06-20 10:11:57 CST; 8s ago |
71 |
Docs: man:agetty(8) |
72 |
man:systemd-getty-generator(8) |
73 |
http://0pointer.de/blog/projects/serial-console.html |
74 |
Process: 6384 ExecStartPost=/usr/bin/setleds -D +num < /dev/%i |
75 |
(code=exited, status=1/FAILURE) |
76 |
Main PID: 6383 (agetty) |
77 |
CGroup: /system.slice/system-getty.slice/getty@××××.service |
78 |
└─6383 /sbin/agetty --noclear tty1 linux |
79 |
|
80 |
jun 20 10:11:57 jdesk systemd[1]: Started Getty on tty1. |
81 |
jun 20 10:11:57 jdesk setleds[6384]: KDGKBLED: Inappropriate ioctl for device |
82 |
jun 20 10:11:57 jdesk setleds[6384]: Error reading current flags |
83 |
setting. Maybe you are not on the console? |
84 |
|
85 |
|
86 |
> Regards. |
87 |
> -- |
88 |
> Canek Peláez Valdés |
89 |
> Profesor de asignatura, Facultad de Ciencias |
90 |
> Universidad Nacional Autónoma de México |
91 |
> |
92 |
|
93 |
I hope this would help, have a nice day. |