Linux desktop entry icon

Custom icon for .desktop file not appearing

I intend to change from Windows 7 to Ubuntu. There are some icons on the desktop I would like to use on Ubuntu. I converted these icons to *.png 64*64 pixel and put in /home/user/icons Then I use the terminal:

[desktop entry] Name=Account Exec=/home/user/jameica/jameica.sh Icon=/home/user/icons/ico_account.png Terminal=false Type=application 

I store this file to /usr/share/application with the name account.desktop The desktop entry is created, but not with the desired icon. What is wrong?

8 Answers 8

As of July 2018, there seem to be some bugs in Unity in how it reads .desktop files. Specifically, the path provided for the Icon field cannot be wrapped in quotes. Even if the path contains spaces, it must not be wrapped in quotes.

On the other hand, it’s worth mentioning here that the path provided for the Exec field must be wrapped in quotes if it contains spaces. If it doesn’t contain spaces, the quotes can be left off. This inconsistency in behavior is horribly confusing and should really be considered a bug.

Thus, the following is a valid .desktop:

[Desktop Entry] Name=Firefox Developer Edition Comment=The developer edition of Firefox Quantum. Exec="/home/jack/Applications/Firefox Developer Edition/firefox" Icon=/home/jack/Applications/Firefox Developer Edition/browser/chrome/icons/default/default32.png Terminal=false Type=Application 

The following will run, but not display the icon:

[Desktop Entry] Name=Firefox Developer Edition Comment=The developer edition of Firefox Quantum. Exec="/home/jack/Applications/Firefox Developer Edition/firefox" Icon="/home/jack/Applications/Firefox Developer Edition/browser/chrome/icons/default/default32.png" Terminal=false Type=Application 

And the following won’t even run:

[Desktop Entry] Name=Firefox Developer Edition Comment=The developer edition of Firefox Quantum. Exec=/home/jack/Applications/Firefox Developer Edition/firefox Icon=/home/jack/Applications/Firefox Developer Edition/browser/chrome/icons/default/default32.png Terminal=false Type=Application 

Источник

Как создать ярлык в Ubuntu

Ещё со времён Windows мы привыкли к ярлыкам на рабочем столе. Это красиво, практично и очень удобно. Но в последних версиях разработчики из Canonical решили, что пользователи должны использовать боковую панель запуска, а на рабочем столе будет свободное пространство. Но не всех пользователей устраивает такое положение дел.

Читайте также:  Как запустить скрипт python linux

В этой статье мы рассмотрим, как создать ярлык на рабочем столе Ubuntu, а также разберёмся, как создать ярлык для программы.

Добавление ярлыка в Ubuntu

Добавление ярлыка в Ubuntu на боковую панель не вызовет никаких трудностей даже у начинающего пользователя. Просто перетащите ярлык приложения из меню Dash в область панели:

Также вы можете кликнуть правой кнопкой мыши по нужному приложению в меню и выбрать Добавить в избранное:

После этого ярлык появится на панели. С рабочим столом дело обстоит сложнее. При попытке скопировать приложение возникает ошибка. Но всё же, не смотря на желания разработчиков из Canonical, как говорится, если очень хочется, то можно. Сначала установите gnone-tweak-tool командой:

sudo apt-get install gnome-tweak-tool

Запустите приложение и на вкладке рабочий стол установите переключатель Показывать значки на рабочем столе в положение On:

Затем откройте в файловом менеджере Nautilus папку /usr/share/applications и скопируйте ярлык нужной программы на Рабочий стол. Обратите внимание — копировать нужно именно с помощью контекстного меню, а не перетаскиванием:

После того, как вы вставите ярлык, он будет определяться как неизвестный файл. Запустите его, система спросит, доверяете ли вы этому ярлыку. После того, как вы нажмёте Доверять и запустить, файл превратится в нормальный ярлык приложения.

Если для вашей программы ярлыка не существует, вы можете создать его вручную. Имена файлов ярлыков заканчиваются расширением .desktop и имеют следующий синтаксис:

[Desktop Entry]
Version = 1.0
Name = название
Comment = описание
Exec = /путь/к/исполняемому/файлу
Icon = /путь/к/иконке
Terminal = false
Type = Application
Categories = категории

Здесь самый важный параметр — это Exec. Он должен содержать полный путь к исполняемому файлу программы в файловой системе. Также нужно указать название и полный путь к иконке. Например, ярлык для запуска определённой виртуальной машины в VirtualBox будет выглядеть вот так:

