Create a shortcut icon in ubuntu to solve the problem of 2 icons

foreword

Because the software on ubuntu has WeChat available, I am going to try ubuntu, and deepin is also based on Debian, so the software can be used universally in theory. Using ubuntu, I found that there is no problem as the main machine for development. When writing code, basically the main driver is available, and some notebooks may have driver problems. WeChat can be downloaded from ukylin, but some software does not have application icons and shortcuts, which requires a little hands-on ability.

Create Shortcut

The way to create a shortcut is very simple, that is, create a text file with the name .desktop as the file name, and use vim or other text editors. Take idea as an example. After all, the official download is a tar file. Unzip a directory

In fact, you can use ./ or sh to start at this time, but it is too troublesome, it is better to be simple (in fact, idea will automatically create a shortcut before, but the latest version does not have it by default), and appimage needs to install fuse to run, sudo apt install fuse

[Desktop Entry]
Name=ideaIC  
Comment=ideaIc
Exec=/home/huahua/Applications/ideaIC/bin/idea.sh %U
Icon=/home/huahua/Applications/ideaIC/bin/idea.svg
Terminal=false
Type=Application
Categories=Development;Tools;paper;Application;
StartupNotify=true
NoDisplay=false
StartupWMClass=jetbrains-idea-ce

Name and Comment are well-known by name. If you want to support multiple languages, you need to write according to the language region partition. Generally, they are not used, and they are only used for software development.

Exec is the command to execute the program, generally add %U, meaning: What does “%U” mean when calling a command?

The reason these parameter keys exist is so the desktop manager knows what to do if you open multiple selected objects at the same time or drop one or more objects on it. %U means the program can take all of them in a single invocation; %u means a separate invocation is needed for each object; if none of them are specified then the program doesn't know what to do with things dropped on it. There are other keys which allow the desktop manager to pass customization information to the program, and a separate set of selectors %f, %F, meaning it takes one/multiple files but not URLs.

translate

%U means that the program can accept all objects in one call; %u means that each object needs to be called separately; if they are not specified, then the program does not know what to do with what is dropped on it.

Icon is an icon, generally provided by software, svg is preferred, and png and other formats can also be used

Terminal is for terminal use, and the general graphical interface is not

Type is generally the application

Categories are software purposes, such as idea can be development, tool application, etc.

StartupNotify is a startup notification, configured according to requirements

NoDisplay is very important. If you configure true, the application cannot see the icon, but you can use the shortcut to double-click to open it

StartupWMClass This is to solve the double icon problem

Just create this file and copy it to the desktop to become a shortcut

 At this point, you need to right-click - allow to run, the icon will change, you can double-click to open

 After running, the icon becomes executable

in program menu

To put it in the program menu, you need to put the shortcut cp to ~/.local/share/applications or /usr/share/applications. The location of the user directory is only valid for the current user, and the system directory is globally valid.

The NoDisplay configuration must be set to false .

Solve the problem of multiple icons after startup

At this time, if you use the icon to start, you can use it without any problem. You can also fix the taskbar, but there will be a problem of double icons of the startup icon and the running icon. The solution is to configure StartupWMClass

Type in terminal

xprop | grep WM_CLASS

At this time, the mouse pointer becomes a crosshair, click the opened application, and the terminal will display Class information, including 2 strings 

The first string is Class 

But at this time, after the fixed icon appears, the application icon disappears, and the application icon will not be displayed until the fixed icon

Summarize

Compared with win and mac, ubuntu still needs to be tossed. The advantage is that there are more software now, and a lot of development work is closer to the original ecology, especially after the M1 mac, it is well adapted to the X64 container, but the image is not adapted. At this time, ubuntu can also be used after tossing.

Guess you like

Origin blog.csdn.net/fenglllle/article/details/130467347
Recommended