Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to lock the keyboard and mouse without locking the screen under Linux

2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

In this issue, the editor will bring you about how to lock the keyboard and mouse without locking the screen under Linux. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.

If you don't want your cat or dog to walk on your keyboard or let your child fool around on your keyboard while you are watching something important on the screen, I suggest you try xtrlock.

If you don't want your cat or dog to walk on your keyboard or let your child fool around on your keyboard while you are watching something important on the screen, I suggest you try xtrlock. It is simple but very practical, and you can lock the display of the screen until the user enters the password he or she has set on the keyboard. (LCTT: the user's own password, such as the one used to open the screensaver, does not need to be set separately). In this simple tutorial, I'll show you how to lock the keyboard and mouse without locking the screen under Linux. This technique works in almost all Linux operating systems.

Install xtrlock

Xtrlock packages are available in the default software repositories of most Linux operating systems. So you can install it using the package manager of the distribution you installed.

In Arch Linux and its derivative distributions, run the following command to install it:

$sudo pacman-S xtrlock

Replace it with your own content here.

Replace it with your own code here

Use on Fedora:

$sudo dnf install xtrlock

Use on RHEL, CentOS:

$sudo yum install xtrlock

Use on SUSE/openSUSE:

$sudo zypper install xtrlock

Use on Debian, Ubuntu, Linux Mint:

$sudo apt-get install xtrlock

Use xtrlock to lock the keyboard and mouse but not the screen

After installing xtrlock, you need to create a shortcut according to your choice and use this shortcut to lock the keyboard and mouse.

(LCTT translation note: in his own system (Arch + Deepin), the translator found that the part from here to the following shortcut key creation does not have to be done and is still in effect. )

Create a new file called lockkbmouse under the / usr/local/bin directory:

$sudo vi / usr/local/bin/lockkbmouse

Replace it with your own content here.

Replace it with your own code here

Then add the following command to the file:

#! / bin/bashsleep 1 & & xtrlock

Save and close the file.

Then use the following command to make it executable:

$sudo chmod axix / usr/local/bin/lockkbmouse

Next, we need to create shortcut keys.

Create a shortcut key

On the Arch Linux MATE desktop

Click "System-> Preferences-> Hardware-> keyboard Shortcuts"

Then click "Add" to create a shortcut key.

First type the name of your shortcut, then fill the following command into the command box, and finally click the "Apply" button.

Bash-c "sleep 1 & & xtrlock"

In order to be able to assign a shortcut to this shortcut, you need to select it or double-click it and enter your selected shortcut key combination, for example, I use Alt+k.

If you want to clear this shortcut key combination, hold down the BACKSPACE key. When finished, close the keyboard settings window.

On the Ubuntu GNOME desktop

Enter "System Settings-> Devices-> Keyboard", and then click the "+" symbol.

Type the name of your shortcut key and add the following command to the command box, then click the "Add" button.

Bash-c "sleep 1 & & xtrlock"

Next, assign a shortcut to the newly created shortcut. All we have to do is select or double-click the "Set shortcut" button.

Then you will see the next screen.

Enter the shortcut key combination you selected, for example, I use Alt+k.

If you want to clear this shortcut key combination, you can press BACKSPACE. In this way, the shortcut keys are set, and when you are done, close the keyboard settings window.

From now on, every time you type the shortcut you just set (ATL+K in our example), the mouse pointer will look like a padlock. Now that the keyboard and mouse are locked, you are free to watch your movies or do whatever you want. Even if your child or pet touches some keys on the keyboard or clicks the mouse, these actions will not work.

Because xtrlock is already working.

Did you see that little lock button? It means that the keyboard and mouse are locked. Even if you move the lock button, nothing will happen. The background task is executed until you release the screen, and then manually stop the running task.

Unlock the keyboard and mouse

To unlock the keyboard and mouse, just enter your password and hit enter. You will not see the password during the typing process. All you have to do is type and hit enter. After you enter the correct password, the mouse and keyboard can work again. If you enter a wrong password, you will hear a warning sound. Press ESC to clear the incorrect password entered, and then re-enter the correct password. To remove a character from an incomplete password, simply press the BACKSPACE or DELETE key.

What if I'm locked up forever?

In case you are permanently locked on the screen, switch to a TTY (such as CTRL+ALT+F2) and run:

$sudo killall xtrlock

Or you can use the chvt command to switch between TTY and X sessions.

For example, if you want to switch to TTY1, run:

$sudo chvt 1

To switch back to the X session, type:

$sudo chvt 7

Different distributions use different shortcut key combinations to switch between different TTY.

Man xtrlock above is how to lock the keyboard and mouse without locking the screen under Linux. If you happen to have similar doubts, please refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report