So, I want to toggle a few of my key to remap them to numeric. While this is trivial to accomplish using xmodmap, the one I am confused about is on assigning variable to a bash script so that they don't persist in the script. The algorithm would be: 1. Assign a variable with binary value, with default equal to 1. 2. If the variable value is equal to 1, remap to numeric keys, toggle the variable to 0. Else if the variable is equal to 0, remap to default key, toggle variable value to 1. The question is on how to do it so the toggle persists. While it is possible to fetch value to be assigned from a file, and rewriting the file later, is there no way to edit the script?
If there's anyway to determine the value from the output of a command that would probably be the most self contained solution. From reading the Arch wiki, it looks like the output of xmodmap -pke might do what you want. EDIT: wrong option
hmmm... Xmodmap part is solved actually. I've bound two script (one to modify and one to return tl default) to two different keybinding. Now I want to make it into one script where the toggle function works. what kind of data do you want? The script? Sure.
Two options I can think about: 1) Instead of using a variable, you should be able to check if the current mapping is the original mapping or the changed mapping. The script would check which state the mappings are in and toggle to the other mapping instead, of course this assumes that the mapping persists. 2) If you want the variable itself to be changed in the script after each toggle, then you should look up self-modifying bash scripts on stack overflow, as there are threads on this topic. Hopefully this helps answer your question.
What I mean is taking the output of xmodmap -pke, which prints out your current bindings, and using that as to determine your 0 or 1. So something like "xmodmap -pke | grep keycode"
thank you!!! I just need to map mode_switch keysym and map the others to those of 3rd and 4th column. No more RSI pain, I hope...