I Messed up my Keyboard while trying to remap a Key

Questions about applications and software
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
Turon
Level 1
Level 1
Posts: 6
Joined: Mon Jul 15, 2019 5:51 am

I Messed up my Keyboard while trying to remap a Key

Post by Turon »

My left directional key on my old HP laptop gave way, so I tried to remap it. I found a command in this topic that enabled me to remap my left key to my right shift key:

Code: Select all

sudo sed -i '29s|.*|key<RTSH>{[Left]};|' \
/usr/share/X11/xkb/symbols/pc \
&& sudo dpkg-reconfigure xkb-data
I, however, wanted to remap my left key to my right ctrl key, because it was closer to the original location of my left key, so I altered the command without really understanding what I was doing, this is approximately what I typed in:

Code: Select all

sudo sed -i '29s|.*|key<RTSH>{[Left]};{[Ctrl_R]}|' \
/usr/share/X11/xkb/symbols/pc \
&& sudo dpkg-reconfigure xkb-data
This command completely ruined my OS's keyboard inputs and now not even the on-screen keyboard works. Is this situation resolvable or will I have to reinstall my OS? I'd imagine I'd have to manipulate something externally since I literally can't use the keyboard now.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
gittiest personITW
Level 12
Level 12
Posts: 4285
Joined: Tue May 28, 2019 4:27 pm

Re: I Messed up my Keyboard while trying to remap a Key

Post by gittiest personITW »

If you made a Timeshift snapshot you can go back to before that.
You can boot into Live Mint and open Timeshift from there.
magnus7
Level 4
Level 4
Posts: 359
Joined: Sat Jan 30, 2016 8:46 pm

Re: I Messed up my Keyboard while trying to remap a Key

Post by magnus7 »

To undo remapping reinstall xkb-data package:

Open Menu > Character Map
Create text: xkb-data and your password by dragging characters to "Text to copy:" (use scripts "Latin" and "Common")

Open Menu > Synaptic Package Manager
Search: xkb-data
Right click on xkb-data and choose: "Mark for Reinstallation"
"Apply" and restart the computer
Turon
Level 1
Level 1
Posts: 6
Joined: Mon Jul 15, 2019 5:51 am

Re: I Messed up my Keyboard while trying to remap a Key

Post by Turon »

gittiest personITW wrote: Wed Oct 13, 2021 4:51 pm If you made a Timeshift snapshot you can go back to before that.
You can boot into Live Mint and open Timeshift from there.
I don't specifically remember doing a timeshift snapshot, so I probably didn't. But in hindsight I will so thanks for the suggestion
magnus7 wrote: Thu Oct 14, 2021 10:17 am To undo remapping reinstall xkb-data package:

Open Menu > Character Map
Create text: xkb-data and your password by dragging characters to "Text to copy:" (use scripts "Latin" and "Common")

Open Menu > Synaptic Package Manager
Search: xkb-data
Right click on xkb-data and choose: "Mark for Reinstallation"
"Apply" and restart the computer
My one account on linux mint has a password, I only have access to my Guest session. Is it normal to not be able to access the Synaptic Package Manager as a guest? Because I click on it, and nothing happens...
User avatar
AZgl1800
Level 20
Level 20
Posts: 11170
Joined: Thu Dec 31, 2015 3:20 am
Location: Oklahoma where the wind comes Sweeping down the Plains
Contact:

Re: I Messed up my Keyboard while trying to remap a Key

Post by AZgl1800 »

Timeshift is your Friend!!!

set it up for 5 Daily snapshots, I had to use mine today and after trying something that sounded really neat, but would not work on my OS.

it took all of 60 seconds for it to restore and then reboot my PC
Last edited by AZgl1800 on Mon Oct 18, 2021 8:37 pm, edited 2 times in total.
LM21.3 Cinnamon ASUS FX705GM | Donate to Mint https://www.patreon.com/linux_mint
Image
motoryzen
Level 10
Level 10
Posts: 3465
Joined: Sun Dec 08, 2019 12:25 am

Re: I Messed up my Keyboard while trying to remap a Key

Post by motoryzen »

it took all of 60 seconds for it to restore and then reboot my PC
Ah yes...SSD's indeed show their worth this way also xD \m/ I couldn't agree more.
Mint 21.2 Cinnamon 5.8.4
asrock x570 taichi ...bios p5.00
ryzen 5900x
128GB Kingston Fury @ 3600mhz
Corsair mp600 pro xt NVME ssd 4TB
three 4TB ssds
dual 1TB ssds
Two 16TB Toshiba hdd's
24GB amd 7900xtx vid card
Viewsonic Elite UHD 32" 144hz monitor
Aztaroth
Level 5
Level 5
Posts: 764
Joined: Mon Jan 11, 2021 1:48 am

