termux-app icon indicating copy to clipboard operation
termux-app copied to clipboard

[Feature]: Use same directory to resotore config file of termux, not seperately

Open Freed-Wu opened this issue 3 years ago • 14 comments

Feature description

Now, config file of termux has many paths:

  • ~/.termux
  • ~/bin: termux hook use it
  • ~/shortcuts: termux-widgets use it
  • ~/.termuxrc: termux-packages use it

Why not use a same directory? Such as ~/.termux, Or ${XDG_CONFIG_HOME:-$HOME/.config}/termux? Use a same directory is more convenient for user to backup their config file by VCS, and respect some standard.

Thanks.

Additional information

Most of app/terminal emulators use ${XDG_CONFIG_HOME:-$HOME/.config}/appname to restore their config files.

Freed-Wu avatar Jun 05 '22 09:06 Freed-Wu

~~Configuration files for most software are located in $PREFIX/etc, $HOME/.config and $HOME,~~ ~~if you want to change them, it will take a lot of work.~~

Termux can be backed up via termux-backup, but it is sometimes too large. Need to make a script specifically for backing up configuration files for termux?

2096779623 avatar Jun 08 '22 05:06 2096779623

@2096779623 It sounds more like to me that the user just wants the configs in another basically catchall location so as to do less and that's it. Not that the user needs a script.

@Freed-Wu The path is hardcoded but it shouldn't take more than some minutes to switch it over to a setting with user specified path unless there's something else going on. I don't know why they hardcoded it. Could just be that's how they did it or there could be a difficult reason.

Xavron avatar Jun 21 '22 16:06 Xavron

@Freed-Wu The path is hardcoded but it shouldn't take more than some minutes to switch it over to a setting with user specified path unless there's something else going on. I don't know why they hardcoded it. Could just be that's how they did it or there could be a difficult reason.

So need a script to backup them.

2096779623 avatar Jun 23 '22 14:06 2096779623

It sounds more like to me that the user just wants the configs in another basically catchall location so as to do less

I think termux can:

  • ${XDG_CONFIG_HOME:-$HOME/.config}/termux store colors.properties, termux.properties, etc.
  • ${XDG_CONFIG_HOME:-$HOME/.config}/termux/bin store termux-file-editor, termux-url-opener, etc.
  • ${XDG_CONFIG_HOME:-$HOME/.config}/termux/shortcuts store termux-widgets's shortcuts.
  • ${XDG_CONFIG_HOME:-$HOME/.config}/termux/termuxrc.sh store the config of termux-packages like
# shellcheck shell=bash disable=SC2034
JAVA_HOME="$(command ls -d /usr/lib/jvm/java-*-openjdk 2> /dev/null||return 0)"

if [ "${TERMUX_PACKAGES_OFFLINE-false}" = false ]; then
	if [ -d /opt/android-sdk ]; then
		ANDROID_HOME=/opt/android-sdk
	fi
	if [ -d /opt/android-ndk ]; then
		NDK=/opt/android-ndk
	fi
fi
# ex: filetype=bash

I hope it is suffixed with .sh because the original name ~/.termuxrc let me must write some shell=bash and filetype=bash to let editor and other tools know it is a bash script.

So I can add ${XDG_CONFIG_HOME:-$HOME/.config}/termux to my dotfiles easily, not search many different paths.

The path is hardcoded but it shouldn't take more than some minutes to switch it over to a setting with user specified path

Sounds it can be realized, right?

Freed-Wu avatar Nov 11 '22 06:11 Freed-Wu

May the PR about this feature be accepted?

Freed-Wu avatar Nov 14 '22 08:11 Freed-Wu

Primary paths will be changed to the following with the next update.

  • ~/.termux/termux-widget/shortcut/{launcher,dynamic,device_control,icon}
  • ~/.termux/termux-widget/termux-widget.properties
  • ~/.termux/termux-float/termux-float.properties

The termux-tasker paths can be changed in future, currently defaults to ~/.termux/tasker for non absolute paths so changing directory may require work.

The .config directly can used as secondary path for properties files but shortcuts/binaries won't be stored there. Having multiple directories complicates things and increases I/O for execution for checking if canonical paths are under allowed directories.

I can change ~/.termux/termux.properties primary path to ~/.termux/termux/termux.properties but then will have 3 paths, but since more properties files are planned to be added in future, it may be a good idea to move now.

The ~/bin paths would be good to be moved to ~/.termux/termux/bin, will look into that.

agnostic-apollo avatar Nov 14 '22 09:11 agnostic-apollo

Primary paths will be changed to the following with the next update.

:+1: And README.md should be updated.

Freed-Wu avatar Nov 14 '22 12:11 Freed-Wu

termux-app docs for properties and termux-widget docs will be available on the new site.

agnostic-apollo avatar Nov 14 '22 15:11 agnostic-apollo

I found termux-boot uses ~/.termux/boot. It looks a little inconsistent because

  • termux-app (or just name it termux) use ~/.termux/termux
  • termux-widget use ~/.termux/termux-widget
  • termux-float use ~/.termux/termux-float

They are prefixed by ~/.termux/termux-*, so it looks like ~/.termux/boot is an inconsistent design?

Freed-Wu avatar Jan 10 '23 11:01 Freed-Wu

termux-boot is EOL and boot event support has been added directly into termux-app with a different path and will be available in next version as a beta feature, have talked about it on our matrix dev channel.

agnostic-apollo avatar Jan 10 '23 11:01 agnostic-apollo

termux-boot is EOL and boot event support has been added directly into termux-app with a different path and will be available in next version as a beta feature, have talked about it on our matrix dev channel.

It would be good to make an official statement regarding that. Most users don't frequent the developer chatroom. This probably isn't anything urgent, but it should be mentioned with a future release.

TomJo2000 avatar Jan 10 '23 11:01 TomJo2000

Yeah, I plan to do that when I push out the update.

agnostic-apollo avatar Jan 10 '23 11:01 agnostic-apollo