Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shortcuts cannot be symlinks outside the ~/.shortcuts or ~/.termux directory #57

Closed
harshad1 opened this issue Sep 28, 2021 · 14 comments
Closed

Comments

@harshad1
Copy link

harshad1 commented Sep 28, 2021

Problem description

I used to be able to use a simlink for .shortcuts. In the latest version it has to be a directory.

Steps to reproduce

  1. Make simlink from .shortcuts -> ./foo/bar
  2. Widget is empty

Expected behavior

Termux shows all items in ./foo/bar

Additional information

  • Termux application version: 0.117
  • Termux widget version: 0.13 (f droid)
  • Android OS version: 11
  • Device model: Pixel 3 XL
@agnostic-apollo
Copy link
Member

agnostic-apollo commented Sep 28, 2021

That is expected behaviour. Check Changelog for v0.13.0 at https://github.com/termux/termux-widget/releases

Create a symlink under ~/.shortcuts directory and place foo under ~/.termux.

If you want scripts in ~/.termux to show, create a symlink for them inside ~/.shortcuts, like for a script file with ln -s ~/.termux/script ~/.shortcuts/script or for a whole directory with ln -s ~/.termux/dir ~/.shortcuts/dir.

The ~/.shortcuts path must itself also be a directory and cannot be a symlink.

@RalfWerner
Copy link

@harshad1 as discussed here ff the "canonical" restriction (for tasker) will not changed back for widget and I desribe a new one

@agnostic-apollo agnostic-apollo pinned this issue Sep 29, 2021
@agnostic-apollo agnostic-apollo changed the title .shortcuts cannot be a simlink shortcuts cannot be a symlink outside ~/.shortcuts or ~/.termux Sep 29, 2021
@agnostic-apollo agnostic-apollo changed the title shortcuts cannot be a symlink outside ~/.shortcuts or ~/.termux shortcuts cannot be symlinks outside the ~/.shortcuts or ~/.termux directory Sep 29, 2021
@agnostic-apollo agnostic-apollo changed the title shortcuts cannot be symlinks outside the ~/.shortcuts or ~/.termux directory Shortcuts cannot be symlinks outside the ~/.shortcuts or ~/.termux directory Sep 29, 2021
@harshad1
Copy link
Author

Thanks for pointing me in the right direction.

Unfortunately, this change has broken my workflow. I use simlinks for both ~/.termux and ~/.shortcuts (both point to a folder on my sdcard which is synced with FolderSync).

Will need to figure out a new system.

@agnostic-apollo
Copy link
Member

agnostic-apollo commented Sep 30, 2021

Sorry for the inconvenience but this had to be done. You can use rsync command to sync your ~/.shortcuts directory to sd card and then run folder sync or you can also directly just use rclone for backups.

@harshad1
Copy link
Author

this had to be done

Np. Though could you point me at any discussions of why it was required? Would be interesting to read.

You can use rsync command

Ah good suggestion. My current workaround is less elegant :p. I have the following in a shortcut

rm -rf ~/.termux || true
rm -rf ~/.shortcuts || true
cp -r ~/configuration/app_files/termux ~/.termux
cp -r ~/.termux/shortcuts ~/.shortcuts
chmod 700 -R ~/.termux/shortcuts
chmod 700 -R ~/.termux/tasker

@agnostic-apollo
Copy link
Member

It's a restriction for termux plugins that can be controlled by external apps. Same applies to termux-tasker for almost a year, it even requires additional permissions. It's just being enforced now for termux-widget.

I have the following in a shortcut

Yeah, the other way works too.

@nate2014jatc
Copy link

Can this be manually overridden?
This breaks how I've historically used the widget.

@RalfWerner
Copy link

Can this be manually overridden? This breaks how I've historically used the widget.

Not really, except you use the version V0.12! I also deal with my administration as the canonical restriction is not negotiable

@nate2014jatc
Copy link

Can this be manually overridden? This breaks how I've historically used the widget.

Not really, except you use the version V0.12! I also deal with my administration as the canonical restriction is not negotiable

I'm not certain I understand your meaning in the second part of your statement, could you please rephrase?

@RalfWerner
Copy link

see above and links

@agnostic-apollo
Copy link
Member

Can this be manually overridden?

You can create the symlinks as discussed above or compile termux-widget yourself with the restriction removed. You can also create wrapper scripts under ~/.termux or ~/.shortcuts to the actual scripts if the actual scripts are outside those directories.

@agnostic-apollo
Copy link
Member

Check termux/termux-app#2595 for why this change was enforced.

tylerbrazier added a commit to tylerbrazier/dotfiles that referenced this issue Apr 6, 2023
This is only because termux .shortcuts can't be symlinks:
termux/termux-widget#57
I don't want to symlink everything else and make an exception for these
because it would be inconsistent and confusing.
@ac-z
Copy link

ac-z commented Nov 8, 2023

~/.shortcuts/* are the only files in my whole setup that I can't just symlink from my dotfiles repo via GNU stow...
Making a bash script to generate shims in that folder is doable, but inconvenient.

@ac-z
Copy link

ac-z commented Nov 8, 2023

Alright, here's what I came up with.
https://github.com/amb3r-dev/dotfiles/blob/master/termux/.local/bin/termux-shortcuts.sh
This script allows you to define all of your shortcuts as bash functions in a single file, and generate shims for each.
The shims are smart enough to delete themselves if their functions have been removed from termux-shortcuts.sh.
Note that this will overwrite existing scripts in ~/.shortcuts/ if they have the same names as functions you put in this script.

2023-11-08T13:25:41,233221891-08:00
Screenshot_20231108_132320_Nova7
Works like a charm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants