A method for adaptively shielding shortcut keys in Linux operating system
By defining the DBus protocol specifications and dynamically managing the blocked shortcut key service, the problem of insufficient flexibility caused by static strategies in shortcut key management of existing operating systems is solved, and dynamic management of shortcut keys and user operation convenience is achieved.
Patent Information
- Application Number
- CN202510169652.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-17
- Publication Date
- 2025-05-06
- Estimated Expiration
- 2045-02-17
AI Technical Summary
The existing operating systems adopt static fixed strategies in shortcut key management, which is difficult to adapt to dynamic changes, resulting in increased development costs and reduced system flexibility.
By defining the DBus protocol specification, dynamic management of registration and cancellation of blocked shortcut key services is realized, the blacklist shortcut key list is updated, and whether the shortcut key event is responding normally based on the current blacklist list.
It realizes the enable and disable state of dynamic management shortcut keys, without complex adaptation work, accurately solves the needs of partially blocked shortcut keys, ensuring user operation convenience and system response timeliness.
Smart Images

Figure SMS_1
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of computers, and in particular provides a method for adaptively shielding shortcut keys under a Linux operating system. Background Art
[0002] In today's highly integrated and personalized desktop environment, the widespread use of shortcut keys has greatly improved the user's operating efficiency and experience. With the booming and increasing maturity of the domestic operating system market, many companies have turned their attention to these self-controllable system platforms and used them as the cornerstone of daily office and production environments. The desktop environment UKUI of the Kylin operating system not only inherits the power and flexibility of the Linux desktop operating system, but also incorporates more localized and user-friendly design elements, providing users with a rich operating experience.
[0003] As applications become increasingly rich and complex, the problem of shortcut key scenarios in different windows has gradually become prominent. In the in-depth development of UKUI components, there is a key requirement, that is, when a specific application window is activated, some global shortcut keys can be intelligently disabled to avoid shortcut key conflicts or misoperations, and when these windows are closed, the functions of these shortcut keys can be automatically restored to ensure seamless and efficient user operations. This requirement highlights the urgency and importance of dynamically managing shortcut keys.
[0004] At present, many operating systems, both domestic and foreign, generally adopt a static fixed strategy for shortcut key management, that is, multiple sets of shortcut key disabled combinations are preset in the system for different windows to call when needed, but this method is difficult to adapt to dynamic changes. Whenever there is a new shortcut key management requirement, it is often necessary to re-develop tedious work on both the operating system and the application software. In addition, there is a simple and crude method, that is, to block all shortcut keys through global settings, but this obviously cannot meet the delicate needs of managing only some shortcut keys, and also sacrifices the flexibility and efficiency of user operations. Summary of the invention
[0005] In order to overcome the above-mentioned defects, the present invention is proposed to solve the technical problem that the existing shortcut key shielding method not only increases the development cost but also reduces the system flexibility.
[0006] The present invention provides a method for adaptively shielding shortcut keys under a Linux operating system, comprising the following steps:
[0007] Define the DBus protocol specification for registering and shielding shortcut key service;
[0008] After the system logs in, the shortcut key process starts, monitors the registration and deregistration of all shielded shortcut key services through the DBus API, updates the blacklist shortcut key list, monitors shortcut key events from the system, and determines whether the current shortcut key event responds normally based on the current blacklist shortcut key list;
[0009] In response to the target application starting, registering the shielding shortcut key service according to the DBus protocol specification, then setting the shortcut key to be shielded, and in response to the target application exiting, unregistering the corresponding shielding shortcut key service, the target application is the application that needs to shield the shortcut key.
[0010] Furthermore, the DBus protocol specification includes a service name, a service path, an interface name and a Methods method. The service name and the service path serve as a basis for the target application to register a shortcut key shielding service. The interface name is used by the DBus API to monitor the shortcut key shielding service according to a preset core interface identifier. The Methods method is used by the DBus API to obtain the shortcut keys that need to be shielded for each shortcut key shielding service through a preset interface.
[0011] Furthermore, the DBus protocol specification also includes a Properties method, and the Properties method is used by the DBus API to obtain the shortcut keys that need to be blocked for each shortcut key blocking service through preset properties.
[0012] Further, the registration and deregistration of all shielded shortcut key services are monitored through the DBus API, and the blacklist shortcut key list is updated, including:
[0013] The shortcut key process monitors all services prefixed with the preset core interface identifier through the DBus API, that is, the registered shielded shortcut key services;
[0014] By traversing all registered shielded shortcut key services, for each shielded shortcut key service, read its preset interface through the predefined Methods method, obtain the shortcut key to be shielded, and obtain the shortcut key blacklist list;
[0015] When it is detected that a service for blocking shortcut keys is deregistered, all shortcut keys that need to be blocked and are associated with the service are removed from the shortcut key blacklist.
[0016] Further, the monitoring of the shortcut key events from the system and judging whether the current shortcut key events are responded normally according to the current blacklist shortcut key list include:
[0017] The shortcut key process matches the received shortcut key event with the acquired shortcut key blacklist. If the shortcut key event belongs to the enumeration ID in the shortcut key blacklist, the shortcut key event will not be responded to; if the shortcut key event does not belong to the enumeration ID in the shortcut key blacklist, the shortcut key event will be processed according to the normal process.
[0018] Further, in response to the target application starting, registering the shielding shortcut key service according to the DBus protocol specification, and then setting the shortcut key to be shielded, including:
[0019] After the target application is started, a shielded shortcut key service with the preset service name is registered through the DBus API;
[0020] After the shortcut key blocking service is successfully registered, the shortcut keys to be blocked can be set through the blockShortcuts interface.
[0021] Working principle and beneficial effects of the present invention:
[0022] In the technical solution of the present invention, by defining a set of efficient and easy-to-integrate DBus protocol mechanisms, any window or application that needs to disable or modify shortcut key behavior only needs to simply follow the protocol and register the shielded shortcut key service to the DBus (desktop bus) API. When the system is started, the shortcut key process of the DBus API is started, monitoring the registration and deregistration of all shielded shortcut key services, updating the blacklist shortcut key list, and monitoring shortcut key events from the system at the same time, and judging whether the current shortcut key event responds normally according to the current blacklist shortcut key list. Instant shortcut key blacklist management can be achieved without complicated adaptation work in advance.
[0023] The present invention can dynamically and flexibly manage the enabling and disabling status of shortcut keys according to actual application scenarios, without the need for complex two-end development every time a new requirement is added. It accurately solves the need to partially shield shortcut keys, ensuring the convenience of user operation and the timeliness of system response. DETAILED DESCRIPTION
[0024] Some embodiments of the present invention are described below. It should be understood by those skilled in the art that these embodiments are only used to explain the technical principles of the present invention and are not intended to limit the protection scope of the present invention.
[0025] In the embodiment of the present invention, the DBus protocol scheme is adopted as the specific implementation path of the present invention. DBus is a widely used message bus system in the Linux desktop environment. Its advantage is that it can automatically manage the registration and deregistration of services, and when the application exits or closes abnormally, the DBus service associated with it will also disappear accordingly, thereby effectively reducing the coupling between components and improving the system's adaptability and robustness.
[0026] In this embodiment, a method for adaptively shielding shortcut keys under a Linux operating system mainly includes four steps: defining interface specifications, shortcut key process monitoring shielding shortcut key service, shortcut key process monitoring shortcut key events, and registering shielding shortcut key service after application startup, as shown in the following.
[0027] 1. Define the DBus protocol specification for registering and shielding shortcut key service.
[0028] ① Service name: The format of org.ukui.settingsDaemon.shortcut.#application name is uniformly adopted, where #application name is a placeholder for the application name and is used to uniquely identify the specific application or window that registers the service.
[0029] ②Service path: fixed to / org / ukui / settingsDaemon / shortcut to simplify the service access path and improve the readability and maintainability of the system.
[0030] ③Interface definition:
[0031] Interface Name: org.ukui.settingsDaemon.shortcut is used as the core interface identifier of the shortcut key shielding function.
[0032] Methods: This method returns by calling the blockShortcuts() interface to obtain the shortcut keys that need to be blocked by the application. Its return type is array[string], that is, a string array containing the enumeration IDs of all shortcut keys to be blocked.
[0033] In one implementation, Properties is also defined. This method obtains the value of the blockShortcuts property (the property name can be the same as the method name, for example) by obtaining properties, and also returns the list of shortcut keys that the application needs to block, which is of type array[string]. This property acquisition method is a supplement to the Methods method, which facilitates obtaining the list of shortcut keys that need to be blocked through property access in certain scenarios.
[0034] In this embodiment, a set of concise and clear protocol standards is first defined to guide how applications or windows that need to disable or modify shortcut key behavior are registered on the DBus interface. This is the basis of the entire solution, ensuring that different components can communicate and collaborate according to unified rules. By dynamically registering the DBus interface, the immediate effectiveness and revocation of the shortcut key list that needs to be blocked is achieved without restarting the system or restarting the application, which greatly improves the response speed and flexibility of the system.
[0035] In one implementation, some shortcut keys are shown in Table 1.
[0036] Table 1:
[0037]
[0038] 2. The user selects an account and logs into the system. After logging into the system, the shortcut key process starts.
[0039] 2.1 The shortcut key process monitors the registration and deregistration of all shielded shortcut key services through the DBus API and updates the blacklist shortcut key list.
[0040] The shortcut key process listens to org.ukui.settingsDaemon.shortcut. #Application name through DBus API, that is, all services prefixed with the preset Interface Name. This step is to obtain the registered (including newly registered and existing) shielded shortcut key services and shielded shortcut key services that need to be deregistered in time.
[0041] In one implementation, all registered shortcut key blocking services org.ukui.settingsDaemon.shortcut.#application name are traversed, but their shortcut key blocking requests are not processed immediately. Instead, after the corresponding blocked shortcut key event is triggered, the corresponding shortcut key event is processed by detecting the blacklist shortcut key list. This step is to avoid that some applications that need to block shortcut keys are incorrectly processed before they are fully initialized at the beginning of system startup. For each registered, confirmed, and valid shortcut key blocking service, its blockShortcuts interface is read through the predefined Methods method to obtain the shortcut keys that need to be blocked and obtain the shortcut key blacklist list.
[0042] In one implementation, once it is detected that the shortcut key blocking service org.ukui.settingsDaemon.shortcut.#application name has been deregistered, all shortcut keys that need to be blocked and are associated with the service are immediately removed from the internally managed shortcut key blacklist, ensuring that the system's shortcut key response logic is always kept up to date.
[0043] In this embodiment, dynamic blacklist management: through the DBus API, the application or window can dynamically register the shielding shortcut key service, so that the shortcut keys that need to be shielded in all services are incorporated into the shortcut key blacklist list. The shortcut key blacklist list contains the enumeration IDs of the shortcut keys that need to be shielded. After the system receives the service registration request, it will immediately store the shortcut key information that needs to be shielded, and prepare to apply these rules in subsequent shortcut key events.
[0044] The end that handles shortcut key events does not need to care about the specific details of the source of the shortcut key blacklist. It only needs to identify and follow the unified interface protocol to extract and apply the shortcut key blacklist. This design reduces the coupling between different components and improves the scalability and maintainability of the system.
[0045] 2.2 The shortcut key process monitors the shortcut key events from the system and determines whether the current shortcut key event responds normally based on the current blacklist shortcut key list.
[0046] The shortcut key process continuously monitors and receives shortcut key events from the system. The received shortcut key is matched with the acquired shortcut key blacklist to determine whether the event belongs to the enumeration ID in the shortcut key blacklist, so as to determine whether the shortcut key needs to be blocked. If the shortcut key event belongs to the enumeration ID in the shortcut key blacklist, the shortcut key event will not be responded to; if it does not belong to the enumeration ID in the shortcut key blacklist, the shortcut key event will be processed according to the normal process. This mechanism effectively avoids unexpected responses caused by conflicts between global shortcut keys and window shortcut keys.
[0047] 3. In response to the target application starting, register the shielding shortcut key service according to the DBus protocol specification, then set the shortcut key to be shielded, and in response to the target application exiting, unregister the corresponding shielding shortcut key service. The target application is the application that needs to shield the shortcut key.
[0048] In one implementation, when the application that needs to block shortcut keys is started, a blocking shortcut key service named "org.ukui.settingsDaemon.shortcut.#appname" is registered through the DBus API (# is a concatenation symbol that concatenates the content before and after into one line), where "#appname" is a placeholder for the actual application name, which is used to uniquely identify the application. After the blocking shortcut key service is successfully registered, the shortcut keys that need to be blocked are set through the blockShortcuts interface.
[0049] In one implementation, when the application that needs to shield the shortcut key completes its task or is actively closed by the user, the application exits. Before or after the application exits (depending on the management method of the DBus service), the corresponding shielded shortcut key service is unregistered. This step ensures that even if the application exits abnormally, invalid service registration information is no longer retained on the DBus API. With the disappearance of the registered DBus interface, the system can automatically clear the shortcut key blacklist associated with it, effectively avoiding the accumulation of invalid data, optimizing the utilization of system resources, and avoiding the accumulation of invalid data.
[0050] It should be pointed out that although the various steps in the above embodiments are described in a specific order, those skilled in the art can understand that in order to achieve the effects of the present invention, different steps do not have to be performed in such an order, and they can be performed simultaneously (in parallel) or in other orders. These changes are within the scope of protection of the present invention.
[0051] Based on the above steps, this embodiment defines a set of efficient and easy-to-integrate DBus protocol mechanisms, so that any window or application that needs to disable or modify shortcut key behavior only needs to simply follow the protocol and register the shielded shortcut key service to the DBus (desktop bus) API. When the system starts, the shortcut key process of the DBus API starts, monitors the registration and deregistration of all shielded shortcut key services, updates the blacklist shortcut key list, monitors shortcut key events from the system, and determines whether the current shortcut key event responds normally based on the current blacklist shortcut key list. Instant shortcut key blacklist management can be achieved without complex adaptation work in advance.
[0052] The present invention has the following technical effects:
[0053] 1. Improve system security and user privacy protection
[0054] The present invention effectively prevents unauthorized processes from maliciously occupying or tampering with shortcut keys by implementing strict DBus service name prefix management and blacklist dynamic update mechanism, thereby significantly improving the security of the system and the privacy protection level of users. This improvement makes the system more stable and reliable in the face of potential security threats.
[0055] 2. Enhance user experience
[0056] Users can flexibly define shortcut keys to be blocked according to personal or application needs, and they will take effect immediately through the DBus service. This instant feedback and highly customized user experience make it more convenient and efficient for users to use the system. At the same time, it reduces misoperations caused by shortcut key conflicts, further improving user satisfaction.
[0057] 3. Improve system flexibility and maintainability
[0058] The shortcut key management system of the present invention adopts modular design and plug-in expansion mechanism, so that the system can easily adapt to different hardware and software environments. In addition, through the dynamic registration and deregistration of DBus service, system administrators or developers can easily add, delete or modify shortcut key configuration, which greatly improves the flexibility and maintainability of the system.
[0059] 4. Optimize system resource utilization
[0060] Traditional shortcut key management solutions often use static configuration or global scanning, which not only increases system resource consumption, but also may cause unnecessary performance bottlenecks. However, the present invention dynamically monitors DBus service changes and only performs shortcut key matching and response when necessary, thereby significantly reducing system resource occupancy and optimizing system resource utilization.
[0061] 5. Promote the healthy development of the software ecosystem
[0062] The implementation of the present invention provides software developers with a set of standard, easy-to-integrate shortcut key management interfaces, allowing them to focus more on the development of application functions without having to worry about shortcut key conflicts or management issues. This helps promote the healthy development of the software ecosystem and promote the emergence of more high-quality, highly compatible applications.
[0063] Here are some terms involved in the present invention.
[0064] UKUI: Kylin operating system desktop environment.
[0065] DBus: (Desktop Bus) is an inter-process communication (IPC) mechanism widely used in Linux and Unix systems, and is also regarded as a message bus system. It provides a low-latency, low-overhead, high-availability platform that allows different applications and processes to communicate and collaborate.
[0066] Those skilled in the art will appreciate that the modules in the device can be adaptively split or merged. Such splitting or merging of specific modules will not cause the technical solution to deviate from the principle of the present invention, and therefore, the technical solutions after splitting or merging will fall within the protection scope of the present invention.
[0067] So far, the technical solutions of the present invention have been described in conjunction with the preferred embodiments, but it is easy for those skilled in the art to understand that the protection scope of the present invention is obviously not limited to these specific embodiments. Without departing from the principle of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after these changes or substitutions will fall within the protection scope of the present invention.
Claims
1. A method for adaptively shielding shortcut keys in a Linux operating system, characterized in that: The following steps are involved: Define the DBus protocol specification for registering and shielding shortcut key service; After the system logs in, the shortcut key process starts, monitors the registration and deregistration of all shielded shortcut key services through the DBus API, updates the blacklist shortcut key list, monitors shortcut key events from the system, and determines whether the current shortcut key event responds normally based on the current blacklist shortcut key list; In response to the target application starting, registering the shielding shortcut key service according to the DBus protocol specification, then setting the shortcut key to be shielded, and in response to the target application exiting, unregistering the corresponding shielding shortcut key service, the target application is the application that needs to shield the shortcut key.
2. The method for adaptively shielding shortcut keys in a Linux operating system according to claim 1, characterized in that: The DBus protocol specification includes a service name, a service path, an interface name and a Methods method. The service name and the service path are used as the basis for the target application to register the shielding shortcut key service. The interface name is used for the DBus API to monitor the shielding shortcut key service according to the preset core interface identifier. The Methods method is used for the DBus API to obtain the shortcut keys that need to be shielded for each shielding shortcut key service through the preset interface.
3. The method for adaptively shielding shortcut keys in a Linux operating system according to claim 2, characterized in that: The DBus protocol specification also includes a Properties method, and the Properties method is used by the DBus API to obtain the shortcut keys that need to be blocked for each shortcut key blocking service through preset properties.
4. The method for adaptively shielding shortcut keys in a Linux operating system according to claim 2, characterized in that: The DBus API is used to monitor the registration and deregistration of all shielded shortcut key services, and update the blacklist shortcut key list. include, The shortcut key process monitors all services prefixed with the preset core interface identifier through the DBus API, that is, the registered shielded shortcut key services; By traversing all registered shielded shortcut key services, for each shielded shortcut key service, read its preset interface through the predefined Methods method, obtain the shortcut key to be shielded, and obtain the shortcut key blacklist list; When it is detected that a service for blocking shortcut keys is deregistered, all shortcut keys that need to be blocked and are associated with the service are removed from the shortcut key blacklist.
5. The method for adaptively shielding shortcut keys in a Linux operating system according to claim 4, characterized in that: The monitoring of shortcut key events from the system and judging whether the current shortcut key event responds normally according to the current blacklist shortcut key list include: The shortcut key process matches the received shortcut key event with the acquired shortcut key blacklist. If the shortcut key event belongs to the enumeration ID in the shortcut key blacklist, the shortcut key event will not be responded to; if the shortcut key event does not belong to the enumeration ID in the shortcut key blacklist, the shortcut key event will be processed according to the normal process.
6. The method for adaptively shielding shortcut keys in a Linux operating system according to claim 2, characterized in that: In response to the target application starting, registering the shielding shortcut key service according to the DBus protocol specification, and then setting the shortcut key to be shielded, including: After the target application is started, a shielded shortcut key service with the preset service name is registered through the DBus API; After the shortcut key blocking service is successfully registered, the shortcut keys to be blocked can be set through the blockShortcuts interface.
Citation Information
Patent Citations
Method and system for shielding virtual key of mobile terminal
CN105912333A
Shortcut key implementation method, computing device and storage medium
CN114527883A