Switching wsconsole screens with Alt-Fn in NetBSD and OpenBSD
The Linux console provides a number of "virtual terminals" (VTs) which can be accessed with the key combination Alt-Fn (n=1,2,...). FreeBSD provides a similar facility with the same keystrokes.
In NetBSD and OpenBSD the default console is called wsconsole (short for WorkStation console), and provides several virtual screens that are accessed with the key combination Ctrl-Alt-Fn.
Neither of these two key combinations is "right or wrong", and which is "better" depends on what you're used to. New users coming to NetBSD or OpenBSD who are used to the Linux convention Alt-Fn may find it frustrating to have to also press Ctrl- to switch screens. This can be particularly true when simultaneously working on two machines which use different conventions.
This guide will show how to change the NetBSD or OpenBSD screen switching keys to Alt-Fn, which I find to be easier. The basic principles on the two OS's are the same, but the syntax differs in places.
1b. Purpose and scope.
This guide is intended to be practical, rather than perfect.
2a. Changing the NetBSD key map on the fly.
This subsection focuses on NetBSD. The modifications for OpenBSD are summarized in the next subsection.
The keyboard mapping can be inspected, and changed, using the wsconsctl(8) command as root. For NetBSD this command may use the -k flag to access the keyboard (rather than the mouse or display), but -k can be left off since it's the default.
The existing keyboard map can be inspected with
Of particular interest to the topic at hand is to find map entries containing the items Cmd1, Cmd2 and Cmd. For example, on my machine I get this output:
This means the left Ctrl key also acts as Cmd1 and the left Alt key also acts as Cmd2. By default, Cmd1 and Cmd2 are both required together with Fn to switch virtual screens.
We want to change this so there is only a single Cmd key required, on Alt. I'll show how to do this in the context of the above example; if your keycodes are different, then make the appropriate changes. To do this we get rid of Cmd1 on left Ctrl (keycode 29), get rid of Cmd2 on left Alt (keycode 56) and add Cmd to left Alt. This can be done with the commands:
The -w flag tells wsconsctl to write the changes to the map.
Doing the above should allow any wsconsole commands previously accessible with Ctrl-Alt-* to be invoked with just left Alt-*, including switching screens with Alt-Fn, but this will only stay in effect for the current boot-up.
2b. Modifications for OpenBSD.
On OpenBSD, wsconsctl has no -k or -w flags. The syntax is
You may want to change Control_R and Alt_R as well.
3. Making the changes permanent.
If you want these changes to take effect automatically every time you boot, put them in the appropriate config files.
I begin with NetBSD. First, define a keyboard map file by adding the following line, or similar, into /etc/wscons.conf,
# Change Cmd_ "prefix" from Ctrl+Alt- to Alt- (all Left) # This is done by using Cmd rather than Cmd1 and Cmd2 ! # Remove first entry Cmd1 on RHS for left Control key: keycode 29 = Control_L # Remove first entry Cmd2 on RHS for left Alt key, and add Cmd: keycode 56 = Cmd Alt_L # Above could make Alt-Esc enter the debugger (dangerous?) # so let's turn off this capability which I never use anyway. # Remove first entry Cmd_Debugger on RHS: keycode 1 = Escape
Turning to OpenBSD, it's only necessary to modify a single config file,
to which changes in the form variable+=value are added, e.g.:
keyboard.map+="keycode 29 = Control_L" keyboard.map+="keycode 56 = Cmd Alt_L" keyboard.map+="keycode 1 = Escape"
OpenBSD FAQ Section 7.1 is minimalist.
* I have had this not work on an HP USB wireless keyboard.
* I never tried to change the Linux keys to Ctrl-Alt-Fn.
* I don't have a deep understanding of BSD wsconsole key mapping, as I didn't find any clear, friendly and thorough documentation. A study of the source code may be needed to learn more.
* Comments, criticisms, suggestions, etc., are welcome.
Last edited by IdOp; 1st September 2011 at 02:33 PM.
Thanks for the clarification, BSDfan666. I missed the potential for confusion due to not having a laptop. I added some colour in the first paragraph to emphasize your point, but didn't put an upper limit of 12 since not that many screens are configured by default.
|Thread||Thread Starter||Forum||Replies||Last Post|
|Puppet switching from GPL to Apache licence||J65nko||News||0||3rd May 2011 06:22 PM|
|Guardian switching from Java to Scala||J65nko||News||0||5th April 2011 09:39 PM|
|Problem switching from ide to scsi (virtualbox)||mlharvey||FreeBSD General||1||14th November 2010 02:55 PM|
|Netbook - NetBSD or OpenBSD?||marc||General Hardware||4||21st July 2009 03:44 PM|
|Qs for switching from Ubuntu to OpenBSD||JavaUser||OpenBSD General||5||17th October 2008 11:28 AM|