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-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article will explain in detail how to lock the keyboard and mouse without locking the screen under Linux. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

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

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 uses 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

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 * 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?

In case you are 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. Please refer to the official website of the corresponding distribution you installed for more details.

For more information about xtrlock, please refer to the man page:

$man xtrlock

So that's all. I hope this guide can help you. If you find this guide useful, please take the time to share it to your moments and support us (OSTechNix).

On "how to lock the keyboard and mouse under the Linux without locking the screen" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, please share it out for more people to see.

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