12 Temmuz 2020 Pazar

.desktop Dosyası - Application Launcher İçindir

Giriş
Not : Kısa yol dosyasına bir diğer alternatif ise  gnome-shell extension oluşturmak. Bir örnek burada

Not : Exec, Name, Type alanlarını doldurmak gerekir. Kısa yol gtk-launch komutu ile doğrulanabilir

.desktop Dosyası Nereye Konulur
1. Herkes İçin
Açıklaması şöyle. Yani /usr/share/applications dizini altında konulur.
Desktop entry files must reside in the $XDG_DATA_DIRS/applications directory and must have a .desktop file extension. If $XDG_DATA_DIRS is not set, then the default path is /usr/share is used. This also implies that user specific desktop entries may be located at $XDG_DATA_HOME/applications which is searched first. If $XDG_DATA_HOME is not set, then the default path ~/.local/share is used. Desktop entries are collected from all directories in the $XDG_DATA_DIRS environment variable. Directories which appear first in $XDG_DATA_DIRS are given precedence when there are several .desktop files with the same name.
2. Tek Kullanıcı İçim
Tek bir kullanıcı için açıklama şöyle. Yani ~/.local/share/applications dizini altında konulur.
You can use ~/.local/share/applications under your user's home folder to keep .desktop files that you want to have available for that user only.
Benzer açıklama şöyle
A desktop launcher is a text file with the .desktop extension, formatted in a specific way. If you place it in the folder ~/local/share/applications, it will be picked up in the application overview.

Thus, you could create the file ~/.local/share/applications/toggle-keyboard.desktop to launch your script. 
Exec Alanı ve Open With Menu
Açıklaması şöyle
In order for an app to be available and usable in the open with menu when a file is selected, it needs to have two things in its .desktop launcher file
- Exec key code 
- MimeType=
Seçeneklerin açıklaması şöyle
%f A single file name, even if multiple files are selected. The system reading the desktop entry should recognize that the program in question cannot handle multiple file arguments, and it should should probably spawn and execute multiple copies of a program for each selected file if the program is not able to handle additional file arguments. If files are not on the local file system (i.e. are on HTTP or FTP locations), the files will be copied to the local file system and %f will be expanded to point at the temporary file. Used for programs that do not understand the URL syntax.

%F A list of files. Use for apps that can open several local files at once. Each file is passed as a separate argument to the executable program.

%u A single URL. Local files may either be passed as file: URLs or as file path.

%U A list of URLs. Each URL is passed as a separate argument to the executable program. Local files may either be passed as file: URLs or as file path.

%i The Icon key of the desktop entry expanded as two arguments, first --icon and then the value of the Icon key. Should not expand to any arguments if the Icon key is empty or missing.

%c The translated name of the application as listed in the appropriate Name key in the desktop entry.

%k The location of the desktop file as either a URI (if for example gotten from the vfolder system) or a local filename or empty if no location is known.
Örnek - %F
Açıklaması şöyle. Çoklu dosya seçimi anlamına gelir.
%F if the app is capable of accepting multiple files as arguments or %f if it can only accept a single file as an argument. This code is added at the end of the Exec= line with a space before it.
Şöyle yaparız
[Desktop Entry]
Name=Amazon
Comment=Online Shopping for Electronics, Apparel, Computers, Books, DVDs & more
Type=Application
Categories=Network;
Icon=amazon-store
Exec=/usr/share/ubuntu-web-launchers/amazon-launcher %F
X-Ubuntu-Gettext-Domain=ubuntu-default-launchers
MimeType=image/bmp;image/gif;image/jpeg;image/jpg;image/pjpeg;
Örnek - %U
Örneğin tarayıcıda açmak istersek bu seçeneği kullanırız.

Exec Alanı
Açıklaması şöyle
The Exec key must contain a command line. A command line consists of an executable program optionally followed by one or more arguments. The executable program can either be specified with its full path or with the name of the executable only. If no full path is provided the executable is looked up in the $PATH environment variable used by the desktop environment. The name or path of the executable program may not contain the equal sign ("="). Arguments are separated by a space.
Örnek
Şöyle yaparız
[Desktop Entry]
Name=Toggle Keyboard
Comment=Toggle keyboard on or off
Exec=<name or path to your script>
Terminal=false
Type=Application
Icon=<name or path to the icon >
Categories=Utility;
Name Alanı
Örnek

Şöyle yaparız
[Desktop Entry]
Exec=/bin/bash -c "cd ~/MyDirectory && myapp some_arguments"
Name=Some App
Type=Application
Terminal Alanı
Örnke
Şöyle yaparız
[Desktop Entry]
Version=1.0
Type=Application
Name=Line Chat
Comment=Line Chat
Exec=google-chrome "chrome-extension://ophjlpahpchlmihnnnihgmmeilfjmjjc/index.html"
Icon=
Path=
Terminal=false
StartupNotify=false
Type Alanı
Örnek
Şöyle yapaız
[Desktop Entry]
Version=1.0
Name=Script
Comment=
Keywords=Script
Exec=/pathtoscript/scriptname
Terminal=false
X-MultipleArgs=true
Type=Application
Icon=preferences-system
Categories=GTK;Development;
StartupNotify=false

Hiç yorum yok:

Yorum Gönder