custom math keyboard layout and toggle quickly between it and regular layout

dajlano

New Member
Joined
Jan 7, 2021
Messages
15
Reaction score
5
Credits
161
hi everyone. I have a small laptop without a 10-key and i have a lot of studying I need to complete. in this studying, i'll need to do lots of numbers and math stuff mostly in spreadsheets but also will need to type out lots of verbal things as well.

i'm incredibly lazy and like to minimize how far i have to move my hands and fingers.

is there a way I can set up a custom math keyboard layout? i want to put 1234567890 on home row, (so 1234 would be ASDF, etc.).... and then i want to put the 4 main math operators ( + - * / ) where the QWER spots are...... etc. also, if I wanted to put the ^ sign, would that create further complications since that normally involves a modifier key (shift)?...... for that matter, I suppose on my small keyboard w/out the 10-key, the + sign also requires a modifier.......

but that's not all...... i also want to be able to toggle in between this custom layout and my normal layout with ease.

I'm not sure if this is possible. you guys have been so helpful in the past (thanks for that), i figure I'll give it a try asking.
 


Fanboi

Well-Known Member
Joined
Apr 16, 2021
Messages
358
Reaction score
270
Credits
4,288
I dunno your distro, I use Debian mainly, but you should always use the Arch Wiki as a reference point and adjust as needed. Anyway, Xmodmap may be what you need. I used it on my mouse, but it's for keyboard, too. Here you go:
 
OP
D

dajlano

New Member
Joined
Jan 7, 2021
Messages
15
Reaction score
5
Credits
161
good morning everyone,

fanboi, xmodmap worked to change all the keys to whatever i want!

now if there were only a way rapidly switch back and forth between regular keyboard layout and this one. I think i saw a video where a guy hit both of his ctrl keys at the same time and allowed him to instantly switch back and forth between US and Dutch keyboards....... but would my situation be different since one of mine that i'm switching to is a custom as opposed to a "built-in" option?

what i'm currently doing is opening a terminal and just putting in the 'xmodmap .Xmodmap command. ................. also, to make this faster, I've created an alias for this, so 3 quick characters will type this command out in the terminal. so right now to switch back and forth i have to : use my key binding to open terminal; and then use my alias to run the xmodmap.

but is there a way i can just toggle like the guy in the dutch keyboard example i reference above?
 

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
4,060
Reaction score
3,727
Credits
32,598
I'm not 100% sure, but I believe you're looking for Fcitx. That is the tool in Lubuntu (so presumably works anywhere) that lets you switch your keyboard layout with a keyboard shortcut. I've never tried it with a custom keyboard layout.
 

Fanboi

Well-Known Member
Joined
Apr 16, 2021
Messages
358
Reaction score
270
Credits
4,288
You could use multiple config files and call xmodmap <file>. If your window manager or DE has built-in keybindings (like XFCE), you can assign keys for switching by calling xmodmap with a different config file for each. If not, a program like sxhkd, which is desktop-agnostic, an do it.

A more elegant approach would be a shell script, something like:
Code:
#! /bin/bash

iiKeyConf=$1

config_x () {
# Put your literal Xmodmap commands here
}
config_y () {
# Put your literal Xmodmap commands here
}
config_z () {
# Put your literal Xmodmap commands here
}

case $iiKeyConf in
cfg_x)
 config_x
;;
cfg_y)
 config_y
;;
cfg_z)
 config_z
;;
esac

You could put the script in /usr/local/bin and chmod +x it so it's globally available. Then just bind calling it to certain keys, say:
F7: "myscript cfg_x"
F8: "myscript cfg_y"
F9: "myscript cfg_z"
If you wanted, you could add alerts when switching configs to your script with xmessage, or if you want it to look good, Zenity.

sxhkd

Zenity
 
$100 Digital Ocean Credit
Get a free VM to test out Linux!

Members online


Top