Add "shortcuts" to applications under linux QT

Model and configuration

Development platform: Imx6DL
QT version: QT5.6

The previous article introduced how to build a cross-compilation environment for Qt Creator. The executable files compiled by Qt Creator can be directly put into the Imx6DL development platform to run. This article introduces how to add a "shortcut" to the executable program on the basis of the previous article.

Before operation, we need to know the following:
1. Linux startup process
2. Desktop management program Matchbox
3. Desktop file

Linux boot process

Reprinted: Linux startup process analysis (SysV init startup mode)
https://blog.csdn.net/yellowblue2/article/details/78745172
Reprinted: Matchbox (1): Startup script
https://blog.csdn.net/u010168781/ article/details/79696160
linux boot process

Start script execution order

1. After the kernel is initialized, an Init process is created. The init process is the starting point of all processes, and generally corresponds to the executable file /sbin/init.

2. /sbin/init reads the /etc/initabfile and initializes it according to the content inside.

# 指定默认缺省运行级别为5 #
id:5:initdefault:

# 首次执行的脚本,si是系统初始化的进程 #
si::sysinit:/etc/init.d/rcS

#runlevel is used to indicate the state of the system after the init process ends. There is no fixed information in the hardware of the system to indicate the runlevel
#Runlevel 0 is for init to close all processes and terminate the system.
#Runlevel 1 is used to switch the system to single-user mode.
#Runlevel 2 is a mode that allows the system to enter multi-user mode, but it does not support file sharing. This mode is rarely used.
#Runlevel 3 is the most commonly used operating mode, mainly used to provide a true multi-user mode, and it is also the default mode for most servers.
#Runlevel 4 is generally not used by the system. Users can design their own system status and apply it to runlevel 4. Although it is rarely used, using this system can # achieve some specific login requests.
#Runlevel 5 is to initialize the system as a dedicated X Window terminal. For a powerful Linux system, this is not a good choice, but if the user needs this, he can also start the program at runlevel.
#Runlevel 6 is to close all running processes and restart the system

3. Execute the /etc/init.d/rcSscript

# 声明环境变量 #
PATH=/sbin:/bin:/usr/sbin:/usr/bin
runlevel=S
prevlevel=N
umask 022
export PATH runlevel prevlevel

# 设置环境变量 #
. /etc/default/rcS

exec /etc/init.d/rc S

4. /etc/init.d/rc SImplementation

# 现在开始运行对应运行级别的启动脚本,S开头 #
# 第一次的运行级别为:runlevel为S,previous为S,执行 /etc/rcS.d/S* #
# 第二次的运行级别: runlevel为3或5,previous为S #
# 关机时,第三次的运行级别:runlevel为6,previous为K或S #
# Now run the START scripts for this runlevel. #
for i in /etc/rc$runlevel.d/S*

#启动脚本
startup $i start

5, running /etc/rcS.d/the script in the beginning of the S, as follows:
Scripts in the rcS.d folder
6, execute l5:5:wait:/etc/init.d/rc 5the script in the corresponding level, i.e. /etc/rc5.dscript folder
Scripts in the /etc/rc5.d folder

Placed in rc*.d is the symbolic link of the actual file in the /etc/Init.d folder, the naming format is S{number}{name} /K{number}{name}
The file starting with S is passed to the script start
The file starting with parameter K passes the stop parameter
number to the script to determine the order of execution

7. S01xserver-nodm is used to start the XServer system, and the execution steps are as follows:
(1) Execute the /etc/X11/Xserverscript

exec xinit /etc/X11/Xsession -- $BINDIR/$XSERVER $ARGS -dpi $DPI $*
xinit 命令首先执行Xserver 命令即$XSERVER $DISPLAY $ARGS $*,接着执行X 客户端命令即 /etc/X11/Xsession脚本;

(2) Execute the /etc/X11/Xsessionscript

SYSSESSIONDIR=/etc/X11/Xsession.d
SESSIONFILES=`ls -X $SYSSESSIONDIR`
if [ -n "$SESSIONFILES" ]; then
  for SESSIONFILE in $SESSIONFILES; do
  # Test if script is executable first before sourcing it
    if [ -x "$SYSSESSIONDIR/$SESSIONFILE" ]; then
      . $SYSSESSIONDIR/$SESSIONFILE
    fi
  done
fi	
接着循环执行/etc/X11/Xsession.d文件夹下的脚本 ,其中,90XWindowManager.sh 为窗口管理器脚本,其执行 /usr/bin/x-session-manager 脚本,然后执行 /etc/matchbox/session 脚本

(3) Execute the /etc/matchbox/sessionscript

最后启动 Matchbox 三个程序
matchbox-desktop &
    
START_APPLETS=showdesktop,windowselector                                
END_APPLETS=clock,battery,$KEYBOARD_APPLET,systray,startup-notify,notify
matchbox-panel --titlebar --start-applets $START_APPLETS --end-applets $END_APPLETS &    

exec matchbox-window-manager -theme Sato -use_desktop_mode decorated

Matchbox (desktop management program)

Reprinted: Matchbox summary
https://blog.csdn.net/u013491946/article/details/75068488

1. The
main function of Matchbox Window Manager is to set the window interface and configure themes. The reference document is not found, and it is rarely introduced on the Internet.

2. Matchbox-panel-manager
panel manager, used to manage panel applications, these small programs include: start menu, user information tools such as: battery power display, cpu and other monitoring, clocks.

3. Matchbox Desktop
desktop is at the bottom of the window stack, providing the most primitive way to run programs, but it can be extended.

Desktop file

Reprinted: Getting Started with Desktop Files under Linux
https://blog.csdn.net/yiferhuang/article/details/86634589

1, the Desktop Entryfile is a file system for the Linux desktop configuration information describing the program starts, it .desktopis the extension, the equivalent of a desktop shortcut for Windows systems. Usually a binary executable program is a file with no suffix and no icon, and cannot be moved at will.
2. When the system runs Matchbox Desktop, the system will automatically detect the /usr/share/applicationsfiles in the folder .desktop.
3. Each .desktopfile is the entrance of an application, and each .desktopfile can display an icon.

desktop file basic template

Take demo.desktop as an example

[Desktop Entry]
Name=<应用程序名>
Type=Application
Exec=<应用程序完整路径>
Icon=<应用程序图标的完整路径>

• Name: the final display name of the desktop file (be sure to pay attention to the difference with the desktop file name)
• Type: used to specify the type of desktop file (including 3 types: Application, Link, Directory)
• Exec: used to specify the binary file The full path of the execution program
• Icon: Specify the full path of the application icon (the suffix name can be omitted). The icon supports png format, svg format, etc. The recommended size of the icon is 128x128

Add "shortcut" to the application

After talking for a long time, only the last sentence is useful!!

The executable file into /forlinx/qtbin, and then in /usr/share/applicationsthe next to create a .desktop file, restart the application, you can see we've added on the desktop.

The .desktop file I added

[Desktop Entry]
Name=openglwindow
Exec=/forlinx/qtbin/openglwindow
Icon=3g-icon
#Terminal=false
Type=Application
Categories=Forlinx;
#X-MB-SingleInstance=true
#Comment=Qt5 NMapper
#StartupNotify=false

Guess you like

Origin blog.csdn.net/qq_34743935/article/details/90636481