The problem here is that all the cases you've mentioned are somewhat different.
"The desktop login prompt"—as you've called it—is presented by the so-called desktop manager (DM) whose task is to authenticate the user and when it succeeds, to spawn an instance of X.org and run that user's X session on it, and Xfce kicks in only at that phase.
Putting a call to xmodmap
to ~/.bashrc
is not a too wise idea simply because xmodmap
assumes it's able to find the active X session (usually by looking for a variable named DISPLAY
in its environment, which is inherits from its parent process (which it inherits from theirs, and all the way back to the process responsible for bringing up an X session which actually sets that variable and exports it). So should you run bash
, say, on a plain virtual terminal—that textual console which you see when you hit Ctrl+Alt+F1 while in X,—that call to xmodmap
will bark at you for it will have been unable to locate an X server running an X session.
So basically your system roughly has several "phases" (or "contexts") of execution when it boots:
- The bootloader;
- Early boot / initramfs;
- System (after mounting the real root FS); the DM is spawned at this phase;
- The user's X session or the user's settion on a non-graphical session on a VT.
Another thing to note is that a Linux-based system running on a PC always has its users interact with it via virtual terminals (VTs), and an X server also runs on a VT, and is bound to it (and that's why you usually are able to switch to another, non graphical, VT while in X).
So, we could try to attack the problem this way:
- See if setting scroll lock to "on" on all the available VTs works—that is, when a DM starts on a VT and then spawns an X server, they both inherit the scoll lock setting.
- If that won't work, we can see which configuration your particular DM has (you did not tell us which DM you're using). It might have an ability to run external commands or it might have direct keyboard settings.
- If all that fails, we at least can see how Xfce may be made run an external command when it brings a user's session up.
So, while I don't have offhand answer to your problem, I'd attack it at step 3:
- This suggests using
setleds
to setting up LEDs at system startup.
- This explains how to set up NumLock at bootup using
setleds
and thus is trivially adaptable to the case of ScrollLock.