[Desktop Entry]
Version=1.0
Name=Ubuntu 18.04 VM
Comment=Start Ubuntu 18.04 VM
Exec=/usr/bin/VBoxManage startvm «Ubuntu1804»
Icon=/usr/share/icons/hicolor/256×256/apps/ubuntu-logo-icon.png
Terminal=false
Type=Application

Читайте также:  Linux rdp terminal client

Этот файл можно сохранить. Кликните по нему правой кнопкой мышки и перейдите на вкладку Права. Здесь вам нужно установить галочку Разрешить запуск файла как программы:

Далее запустите ярлык и согласитесь с тем, что ему можно доверять:

Таким образом, вы можете выполнить любую команду или запустить любую программу с нужными опциями.

Если вы не хотите редактировать файл вручную, можно воспользоваться утилитой gnome-desktop-item-edit. Для её установки выполните:

sudo apt install —no-install-recommends gnome-panel

Затем, чтобы создать ярлык Ubuntu, нужно выполнить:

gnome-desktop-item-edit ~/Рабочий\ стол/ —create-new

Здесь нужно ввести имя ярлыка, команду и описание. Затем нажмите Ок для добавления ярлыка. Активировать его нужно таким же образом, как и созданный вручную.

Выводы

Теперь добавление ярлыка в Ubuntu 18.04 для вас не проблема, даже не смотря на то, что разработчики скрыли эту возможность. Linux был и остаётся той системой, где всё можно настроить под себя. Удачи вам в ваших экспериментах!

Обнаружили ошибку в тексте? Сообщите мне об этом. Выделите текст с ошибкой и нажмите Ctrl+Enter.

Источник

How to create executable [Desktop Entry] icon?

I appreciate that this is a similar question to others, but I am unable to ask any questions as I don’t have 50 reputation. I have tried to follow Desktop shortcut for terminal command Ubuntu 20.04.4 LTS does not allow me to right click on Desktop to create a new file (only New Folder). I ran sudo gedit from terminal, and created the following;

[Desktop Entry] Name=Jupyter Notebook Exec=jupyter notebook Terminal=true Type=Application Icon=/usr/share/icons/HighContrast/32x32/devices/pda.png 

I saved the file to Desktop, and it appears with a cog icon and my filename > jupyter.desktop I then change the permissions from terminal to executable, chmod +x (later to +rwx as it doesn’t work) If I attempt to click on the file, all it does is open it in gedit. If I go to terminal and try to run

./jupyter.desktop ./jupyter.desktop: line 1: [Desktop: command not found ./jupyter.desktop: line 2: Notebook: command not found ./jupyter.desktop: line 3: notebook: command not found 

NB I have added ‘quotes’ to lines 2 and 3 (Name=’Launcher Name’ and Exec=’exec param’), but I still get line 1 error, so I don’t know if it correct to add the quotes or not! I have been referring to this as a Shortcut (yup, I come from MS), but think it is more correct to say Launcher?? Out of interest, is the .desktop mandatory, or could I have no extension, or even .lnk? I would very much appreciate some help. Thank you >>>> EDIT after the very useful information from @vanadium >>> I do not think it is possible to create a .desktop file in a subdirectory of XDG_DATA_DIRS, at least, my attempts to ‘get a result’ in the Application Explorer failed. It is however noted that the applications shown appear to be cached, as I believe I had experiences that were not immediate. It also appears that the .desktop files are somehow validated, as I get the impression that invalid information will stop the application being shown. You will have guessed that I am trying to create a Jupyter Notebook shortcut. The reason for doing this was to specify my working directory. During my journey, I found that it appears my installation of notebook actually created a .desktop within ~/.local/share/applications. I had attempted to modify Exec=/home/myhome/my_working_directory/jupyter-notebook %f but this failed, leading me to the conclusion regarding validation. On further investigation, I found I could use —notebook-dir, and so my final solution is to modify ~/.local/share/applications/jupyter-notebook.desktop

[Desktop Entry] Name=Jupyter Notebook Comment=Run Jupyter Notebook Exec=jupyter-notebook --notebook-dir="/home/myhome/my_working_directory" %f Terminal=true Type=Application Icon=notebook StartupNotify=true MimeType=application/x-ipynb+json; Categories=Development;Education; Keywords=python; 

Hopefully the question, and great information from @vanadium, will be useful to others in the future (it is a shame some old questions cannot be deprecated, as they may steer others down the wrong path . pun almost intended)

Читайте также:  Gtx 560 ti linux driver

Источник

Оцените статью
Adblock
detector