termux / termux-widget

Termux add-on app which adds shortcuts to commands on the home screen.
https://f-droid.org/en/packages/com.termux.widget
Other
939 stars 110 forks source link

[wishlist] Support .desktop files #21

Open chrysn opened 6 years ago

chrysn commented 6 years ago

Current shortcuts are typically command-line programs that use stdin/out and have a delimited life time. With git-annex coming to termux, the possibility of other webapp-style local apps following, as well as envisioning the consequenes of an SDL2 port to termux, those might be only a part of what we might want to launch from a desktop icon. Scripts that utilize termux-toast or termux-dialog likely would also prefer to indicate that they don't need the background terminal.

I suggest that Linux desktop files be adopted for that purpose. termux-widget could not only look for executable files in ~/.shortcuts, but also for .desktop files as $XDG_DATA_DIRS/applications/**/*.desktop. Those files could state a localized name of the launcher, an icon, carry custom metadata (like for #20 / #10) and indicate whether a terminal window should be shown at all by setting the Terminal key.

(Alternatives are assuming that everything is shell script and putting metadata in comment lines after the shebang (a practice that has some spread but which I deplore), or Windows 3.1 style PIF files).

Games like moria already have appropriate .desktop files in their Debian packages, and could thus easily become launcher-enabled through termux-widget, complete with name and icon. (Or through a successor to termux-widget, if it turns out that .desktop files are the way to go but termux-widget should stay and there'd be another app that implements .desktop files).

Freed-Wu commented 1 year ago

You means if /data/data/com.termux/files/usr/share/application/nvim.desktop exist,

[Desktop Entry]
Name=Neovim
GenericName=Text Editor
TryExec=nvim
Exec=nvim %F
Terminal=true
Type=Application
Keywords=Text;editor;
Icon=nvim
Categories=Utility;TextEditor;
StartupNotify=false
MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++;

Termux-widget will provide a button which uses /data/data/com.termux/files/usr/share/icons/hicolor/128x128/apps/nvim.png as its icon and when users press the button, it will open a termux terminal then run nvim?

It looks good because it keep consistent with linux programs. However I have a question: if a program is Terminal=false, which means it is a X11 application (or wayland), such as

[Desktop Entry]
Version=1.0
Type=Application
Name=GNU Image Manipulation Program
Comment=Create images and edit photographs
Exec=gimp-2.10 %U
TryExec=gimp-2.10
Icon=gimp
Terminal=false
Categories=Graphics;2DGraphics;RasterGraphics;GTK;
StartupNotify=true
MimeType=image/bmp;image/g3fax;image/gif;image/x-fits;image/x-pcx;image/x-portable-anymap;image/x-portable-bitmap;image/x-portable-graymap;image/x-portable-pixmap;image/x-psd;image/x-sgi;image/x-tga;image/x-xbitmap;image/x-xwindowdump;image/x-xcf;image/x-compressed-xcf;image/x-gimp-gbr;image/x-gimp-pat;image/x-gimp-gih;image/x-sun-raster;image/tiff;image/jpeg;image/x-psp;application/postscript;image/png;image/x-icon;image/x-xpixmap;image/x-exr;image/webp;image/x-webp;image/heif;image/heic;image/avif;image/svg+xml;application/pdf;image/x-wmf;image/jp2;image/x-xcursor;

When user press the button of gimp, should termux open vnc or a X11 server app (See https://wiki.termux.com/wiki/Graphical_Environment) to open gimp? (let user configure to use vnc or any X11 server app) Or just simply don't support any desktop entry which Terminal=false for termux-widget?

agnostic-apollo commented 1 year ago

Linux desktop files are not translatable to Android reqs, but anyways, yaml config files have already been implemented that will provide similar features and will be available in next version as a beta feature.