恥は/dev/nullへ by 初心者

プログラミング素人がのろのろと学んだことをつづっています♪

Debian環境設定(3) 起動時にNumLockをONにする

コンソール画面でテンキーを使ったら数字が入力されなかったので、NumLockがOFFになっていることに気づきました。そこで、NumLockをONにする方法を調べました。

 

 

環境

Debian 10 (buster)on VirtualBox 6.1.6

 

setledsコマンド

ネット情報によると、以下のコマンドが使えそうです。

setleds

manページを読むと、このコマンドは、NumLockキー、CapsLockキー、Scrollキーの挙動を設定するものでした。
NumLockをONにする場合は、以下のようにします。

setleds +num

毎回コマンドを実行するのは面倒なので、このコマンドをホームディレクトリの.profileに記述しました。
実験がてら一度ログアウトして再ログインしたらNumLockがONになっていました。解決です。

 

-Dオプション

manには、 -D オプションについて以下の説明があります。

With option -D, setleds will change both the VT flags and their default settings (so that a subsequent reset will not undo the change). This might be useful for people who always want to have numlock set.

これが正しければ、-D オプションを付けてsetledsを実行することによりデフォルト設定が変更されるはずです。
そこで、rootユーザーでログインし直して、

setleds -D +num

を実行してみました。

しかし、ログアウトしてから再ログインするとNumLockがONになっていませんでした。この点がやや謎ですが、.profileにコマンドを記述しておけば実用上の問題は無いので、深く考えないことにしました^^;。

 

manページの説明(一部抜粋)

Name
setleds - set the keyboard leds

 

Synopsis
setleds [-v] [-L] [-D] [-F] [{+|-}num] [{+|-}caps] [{+|-}scroll]

 

Description
Setleds reports and changes the led flag settings of a VT (namely NumLock, CapsLock and ScrollLock). Without arguments, setleds prints the current settings. With arguments, it sets or clears the indicated flags (and leaves the others unchanged). The settings before and after the change are reported if the -v flag is given.

 

(中略)

 

Options
-num +num
Clear or set NumLock. (At present, the NumLock setting influences the interpretation of keypad keys. Pressing the NumLock key complements the NumLock setting.)

 

-caps +caps
Clear or set CapsLock. (At present, the CapsLock setting complements the Shift key when applied to letters. Pressing the CapsLock key complements the CapsLock setting.)

 

-scroll +scroll
Clear or set ScrollLock. (At present, pressing the ScrollLock key (or ^S/^Q) stops/starts console output.)

 

 

X Window起動時にNumLockをONにする方法

X Window起動時にNumLockをONにする手順については以下の記事のとおりです。

https://uhoho.hatenablog.jp/entry/2021/09/01/025630