Numlock on at startup openbox?

Hi,
I have done this before but cant find it anywhere in my Joplin notes
I also searched and found the below

https://wiki.archlinux.org/title/Activating_numlock_on_bootup#OpenBox

But neither numlockx & nor numlockx on & in my autostart works
I’m accessing autostart from the openbox menu which is opening my ~/.config/openbox/autostart

Any ideas please?
its annoying as I keep getting into insert mode inadvertently

Put numlockx & in your .xinitrc file but above the exec openbox` line. Logout and back in.

My .xinitrc for reference:

#!/bin/sh

userresources=$HOME/.Xresources
usermodmap=$HOME/.Xmodmap
sysresources=/etc/X11/xinit/.Xresources
sysmodmap=/etc/X11/xinit/.Xmodmap

# merge in defaults and keymaps
if [ -f $sysresources ]; then

    xrdb -merge $sysresources
fi

if [ -f $sysmodmap ]; then
    xmodmap $sysmodmap
fi

if [ -f "$userresources" ]; then

    xrdb -merge "$userresources"
fi

if [ -f "$usermodmap" ]; then
    xmodmap "$usermodmap"
fi

# start some nice programs

if [ -d /etc/X11/xinit/xinitrc.d ] ; then
 for f in /etc/X11/xinit/xinitrc.d/?*.sh ; do
  [ -x "$f" ] && . "$f"
 done
 unset f
fi

# Statusbar loop
#while true; do
#   xsetroot -name "$( date +"%F %R" )"
#   sleep 1m    # Update time every minute
#done &

xset +fp /home/dobbie/.local/share/fonts
xset fp rehash

#setxkbmap -option caps:swapescape
 
/usr/lib/xfce-polkit/xfce-polkit &
gnome-keyring-daemon --start --components=pkcs11 &
#nm-applet --no-agent &
#volumeicon &
numlockx &
slstatus &
/usr/bin/setxkbmap -option terminate:ctrl_alt_bksp &
#xcompmgr -n -c -C -t-5 -l-5 -r4.2 -o.55 &
picom &
#mpd &
mpdscribble &
yams &
yams --keep-alive &
/usr/bin/cursor &
/usr/bin/greenclip daemon &
thunar --daemon &
xfce4-power-manager &
xfsettingsd &
/usr/bin/start-pulseaudio-x11 &
paplay /usr/share/sounds/freedesktop/stereo/service-login.oga &
#xscreensaver -no-splash &
easyeffects --gapplication-service &
~/.fehbg &
#hsetroot -root -fill /home/dobbie/Pictures/black-church.png &
#sleep 7 && polybar -r dwmr &
#sleep 5 && polybar -r dwm &
conky -c ~/.conky/dualnp &
conky -c ~/.conky/clock &


exec dwm

Also, further reading.

1 Like

Thanks
https://wiki.archlinux.org/title/Activating_numlock_on_bootup#startx
I had installed numlockx with the entry in my autostart but with no luck,


# required for xfce settings to work
xfsettingsd &

# start the panel
tint2 &

# touchpad-indicator
touchpad-indicator &

# Conky
sleep 1 && conky -c ~/.config/conky/ArchLabs.conkyrc &

# Nextcloud
#sleep 1 && nextcloud &

# Enpass
sleep 1 && enpass &

# restore the last wallpaper applied with nitrogen
sleep 1 && nitrogen --restore &

# activate numlock
numlockx &

Then I tried putting it in .xinitrc but again no luck (with or without it also in autostart as well)

#!/bin/sh

# this file is run when calling startx

# default arch init scripts
if [ -d /etc/X11/xinit/xinitrc.d ]; then
    for f in /etc/X11/xinit/xinitrc.d/?*.sh; do
        [ -x "$f" ] && . "$f"
    done
fi

# user init scripts and settings
[ -r /etc/X11/xinit/.Xmodmap ] && xmodmap /etc/X11/xinit/.Xmodmap
[ -r ~/.Xmodmap ] && xmodmap ~/.Xmodmap
[ -r ~/.Xresources ] && xrdb -merge ~/.Xresources
[ -r ~/.xprofile ] && . ~/.xprofile

numlockx &

# launch the session, commands below this line will be ignored
exec openbox-session
#exec i3

EDIT also no luck with

numlockx on &

Hey this probably might not but work but see if numlock is enabled in your BIOS. Just something to try.

also maybe try running numlockx on in the terminal and rebooting first before checking the BIOS setting.

1 Like

I also thought maybe it could be a conflict with the xfce4 settings keyboard so I tried editing out the

numlockx &

from both autostart and .xinitrc and then selecting ‘restore numlock state on startup’

but no luck

Then when changing this xfce4 settings back again I noticed my keyboard layout was ASUS Laptop, so I tried changing that back to Generic 105-key PC and uncommented

numlockx &

In my autostart and voila!

Thanks for your help @Dobbie03

of course, I am going to ask ‘why?’ :grin:

2 Likes

Good find, glad it is sorted.

1 Like