Re: I Messed up my Keyboard while trying to remap a Key

Post by Aztaroth »

Turon wrote: Mon Oct 18, 2021 3:42 pm Is it normal to not be able to access the Synaptic Package Manager as a guest? Because I click on it, and nothing happens...
Yes, it is. Synaptic Manager needs to be run as an administrator (asks for password when launched). This is impossible in a guest session.

About your keyboard :
- check its current status with :

Code: Select all

setxkbmap -print -verbose 10
(verbose 10 will give all possible infos). Note the layout language.

- reset it accordingly (example for layout language us) :

Code: Select all

setxkbmap -layout us
I'm not sure it will work in a guest session or if it will survive a reboot, but as there's no privileges needed, who knows.
dual boot LMDE4 (mostly) + LM19.3 Cinnamon (sometimes)
Turon
Level 1
Level 1
Posts: 6
Joined: Mon Jul 15, 2019 5:51 am

Re: I Messed up my Keyboard while trying to remap a Key

Post by Turon »

I can't push 'enter' because of the keyboard problem, but I got around that by just pasting in the command on one line and then some nonsense on the next.

Anycase I pasted this command:

Code: Select all

setxkbmap -print -verbose 10
and I got my keyboard layout (it's za), then I pasted your other command but modified for my keyboard:

Code: Select all

setxkbmap -layout za
the terminal, however, outputted this:

Code: Select all

Error loading new keyboard description
Am I out of option on that front?
magnus7
Level 4
Level 4
Posts: 359
Joined: Sat Jan 30, 2016 8:46 pm

Re: I Messed up my Keyboard while trying to remap a Key

Post by magnus7 »

Restart the computer holding down Shift or ESC key to show GRUB Boot Menu.
At this stage your keyboard will work because is controlled by BIOS.
Choose "Advanced options for Linux Mint" > "(recovery mode)" > "root".
Press Enter and run this command:

Code: Select all

apt-get install --reinstall xkb-data
Press Enter, Ctrl+D and "resume".
Restart the computer.
Aztaroth
Level 5
Level 5
Posts: 764
Joined: Mon Jan 11, 2021 1:48 am

Re: I Messed up my Keyboard while trying to remap a Key

Post by Aztaroth »

Turon wrote: Tue Oct 19, 2021 7:42 am

Code: Select all

Error loading new keyboard description
What I feared. In a guest session you can't change anything.
magnus7's idea seems interesting and if his command doesn't work, you may try mine.
dual boot LMDE4 (mostly) + LM19.3 Cinnamon (sometimes)
Turon
Level 1
Level 1
Posts: 6
Joined: Mon Jul 15, 2019 5:51 am

Re: I Messed up my Keyboard while trying to remap a Key

Post by Turon »

magnus7 wrote: Tue Oct 19, 2021 8:03 am Restart the computer holding down Shift or ESC key to show GRUB Boot Menu.
At this stage your keyboard will work because is controlled by BIOS.
Choose "Advanced options for Linux Mint" > "(recovery mode)" > "root".
Press Enter and run this command:

Code: Select all

apt-get install --reinstall xkb-data
Press Enter, Ctrl+D and "resume".
Restart the computer.
Thanks magnus7, I tried that and was able to successfully booted up recovery mode and reinstalled the xkb-data!

This is probably offtopic somewhat but.. How do I actually remap my left directional key to my right Ctrl?
magnus7
Level 4
Level 4
Posts: 359
Joined: Sat Jan 30, 2016 8:46 pm

Re: I Messed up my Keyboard while trying to remap a Key

Post by magnus7 »

Run this command in terminal and restart the computer:

Code: Select all

sudo sed -i '30s|.*|key<RCTL>{[Left]};|' \
/usr/share/X11/xkb/symbols/pc \
&& sudo dpkg-reconfigure xkb-data
Turon
Level 1
Level 1
Posts: 6
Joined: Mon Jul 15, 2019 5:51 am

Re: I Messed up my Keyboard while trying to remap a Key

Post by Turon »

magnus7 wrote: Tue Oct 19, 2021 6:34 pm Run this command in terminal and restart the computer:

Code: Select all

sudo sed -i '30s|.*|key<RCTL>{[Left]};|' \
/usr/share/X11/xkb/symbols/pc \
&& sudo dpkg-reconfigure xkb-data
Thanks it worked! My problem has been resolved for now. Just out of curiosity, which part of your command refers to right ctrl? Is it this part?:

Code: Select all

key<RCTL>
magnus7
Level 4
Level 4
Posts: 359
Joined: Sat Jan 30, 2016 8:46 pm

Re: I Messed up my Keyboard while trying to remap a Key

Post by magnus7 »

Yes.
Locked

Return to “Software & Applications”