Go Back   DaemonForums > Miscellaneous > Guides

Guides All Guides and HOWTO's.

Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   (View Single Post)  
Old 1st September 2011
IdOp's Avatar
IdOp IdOp is offline
Too dumb for a smartphone
Join Date: May 2008
Location: twisting on the daemon's fork(2)
Posts: 534
Thanked 14 Times in 13 Posts
Default Switching wsconsole screens with Alt-Fn in NetBSD and OpenBSD

1a. Introduction.

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

# wsconsctl -k map | less

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:

# wsconsctl map | grep Cmd1
keycode 29 = Cmd1 Control_L

# wsconsctl map | grep Cmd2
keycode 56 = Cmd2 Alt_L

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:

# wsconsctl -w map+="keycode 29 = Control_L"

# wsconsctl -w map+="keycode 56 = Cmd Alt_L"

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

# wsconsctl keyboard.map | less

etc., and

# wsconsctl keyboard.map+="keycode 29 = Control_L"

# wsconsctl keyboard.map+="keycode 56 = Cmd Alt_L"

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,

mapfile /etc/wscons-keymap.local
Second, create /etc/wscons-keymap.local if it doesn't exist and add the following entries into it

# 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
Note, I've added a tweak so that Alt-Esc doesn't trigger the debugger by accident, as this could happen more easily than with Ctrl-Alt-Esc. If you don't want this change omit the "keycode 1 = Escape" stuff.

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"
4. References.



wscons.conf(5) [NetBSD]

wsconsctl.conf(5) [OpenBSD]


OpenBSD FAQ Section 7.1 is minimalist.

5. Disclaimers.

* 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.
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
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

All times are GMT. The time now is 04:17 PM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick