Numlockx and making numlocks on at login screen

Every day solutions to every day challenges. + Brilliant stuff

Moderators: b1o, jkerr82508

Forum rules
Please feel free to post your tip it does not have to be advanced. Also ask questions directly related to the tip here. But do not start new threads with questions or ask for help here. That is what the help section is for. forum rules: http://bjoernvold.com/forum/viewtopic.php?f=8&t=568
User avatar
dedanna1029
Sound-Berserk
Posts: 8780
Joined: 14 Mar 2010, 20:29
Contact:

Numlockx and making numlocks on at login screen

Postby dedanna1029 » 09 Jan 2011, 05:01

For those using gdm, you may notice that installing numlockx and placing it into ~/.xinitrc are not enough; number pad is still off at the login screen. I've found a handy tip to make it stay on, all the way through your login screen:

I guess Suse is good for something, as this is where the tip came from:

make sure numlockx is installed. Edit /etc/gdm/Init/Default:

Code: Select all

if [ -x /usr/bin/numlockx ]; then
/usr/bin/numlockx on
fi


I went on this search after I found that numlock had once again been turned off at the login screen, after recent updates. I edited /etc/slim.conf with numlock on to no avail, I edited /etc/gdm/custom.conf to no avail, among other things. Adding this worked like a charm.

Edit for addition: The file and folder /etc/gdm/Init/Default are case-sensitive.

Code: Select all

#!/bin/sh
# Stolen from the debian kdm setup, aren't I sneaky
# Plus a lot of fun stuff added
#  -George

PATH="/usr/bin:$PATH"
OLD_IFS=$IFS

gdmwhich () {
  COMMAND="$1"
  OUTPUT=
  IFS=:
  for dir in $PATH
  do
    if test -x "$dir/$COMMAND" ; then
      if test "x$OUTPUT" = "x" ; then
        OUTPUT="$dir/$COMMAND"
      fi
    fi
  done
  IFS=$OLD_IFS
  echo "$OUTPUT"
}

sysresources=/etc/X11/Xresources

# merge in defaults
if [ -f "$sysresources" ]; then
    xrdb -merge "$sysresources"
fi

sysmodmap=/etc/X11/Xmodmap

XMODMAP=`gdmwhich xmodmap`
if [ "x$XMODMAP" != "x" ] ; then
  if [ "x$GDM_PARENT_DISPLAY" = "x" ]; then
    if [ -f $sysmodmap ]; then
      $XMODMAP $sysmodmap
    fi
  else
    ( DISPLAY=$GDM_PARENT_DISPLAY XAUTHORITY=$GDM_PARENT_XAUTHORITY $XMODMAP -pke ) | $XMODMAP -
  fi

  #
  # Switch Sun's Alt and Meta mod mappings
  #

  UNAME=`gdmwhich uname`
  PROCESSOR=`$UNAME -p`
  if [ "x$PROCESSOR" = "xsparc" ]; then
    if $XMODMAP | /usr/bin/grep mod4 | /usr/bin/grep Alt > /dev/null 2>/dev/null
    then
      $XMODMAP -e "clear Mod1" \
               -e "clear Mod4" \
               -e "add Mod1 = Alt_L" \
               -e "add Mod1 = Alt_R" \
               -e "add Mod4 = Meta_L" \
               -e "add Mod4 = Meta_R"
    fi
  fi
fi

SETXKBMAP=`gdmwhich setxkbmap`
if [ "x$SETXKBMAP" != "x" ] ; then
  # FIXME: is this all right?  Is this completely on crack?
  # What this does is move the xkb configuration from the GDM_PARENT_DISPLAY
  # FIXME: This should be done in code.  Or there must be an easier way ...
  if [ -n "$GDM_PARENT_DISPLAY" ]; then
    XKBSETUP=`( DISPLAY=$GDM_PARENT_DISPLAY XAUTHORITY=$GDM_PARENT_XAUTHORITY $SETXKBMAP -v )`
    if [ -n "$XKBSETUP" ]; then
      XKBKEYMAP=`echo "$XKBSETUP" | grep '^keymap' | awk '{ print $2 }'`
      XKBTYPES=`echo "$XKBSETUP" | grep '^types' | awk '{ print $2 }'`
      XKBCOMPAT=`echo "$XKBSETUP" | grep '^compat' | awk '{ print $2 }'`
      XKBSYMBOLS=`echo "$XKBSETUP" | grep '^symbols' | awk '{ print $2 }'`
      XKBGEOMETRY=`echo "$XKBSETUP" | grep '^geometry' | awk '{ print $2 }'`
      if [ -n "$XKBKEYMAP" ]; then
        $SETXKBMAP -keymap "$XKBKEYMAP"
      elif [ -n "$XKBTYPES" -a -n "$XKBCOMPAT" -a -n "$XKBSYMBOLS" -a -n "$XKBGEOMETRY" ]; then
        $SETXKBMAP -types "$XKBTYPES" -compat "$XKBCOMPAT" -symbols "$XKBSYMBOLS" -geometry "$XKBGEOMETRY"
      elif [ -n "$XKBTYPES" -a -n "$XKBCOMPAT" -a -n "$XKBSYMBOLS" ]; then
        $SETXKBMAP -types "$XKBTYPES" -compat "$XKBCOMPAT" -symbols "$XKBSYMBOLS"
      elif [ -n "$XKBSYMBOLS" ]; then
        $SETXKBMAP -symbols "$XKBSYMBOLS"
      fi
    fi
  fi
