How to re-enable the caps lock key?
Solution 1
The following commands should work:
xmodmap -e 'keycode 0x42 = Caps_Lock'
or
setxkbmap -option
The commands above work just fine to restore the default behaviour, which I hardly ever need, luckily.
I normally remap the capslock to Control (luckily VI/VIM supports CTRL-C instead of ESC) with the following command:
setxkbmap -option ctrl:nocaps -layout gb
Solution 2
Try setxkbmap -option -layout us -variant dvorak-l -option ctrl:swapcaps
From the manpage:
[...] If you want to
replace all previously specified options, use the -option flag
with an empty argument first.
Irony is that here -option ctrl:swapcaps
actually overrides -option ctrl:nocaps
— I guess the behavior changed.
Edit: As the OP stated, he wants to avoid clearing the options (as done in the way above).
/usr/share/X11/xkb/rules/xorg.lst
shows the option ctrl:aa_ctrl
(control at bottom left), which seems to reset caps lock after nocaps
here.
I guess it's worth a try, and you can also look at the list (grep ctrl\:
) and see if there's something else which may work, in case this one doesn't.
If there's no option for this, I guess the solution is to hack the current keymap, by associating Caps Lock with the Caps Lock key again (but I don't have experience with that, other than believing there's a tool that allows you to do that with a one-liner).
Related videos on Youtube
utnapistim
Updated on September 18, 2022Comments
-
utnapistim over 1 year
I have the following situation:
I create a boost::thread_group instance, then create threads for parallel-processing on some data, then join_all on the threads.
Initially I created the threads for every X elements of data, like so:
// begin = someVector.begin(); // end = someVector.end(); // batchDispatcher = boost::function<void(It, It)>(...); boost::thread_group processors; // create dispatching thread every ASYNCH_PROCESSING_THRESHOLD notifications while(end - begin > ASYNCH_PROCESSING_THRESHOLD) { NotifItr split = begin + ASYNCH_PROCESSING_THRESHOLD; processors.create_thread(boost::bind(batchDispatcher, begin, split)); begin = split; } // create dispatching thread for the remainder if(begin < end) { processors.create_thread(boost::bind(batchDispatcher, begin, end)); } // wait for parallel processing to finish processors.join_all();
but I have a problem with this: When I have lots of data, this code is generating lots of threads (> 40 threads) which keeps the processor busy with thread-switching contexts.
My question is this: Is it possible to call create_thread on the thread_group after the call to join_all.
That is, can I change my code to this?
boost::thread_group processors; size_t processorThreads = 0; // NEW CODE // create dispatching thread every ASYNCH_PROCESSING_THRESHOLD notifications while(end - begin > ASYNCH_PROCESSING_THRESHOLD) { NotifItr split = begin + ASYNCH_PROCESSING_THRESHOLD; processors.create_thread(boost::bind(batchDispatcher, begin, split)); begin = split; if(++processorThreads >= MAX_ASYNCH_PROCESSORS) // NEW CODE { // NEW CODE processors.join_all(); // NEW CODE processorThreads = 0; // NEW CODE } // NEW CODE } // ...
Whoever has experience with this, thanks for any insight.
-
hhaamu over 12 yearsI'm guessing everyone who tried to help me got their keyboards stuck to dvorak =(
-
jw013 over 12 yearsX is so old and complex now that not many people really understand the various internal mechanisms. There's even sections in the man page that says (and I quote): "Nobody wants to say how this works. Maybe nobody knows ...". I am interested in seeing an answer to this question as well but it may be the case that nobody knows ...
-
-
utnapistim about 14 yearsThe code was working as it was (as in my proposed solution) but I wasn't sure it was stable. I have implemented a version that explicitly removes dead threads after join_all. It is not the most efficient of implementations, but it'll do for now (as advised here: groups.google.com/group/boost-list/browse_thread/thread/…) I will also look into implementing a producer-consumer solution (thanks).
-
hhaamu over 12 yearsThat indeed does clear the options list, but I wish to keep the non-caps-related options (as I stated in the question) such as compose keys.
-
kmacdonald over 12 yearsOh, sorry, I misread the question. I can't be sure if this will work (as I stated,
swapcaps
actually re-enables caps lock here), but from/usr/share/X11/xkb/rules/xorg.lst
, I see there is the optionctrl:aa_ctrl
(control at bottom left), which seems to reset caps lock afternocaps
here. -
hhaamu about 12 yearsI think the magic program is
xmodmap
but I'm not quite sure how to use it