monero-project / monero-gui

Monero: the secure, private, untraceable cryptocurrency
Other
1.74k stars 769 forks source link

Why does it generate an invalid .desktop file? #4178

Open Botspot opened 1 year ago

Botspot commented 1 year ago

I was using these commands to compile monero-gui on my own arm64 hardware. These were the commands I used:

sudo apt install qtbase5-dev qtdeclarative5-dev qml-module-qtqml-models2 qml-module-qtquick-controls qml-module-qtquick-controls2 qml-module-qtquick-dialogs qml-module-qtquick-xmllistmodel qml-module-qt-labs-settings qml-module-qt-labs-platform qml-module-qt-labs-folderlistmodel qttools5-dev-tools qml-module-qtquick-templates2 libqt5svg5-dev
git clone --recursive https://github.com/monero-project/monero-gui.git
cd monero-gui
make release-linux-armv8 -j4
cd /home/pi/monero-gui/build/release

# RUN
/home/pi/monero-gui/build/release/bin/monero-wallet-gui

Somewhere during that process, this file showed up: /home/pi/.local/share/applications/monero-gui.desktop. Here's the contents of the file:

[Desktop Entry]
Name=Monero GUI
GenericName=Monero-GUI
X-GNOME-FullName=Monero-GUI
Comment=Monero GUI
Keywords=Monero;
Exec=/home/pi/monero-gui/build/release/bin/monero-wallet-gui %u
Terminal=false
Type=Application
Icon=monero
Categories=Network;GNOME;Qt;
MimeType=x-scheme-handler/monero;x-scheme-handler/moneroseed
StartupNotify=true
X-GNOME-Bugzilla-Bugzilla=GNOME
X-GNOME-UsesNotifications=true
StartupWMClass=monero-wallet-gui

Its icon does not work because no icon named monero exists in /usr/share/icons or in ~/.icons.

This file existed before running sudo make install, which I also find to be strange. Usually compiling and running a program will not create an application launcheer in the menu. I'm fairly sure it was generated by utils.cpp, necause that is the only relevant match when grepping the whole monero-gui directory for '.desktop'. Here's an excerpt from utils.cpp:

$ grep -F '.desktop' ~/monero-gui/src -r -B10 -A10
/home/pi/monero-gui/src/qt/utils.cpp-}
/home/pi/monero-gui/src/qt/utils.cpp-
/home/pi/monero-gui/src/qt/utils.cpp-void registerXdgMime(){
/home/pi/monero-gui/src/qt/utils.cpp-    // Register desktop entry
/home/pi/monero-gui/src/qt/utils.cpp-    // - MacOS handled via Info.plist
/home/pi/monero-gui/src/qt/utils.cpp-    // - Windows handled in the installer by rbrunner7
/home/pi/monero-gui/src/qt/utils.cpp-    // - Linux written to `QStandardPaths::ApplicationsLocation`
/home/pi/monero-gui/src/qt/utils.cpp-    // - Tails written to persistent dotfiles
/home/pi/monero-gui/src/qt/utils.cpp-    QString mime = xdgMime();
/home/pi/monero-gui/src/qt/utils.cpp-    QString appPath = QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation);
/home/pi/monero-gui/src/qt/utils.cpp:    QString filePath = QString("%1/monero-gui.desktop").arg(appPath);
/home/pi/monero-gui/src/qt/utils.cpp-
/home/pi/monero-gui/src/qt/utils.cpp-    if (TailsOS::detect())
/home/pi/monero-gui/src/qt/utils.cpp-    {
/home/pi/monero-gui/src/qt/utils.cpp-        if (TailsOS::detectDotPersistence() && TailsOS::usePersistence)
/home/pi/monero-gui/src/qt/utils.cpp-        {
/home/pi/monero-gui/src/qt/utils.cpp-            TailsOS::persistXdgMime(filePath, mime);
/home/pi/monero-gui/src/qt/utils.cpp-        }
/home/pi/monero-gui/src/qt/utils.cpp-    }
/home/pi/monero-gui/src/qt/utils.cpp-    else
/home/pi/monero-gui/src/qt/utils.cpp-    {

Could someone help explain what is going on here? Would it be possible for me to modify the behavior so that the menu launcher is placed in /usr/share/applications, and so that icons are copied to the relevant folders, in addition to just "installing" monero-gui the same way other GUI programs are?

selsta commented 1 year ago

Somewhere during that process, this file showed up: /home/pi/.local/share/applications/monero-gui.desktop.

Starting the GUI for the first time asks you if you want to install the .desktop file.

This file existed before running sudo make install, which I also find to be strange.

We don't have a make install target.

Its icon does not work because no icon named monero exists in /usr/share/icons or in ~/.icons.

I think this issue is related: https://github.com/monero-project/monero-gui/issues/4006

Botspot commented 1 year ago

We don't have a make install target.

Then maybe it is an undocumented feature.

~/monero-gui/build/release $ sudo make install
Install the project...
-- Install configuration: "Release"
-- Installing: /usr/local/lib/liblmdb.a
-- Installing: /usr/local/lib/libeasylogging.a
-- Installing: /usr/local/lib/libepee.a
-- Installing: /usr/local/bin/monero-wallet-rpc
-- Installing: /usr/local/include/wallet/api/wallet2_api.h
-- Installing: /usr/local/bin/monero-wallet-cli
-- Installing: /usr/local/bin/monero-gen-trusted-multisig
-- Installing: /usr/local/bin/monero-gen-ssl-cert
-- Installing: /usr/local/bin/monerod
-- Installing: /usr/local/bin/monero-blockchain-import
-- Installing: /usr/local/bin/monero-blockchain-export
-- Installing: /usr/local/bin/monero-blockchain-mark-spent-outputs
-- Installing: /usr/local/bin/monero-blockchain-usage
-- Installing: /usr/local/bin/monero-blockchain-ancestry
-- Installing: /usr/local/bin/monero-blockchain-depth
-- Installing: /usr/local/bin/monero-blockchain-stats
-- Installing: /usr/local/bin/monero-blockchain-prune-known-spent-data
-- Installing: /usr/local/bin/monero-blockchain-prune
-- Installing: /usr/local/bin/monero-wallet-gui
selsta commented 1 year ago

We don't have an install target here: https://github.com/monero-project/monero-gui/blob/master/Makefile

It seems CMake adds an install target automatically, that's why it works in your case.

Botspot commented 1 year ago

@selsta, the .desktop file also shows that Monero is meant to open two filetypes: x-scheme-handler/monero and x-scheme-handler/moneroseed. Searching through the source code I find no other mentions of these mimetypes, and they never appear to be set up in /usr/share/mime.

Do you know what use these files have and how I can correctly specify the mimetypes myself in /usr/share/mime?

selsta commented 1 year ago

https://github.com/monero-project/monero/wiki/URI-Formatting

For example monero:46BeWrHpwXmHDpDEUmZBWZfoQpdc6HaERCNmx1pEYL2rAcuwufPN9rXHHtyUA4QVy66qeFQkn6sfK8aHYjA3jk3o1Bv16em?tx_amount=239.39014&tx_description=donation should open monero-gui and enter the address, amount and description.

The moneroseed scheme is outdated.