fi

if [ -x /usr/bin/numlockx ]; then
/usr/bin/numlockx on
fi

exit 0


The addition of this code MUST BE BEFORE the final "fi" in the file.
I'd rather be a free person who fears terrorists, than be a "safe" person who fears the government.
No gods, no masters.
"A druid is by nature anarchistic, that is, submits to no one."
http://uk.druidcollege.org/faqs.html

User avatar
dedanna1029
Sound-Berserk
Posts: 8780
Joined: 14 Mar 2010, 20:29
Contact:

Re: Numlockx and making numlocks on at login screen

Postby dedanna1029 » 12 Mar 2011, 23:03

This will not work for Fedora 14. A bug was filed on numlockx that is still unresolved. Not to mention, the maintainer of the bug, due to a language barrier, appears to have misunderstood what they were saying on comment #8 on the bug. The reporter on comment #8 wasn't asking for there to be no led effect. They were trying to let them know that there is no effect with it.

Oh boy...
I'd rather be a free person who fears terrorists, than be a "safe" person who fears the government.
No gods, no masters.
"A druid is by nature anarchistic, that is, submits to no one."
http://uk.druidcollege.org/faqs.html

User avatar
dedanna1029
Sound-Berserk
Posts: 8780
Joined: 14 Mar 2010, 20:29
Contact:

Re: Numlockx and making numlocks on at login screen

Postby dedanna1029 » 16 May 2011, 05:38

dedanna1029 wrote:This will not work for Fedora 14. A bug was filed on numlockx that is still unresolved. Not to mention, the maintainer of the bug, due to a language barrier, appears to have misunderstood what they were saying on comment #8 on the bug. The reporter on comment #8 wasn't asking for there to be no led effect. They were trying to let them know that there is no effect with it.

Oh boy...

They got a fix for it, but it won't be backported to F14. :(
I'd rather be a free person who fears terrorists, than be a "safe" person who fears the government.
No gods, no masters.
"A druid is by nature anarchistic, that is, submits to no one."
http://uk.druidcollege.org/faqs.html

User avatar
viking60
Über-Berserk
Posts: 9351
Joined: 14 Mar 2010, 16:34

Re: Numlockx and making numlocks on at login screen

Postby viking60 » 16 May 2011, 10:25

I am using Slim so I have not tested this. But I can confirm that the setting in slim.conf does not work.
Fixed it!
I love these kind of tips keep them coming.
Manjaro 64bit on the main box -Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz and nVidia Corporation GT200b [GeForce GTX 275] (rev a1. + Centos on the server - Arch on the laptop.
"There are no stupid questions - Only stupid answers!"

User avatar
dedanna1029
Sound-Berserk
Posts: 8780
Joined: 14 Mar 2010, 20:29
Contact:

Re: Numlockx and making numlocks on at login screen

Postby dedanna1029 » 16 May 2011, 23:19

That's in Arch though. It will work in F15 because they're sending the fix out for it, but it won't work in F14, as the fix isn't being backported to it.

Slim also currently doesn't work in Fedora, as they've simlinked the backgrounds for it to the wrong path, and I can't recall what the right one is.

The fix given in the first post to this thread was for gdm.

As an addendum, however, the fix in the initial post to this thread will work for any other distro, any login manager, other than in Fedora <15, that also has slim available.
I'd rather be a free person who fears terrorists, than be a "safe" person who fears the government.
No gods, no masters.
"A druid is by nature anarchistic, that is, submits to no one."
http://uk.druidcollege.org/faqs.html

User avatar
dedanna1029
Sound-Berserk
Posts: 8780
Joined: 14 Mar 2010, 20:29
Contact:

Re: Numlockx and making numlocks on at login screen

Postby dedanna1029 » 24 Feb 2012, 22:25

After switching to GDM in Arch, due to the add new user bug with slim, I had some issues with this. No numlock on at the login screen. I tried the process in the initial post of this thread, to no avail, tried several other things as well. Did some reading up at the Ubuntu forums more than anywhere, and somebody had mentioned that "it may be best to put the code at the top of the file". Well, there is a difference between "may be best" and "must", but I tried putting it at the top of the file, and it worked. :)

I also was reminded that in systemsettings in KDE, there is an option to have numlock on at login for kdm, and so I turned that on as well.

Between the two, everything for numlock on at the login screen now works, but I do believe that putting that code in at the top of the file is a "must", and not just a "best to".


Return to “Tips & Tricks”