Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
numlock with systemd
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
leonchik1976
Apprentice
Apprentice


Joined: 24 Jan 2010
Posts: 169

PostPosted: Thu Aug 21, 2014 11:23 am    Post subject: numlock with systemd Reply with quote

is it possible to turn numlock on automatically on console with systemd on boot?
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 7127
Location: almost Mile High in the USA

PostPosted: Thu Aug 21, 2014 6:00 pm    Post subject: Reply with quote

Found this:

https://wiki.archlinux.org/index.php/Activating_Numlock_on_Bootup

One possible solution from the link is to create a "Service" file perhaps numlock.service that contains

Code:
[Unit]
Description=Switch on numlock from tty1 to tty6

[Service]
ExecStart=/bin/bash -c 'for tty in /dev/tty{1..6};do /usr/bin/setleds -D +num < \"$tty\";done'

[Install]
WantedBy=multi-user.target


and enable it...
_________________
Intel Core i7 2700K@ 4.1GHz/HD3000 graphics/8GB DDR3/180GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
mackal
Tux's lil' helper
Tux's lil' helper


Joined: 04 Aug 2011
Posts: 87

PostPosted: Thu Aug 21, 2014 6:46 pm    Post subject: Reply with quote

https://wiki.archlinux.org/index.php/Activating_Numlock_on_Bootup#Extending_getty.40.service

I use this solution.
Back to top
View user's profile Send private message
guitou
Guru
Guru


Joined: 02 Oct 2003
Posts: 399
Location: France

PostPosted: Sun Nov 27, 2016 8:58 pm    Post subject: Reply with quote

Hi all.
Waking up an old thread.
Until today, I had managed to have numlock set for my tty consoles, but with an annoying side effect on tty1 (prompt displayed twice and interleaved, issues with login, as if I had 2 agetty processes at the same time).
So today I got rid of this and tried the Extending getty@.service described here too. But sadly it does not work for me.

Code:

# cat /etc/systemd/system/getty\@service.d/numlockOn.conf
[Service]
ExecStartPre=/bin/sh -c 'setleds -D +num < /dev/%I'


I don't think I made a typo since restarting a getty@.service shows me the expected Hint (and does activate Num as well btw).
However, no such happy behavior at boot time: numpad remains inactive on my terminals.

If someone has an idea why, or suggestions for troubleshooting, I'd be glad to know.

++
Gi)
Back to top
View user's profile Send private message
guitou
Guru
Guru


Joined: 02 Oct 2003
Posts: 399
Location: France

PostPosted: Mon Dec 05, 2016 1:05 pm    Post subject: Reply with quote

Replying to myself as I finally took time to struggle again and found out a "working" solution:

Code:
#cat /etc/systemd/system/getty\@.service.d/override.conf
[Service]
ExecStartPre=-/bin/bash -c 'setleds -D +num < /dev/%I'
ExecStart=
ExecStart=-/sbin/agetty --noclear --nohints %I $TERM


Well, did nothing original here, but had a hard time figuring out what went wrong, so let us review important points:
-the '-' before the command means service is considered active even if command does not return 0 (SUCCESS): makes sense to me for the setleds instruction, I'm more confused about why it is present for the getty command, but as this was here in original unit file, I prefered to keep it as is
-the use of the actual program /bin/bash instead of a symlink (/bin/sh) seems of importance too (a pity I did not think about it earlier!)
-I could read here and there that one ought to have command executed after (ExecStartPost=...), but it does randomly work for me (some VTs open like a charm, while other just fail, I cannot tell why)

As a last note, if you want to have 6 (or more) VTs reserved, you have to enable them:
Code:
systemctl enable getty@tty{2-5}

(provided tty1 should already be enabled, and tty6 should be the one reserved as default in logind.conf)

++
Gi)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum