GNU/Linux >> Znalost Linux >  >> Ubuntu

Obrácení role stisknutí Shift+číslo?

existuje nějaký způsob, jak obrátit roli klávesové akce Shift+[1..9]? V podstatě jsem zjistil, že používám symboly na číslech mnohem častěji než čísla samotná. Mám numerickou klávesnici na čísla. A mnoho z těchto symbolů se používá v kódování a latexu. Takže pokud někdo ví, jak mohu získat [email protected]#$%^&*() bez použití shiftu, byl bych velmi vděčný.

Přijatá odpověď:

To je vlastně docela snadné dosáhnout pomocí xmodmap. Jednoduše vytvořte nový soubor s následujícím:

keycode  10 = exclam 1 exclam 1
keycode  11 = at 2 at 2
keycode  12 = numbersign 3 numbersign 3
keycode  13 = dollar 4 dollar 4
keycode  14 = percent 5 percent 5
keycode  15 = asciicircum 6 asciicircum 6
keycode  16 = ampersand 7 ampersand 7
keycode  17 = asterisk 8 asterisk 8
keycode  18 = parenleft 9 parenleft 9
keycode  19 = parenright 0 parenright 0

Uložte jej do kořenového adresáře svého domovského adresáře jako .Xmodmap (velká písmena jsou důležitá). Nyní se stačí odhlásit a znovu přihlásit (možná budete muset restartovat) a vaše klíče budou prohozeny. Pokračujte ve čtení, jak jsem na to přišel. Informace, které jsem použil, abych to zjistil, pochází odtud. Spusťte terminál a zadejte následující příkaz:

xmodmap -pke

To vyplivne spoustu párů nastavení/hodnota kódu klíče, jako je tento:

......
keycode  27 = r R r R
keycode  28 = t T t T
keycode  29 = y Y y Y
keycode  30 = u U u U
keycode  31 = i I i I
keycode  32 = o O o O
keycode  33 = p P p P
keycode  34 = bracketleft braceleft bracketleft braceleft
keycode  35 = bracketright braceright bracketright braceright
keycode  36 = Return NoSymbol Return
keycode  37 = Control_L NoSymbol Control_L
keycode  38 = a A a A
keycode  39 = s S s S
keycode  40 = d D d D
keycode  41 = f F f F
keycode  42 = g G g G
keycode  43 = h H h H
keycode  44 = j J j J
keycode  45 = k K k K
......

Klíčový kód je klíč na vaší fyzické klávesnici a hodnota napravo od rovnítka je to, co se odešle do vašeho počítače. Důvod, proč jsou čtyři, je, že první je obyčejný, druhý je se stisknutým Shiftem a třetí (plain) a dále (shift) se zdá být povolen, jakmile kliknete na tlačítko Scroll Lock. Jak můžete vidět, poskytuje vám to velkou flexibilitu při úpravě klávesnice, co vás napadne.

Nyní to bude fungovat pouze tehdy, když jste přihlášeni do X (jako v GUI), odtud název. Pokud spustíte terminál v Gnome, Unity atd., stále dobře používáte Xmodmap, ale pokud chcete stejnou funkcionalitu v konzoli (tj. nebo PC bez GUI), budete muset použít loadkeys. Ačkoli je obecná myšlenka stejná, loadkeys nabízí mnohem více funkcí a podrobností, takže je to trochu složitější. Nyní, všechny tyto příkazy MUSÍ být provedeny ze skutečné konzole, nelze je provést pomocí emulátoru terminálu, nebo se zobrazí chyba, jako je tato:Couldn't get a file descriptor referring to the console .

Nejprve budeme muset vytvořit naši výchozí mapu kláves, jako je tato:

dumpkeys > ~/my_keymap.map

Bylo by dobré udělat si kopii pro případ, že to opravdu pokazíte. Nyní jej musíme pouze upravit s našimi změnami. Každá definice klíče vypadá takto:

keycode   2 = one              exclam           one              one             
    alt keycode   2 = Meta_one        
    shift   alt keycode   2 = Meta_exclam     
    altgr   alt keycode   2 = Meta_one        
    shift   altgr   alt keycode   2 = Meta_one        
    shiftl  keycode   2 = one             
    shift   shiftl  keycode   2 = exclam          
    altgr   shiftl  keycode   2 = one             
    shift   altgr   shiftl  keycode   2 = one             
    alt shiftl  keycode   2 = Meta_one        
    shift   alt shiftl  keycode   2 = Meta_exclam     
    altgr   alt shiftl  keycode   2 = Meta_one        
    shift   altgr   alt shiftl  keycode   2 = Meta_one        
    shiftr  keycode   2 = one             
    shift   shiftr  keycode   2 = exclam          
    altgr   shiftr  keycode   2 = one             
    shift   altgr   shiftr  keycode   2 = one             
    alt shiftr  keycode   2 = Meta_one        
    shift   alt shiftr  keycode   2 = Meta_exclam     
    altgr   alt shiftr  keycode   2 = Meta_one        
    shift   altgr   alt shiftr  keycode   2 = Meta_one        
    shiftl  shiftr  keycode   2 = one             
    shift   shiftl  shiftr  keycode   2 = exclam          
    altgr   shiftl  shiftr  keycode   2 = one             
    shift   altgr   shiftl  shiftr  keycode   2 = one             
    alt shiftl  shiftr  keycode   2 = Meta_one        
    shift   alt shiftl  shiftr  keycode   2 = Meta_exclam     
    altgr   alt shiftl  shiftr  keycode   2 = Meta_one        
    shift   altgr   alt shiftl  shiftr  keycode   2 = Meta_one        
    ctrll   keycode   2 = one             
    shift   ctrll   keycode   2 = exclam          
    altgr   ctrll   keycode   2 = one             
    shift   altgr   ctrll   keycode   2 = one             
    alt ctrll   keycode   2 = Meta_one        
    shift   alt ctrll   keycode   2 = Meta_exclam     
    altgr   alt ctrll   keycode   2 = Meta_one        
    shift   altgr   alt ctrll   keycode   2 = Meta_one        
    shiftl  ctrll   keycode   2 = one             
    shift   shiftl  ctrll   keycode   2 = exclam          
    altgr   shiftl  ctrll   keycode   2 = one             
    shift   altgr   shiftl  ctrll   keycode   2 = one             
    alt shiftl  ctrll   keycode   2 = Meta_one        
    shift   alt shiftl  ctrll   keycode   2 = Meta_exclam     
    altgr   alt shiftl  ctrll   keycode   2 = Meta_one        
    shift   altgr   alt shiftl  ctrll   keycode   2 = Meta_one        
    shiftr  ctrll   keycode   2 = one             
    shift   shiftr  ctrll   keycode   2 = exclam          
    altgr   shiftr  ctrll   keycode   2 = one             
    shift   altgr   shiftr  ctrll   keycode   2 = one             
    alt shiftr  ctrll   keycode   2 = Meta_one        
    shift   alt shiftr  ctrll   keycode   2 = Meta_exclam     
    altgr   alt shiftr  ctrll   keycode   2 = Meta_one        
    shift   altgr   alt shiftr  ctrll   keycode   2 = Meta_one        
    shiftl  shiftr  ctrll   keycode   2 = one             
    shift   shiftl  shiftr  ctrll   keycode   2 = exclam          
    altgr   shiftl  shiftr  ctrll   keycode   2 = one             
    shift   altgr   shiftl  shiftr  ctrll   keycode   2 = one             
    alt shiftl  shiftr  ctrll   keycode   2 = Meta_one        
    shift   alt shiftl  shiftr  ctrll   keycode   2 = Meta_exclam     
    altgr   alt shiftl  shiftr  ctrll   keycode   2 = Meta_one        
    shift   altgr   alt shiftl  shiftr  ctrll   keycode   2 = Meta_one 

Jak můžete vidět, nabízí mnohem více funkcí/granularity. Pro každý klíč stačí zaměnit hodnoty shift a běžné hodnoty, tj. zde by byl jeden prohozený klíč:

