How to Create a Custom Application Launcher with Quicklist in Linux

29/12/2020
Many popular applications come with quick shortcuts that can be used to execute a specific action. If you right click on the Firefox icon and see a shortcut “Open a New Private Window”, it is nothing but a quick action backed into Firefox application launcher quicklist. This article will explain how to create your own custom launchers with quicklists. Actions in a quicklist can be accessed by right clicking on an application icon.

Creating a Custom Application Launcher with Quicklist

Application launchers that you see in the main menu of your desktop environment are configured using .desktop files. These .desktop files contains code adhering to standards specified by freedesktop specifications.

To create a custom application launcher with quicklist, it is important to understand the structure of a .desktop file first. This article will list only those options that are essential for creating a simple custom application launcher. However, .desktop files are really powerful and it is possible to create advanced launchers with hundreds of options that includes language specific strings, desktop environment restrictions, keyword tags and so on.

The example below shows a custom application launcher called “Text Editors” having two actions in a quicklist:

[Desktop Entry]
Name=Text Editors
Comment=My Favorite Text Editors
Version=1.0.0
Exec=
Terminal=false
Type=Application
StartupNotify=true
Icon=gedit
 
Actions=Sublime-Text;Gedit;
 
[Desktop Action Sublime-Text]
Name=Sublime Text
Exec=subl %U
StartupNotify=true
 
[Desktop Action Gedit]
Name=Gedit
Exec=gedit %U
StartupNotify=true

Where:

  • Name is the name of your custom application launcher that will be shown in the main menu
  • Comment is the searchable short description for the custom launcher
  • Version is the user specified version for the custom app launcher
  • Exec is the default command to run when you left click on the icon of the custom app launcher
  • Terminal defines whether to run the command in a terminal or not
  • Type specifies the type of application
  • StartupNotify, if set to true, allows the system to track launcher events and actions (example: cursor changes to an hourglass figure when doing some background work)
  • Icon refers to the name of the icon to be used for the custom application launcher (read note below)
  • Actions specify the order items in a quicklist
  • [Desktop Action XXXX] creates a new quick list entry that uses some of the options explained above

So to create a valid .desktop launcher with quicklist, you must have a broad [Desktop Entry] category first, followed by [Desktop Action XXXX] entries that define the behavior of individual actions in a quicklist. It is necessary that you use all the variables explained above, as they are the bare minimum ones required for a functional .desktop file.

Note that you have to correctly specify the icon name so that the system can automatically pick an icon for your custom launcher. It is possible to use your own icon file, but for the sake of consistency and reducing dependencies for the custom launcher, it is recommended to use icons already included in you distributions.

To see all valid icon names, run the command below in a terminal:

$ tree -ialf /usr/share/icons/ | grep .png | sed ‘s:.*/::’ | sort | uniq | sed ‘s/.png//g’

To save all valid icon names in a text file, run the command below in a terminal:

$ tree -ialf /usr/share/icons/ | grep .png | sed ‘s:.*/::’ | sort | uniq |
sed ‘s/.png//g’ > icon_names.txt

To activate a .desktop application launcher with quicklist, you need to save it at appropriate location. Run the commands below to create the required .desktop file:

$ cd ~/.local/share/applications
$ subl text-editors.desktop

Replace “subl” with the command of your favorite text editor. Paste the code from above or use your own code, make the file executable using the command below:

$ chmod +x text-editors.desktop

All quicklists can now be accessed by right clicking on the custom application launcher icon. Here is what the end result looks like with an application launcher created from the code above:

Creating a Screenshot Application Using Custom Launcher and Quicklists Only

As you can define left click and right click actions of any custom launcher, it is possible to create minimal apps without much code and GUI interface. Check out an example of a screenshot app made using quicklists only.

To begin with, you have to install some dependencies for the screenshot app to work:

$ sudo apt install imagemagick xdotool

Create a new .desktop file:

$ cd ~/.local/share/applications
$ subl screenshot-app.desktop

Paste the code below in screenshot-app.desktop file:

[Desktop Entry]
Name=The Screenshot App
Comment=Take screenshots of your desktop
Version=1.0.0
Exec=bash -c ‘import -window root ~/Pictures/"$(date -Is)".png’
Terminal=false
Type=Application
StartupNotify=true
Icon=camera
Actions=Fullscreen-delayed;Focused-delayed;Focused;Select-window;
[Desktop Action Fullscreen-delayed]
Name=Grab Fullscreen After 5 Seconds Delay
Exec=bash -c ‘sleep 5; import -window root ~/Pictures/"$(date -Is)".png’
StartupNotify=false
[Desktop Action Focused-delayed]
Name=Grab Focused Window After 5 Seconds
Exec=bash -c ‘window=$(xdotool getwindowfocus); sleep 5; import -window
"$window" ~/Pictures/"$(date -Is)".png’
StartupNotify=false
[Desktop Action Focused]
Name=Grab Focused Window
Exec=bash -c ‘window=$(xdotool getwindowfocus); import
-window "$window" ~/Pictures/"$(date -Is)".png’
StartupNotify=false
[Desktop Action Select-window]
Name=Select Window to Capture
Exec=bash -c ‘import ~/Pictures/"$(date -Is)".png’
StartupNotify=false

Save the file and make it executable:

$ chmod +x screenshot-app.desktop

Now whenever you click on “The Screenshot App”, it will capture a full screen screenshot and store it in ~/Pictures directory. More options are available when you right click on the app icon.

Conclusion

Creating custom launchers with quicklists is a great way to access commonly used apps and commands. As these app launchers work like any other desktop application, it is possible to pin them on taskbar or panel available in your desktop environment. If you keep dependencies minimal, these launchers are quite portable and can be shared between different systems.

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

How to Install and Use Dropbox on OpenSUSE

Dropbox is definitely one of the top online storage solutions for storing and sharing photos, documents, spreadsheets,...
29/12/2020

Chính sách hoàn tiền ONET IDC

CHÍNH SÁCH HOÀN TIỀN TẠI ONET IDC 1. NỘI DUNG Chính sách hoàn tiền dịch vụ có nghĩa là ONET IDC sẽ...
14/10/2012

Top Linux Software for Professional Translators

Translation market is becoming more competitive everyday both for companies and language service providers. While working...
29/12/2020
Bài Viết

Bài Viết Mới Cập Nhật

Tìm Hiểu Về Thuê Proxy US – Lợi Ích và Cách Sử Dụng Hiệu Quả
11/12/2024

Mua Proxy V6 Nuôi Facebook Spam Hiệu Quả Tại Onetcomvn
03/06/2024

Hướng dẫn cách sử dụng ProxyDroid để duyệt web ẩn danh
03/06/2024

Mua proxy Onet uy tín tại Onet.com.vn
03/06/2024

Thuê mua IPv4 giá rẻ, tốc độ nhanh, uy tín #1
28/05/2024