keycode   2 = exclam              one           exclam              exclam             
    alt keycode   2 = Meta_exclam        
    shift   alt keycode   2 = Meta_one     
    altgr   alt keycode   2 = Meta_exclam        
    shift   altgr   alt keycode   2 = Meta_exclam        
    shiftl  keycode   2 = exclam             
    shift   shiftl  keycode   2 = one          
    altgr   shiftl  keycode   2 = exclam             
    shift   altgr   shiftl  keycode   2 = exclam             
    alt shiftl  keycode   2 = Meta_exclam        
    shift   alt shiftl  keycode   2 = Meta_one     
    altgr   alt shiftl  keycode   2 = Meta_exclam        
    shift   altgr   alt shiftl  keycode   2 = Meta_exclam        
    shiftr  keycode   2 = exclam             
    shift   shiftr  keycode   2 = one          
    altgr   shiftr  keycode   2 = exclam             
    shift   altgr   shiftr  keycode   2 = exclam             
    alt shiftr  keycode   2 = Meta_exclam        
    shift   alt shiftr  keycode   2 = Meta_one     
    altgr   alt shiftr  keycode   2 = Meta_exclam        
    shift   altgr   alt shiftr  keycode   2 = Meta_exclam        
    shiftl  shiftr  keycode   2 = exclam             
    shift   shiftl  shiftr  keycode   2 = one          
    altgr   shiftl  shiftr  keycode   2 = exclam             
    shift   altgr   shiftl  shiftr  keycode   2 = exclam             
    alt shiftl  shiftr  keycode   2 = Meta_exclam        
    shift   alt shiftl  shiftr  keycode   2 = Meta_one     
    altgr   alt shiftl  shiftr  keycode   2 = Meta_exclam        
    shift   altgr   alt shiftl  shiftr  keycode   2 = Meta_exclam        
    ctrll   keycode   2 = exclam             
    shift   ctrll   keycode   2 = one          
    altgr   ctrll   keycode   2 = exclam             
    shift   altgr   ctrll   keycode   2 = exclam             
    alt ctrll   keycode   2 = Meta_exclam        
    shift   alt ctrll   keycode   2 = Meta_one     
    altgr   alt ctrll   keycode   2 = Meta_exclam        
    shift   altgr   alt ctrll   keycode   2 = Meta_exclam        
    shiftl  ctrll   keycode   2 = exclam             
    shift   shiftl  ctrll   keycode   2 = one          
    altgr   shiftl  ctrll   keycode   2 = exclam             
    shift   altgr   shiftl  ctrll   keycode   2 = exclam             
    alt shiftl  ctrll   keycode   2 = Meta_exclam        
    shift   alt shiftl  ctrll   keycode   2 = Meta_exclam     
    altgr   alt shiftl  ctrll   keycode   2 = Meta_exclam        
    shift   altgr   alt shiftl  ctrll   keycode   2 = Meta_exclam        
    shiftr  ctrll   keycode   2 = exclam             
    shift   shiftr  ctrll   keycode   2 = one          
    altgr   shiftr  ctrll   keycode   2 = exclam             
    shift   altgr   shiftr  ctrll   keycode   2 = exclam             
    alt shiftr  ctrll   keycode   2 = Meta_exclam        
    shift   alt shiftr  ctrll   keycode   2 = Meta_one     
    altgr   alt shiftr  ctrll   keycode   2 = Meta_exclam        
    shift   altgr   alt shiftr  ctrll   keycode   2 = Meta_exclam        
    shiftl  shiftr  ctrll   keycode   2 = exclam             
    shift   shiftl  shiftr  ctrll   keycode   2 = one          
    altgr   shiftl  shiftr  ctrll   keycode   2 = exclam             
    shift   altgr   shiftl  shiftr  ctrll   keycode   2 = exclam             
    alt shiftl  shiftr  ctrll   keycode   2 = Meta_exclam        
    shift   alt shiftl  shiftr  ctrll   keycode   2 = Meta_one     
    altgr   alt shiftl  shiftr  ctrll   keycode   2 = Meta_exclam        
    shift   altgr   alt shiftl  shiftr  ctrll   keycode   2 = Meta_exclam

Důvodem extra granularity je to, že při používání konzole máte tendenci používat mnohem více klávesových zkratek, a to kvůli její povaze.

Související:Jak nainstalovat Tor v Ubuntu?

Nyní můžete k otestování změn použít následující příkaz:

loadkeys ~/my_keymap.map

Hrajte si, používejte některé programy, které obvykle používáte, a ujistěte se, že to funguje tak, jak chcete. Pokud jste něco udělali, stačí použít loadkeys příkaz vrátit zpět na výchozí. Chcete-li, aby byl trvalý, můžete tento příkaz přidat na konec ~/.bashrc soubor.

Související:„sudo apt-get install foo-“ způsobí odstranění balíčku foo a všeho, co na něm závisí?
Ubuntu
  1. Jak vytvořit roli IAM v AWS pomocí Terraform

  2. 8 kroků k vývoji role Ansible v Linuxu

  3. Obrácení obsahu proměnné slovy

  1. Role VPN v SASE

  2. Jak uvolnit zmrazení po náhodném stisknutí Ctrl-s v terminálu?

  3. Xmodmap Shift + Keycode pro vytvoření Keysym?

  1. Ubuntu – Zakázat Alt Focus?

  2. RHCE Ansible Series #9:Ansible Role

  3. Vytvářejte a rušte role v PostgreSQL