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

Change keyboard type when asking for a password #70

Open
vaites opened this issue Mar 27, 2016 · 14 comments
Open

Change keyboard type when asking for a password #70

vaites opened this issue Mar 27, 2016 · 14 comments

Comments

@vaites
Copy link

vaites commented Mar 27, 2016

When any app or script asks for a password the keyboard doesn't change, but in Android the password fields uses an input method type. Is possible to detect this behavior and change keyboard type?

@vaites
Copy link
Author

vaites commented Apr 24, 2016

This can be implemented with an environment variable? This way any shell script can change the keyboard type before asking for something. Variable can be defined as export TERMUX_KEYBOARD_TYPE=textPassword using this values.

Anyway, detection on passwords still need to be detected...

@ghost
Copy link

ghost commented Jun 11, 2018

@vaites What should be the use of this? If you enter a password, every (good) console application does not echo the password.

@vaites
Copy link
Author

vaites commented Jun 11, 2018

The keyboard changes if you are in a text field or a password field. The most important is the prediction engine (I don't want my passwords to be in my suggestion list) and the keys are different (number keys, comma, etc...).

@Neo-Oli
Copy link
Member

Neo-Oli commented Jun 11, 2018

The most important is the prediction engine

But in Termux, the prediction engine doesn't run anyway, unless you use the Text Input View.

@vaites
Copy link
Author

vaites commented Jun 11, 2018

I know, but the keyboard type changes, and depending on your keyboard app is customizable...

@ghost
Copy link

ghost commented Sep 3, 2019

It is nearly impossible to detect where program prompts a password. Reason - it is same stdin, the only difference here is password usually not echoed. Should be possible to track "no echo" terminal state, but most likely will produce false positives in certain cases.

This can be implemented with an environment variable?

Environment variable useless. Child processes can't modify variables of parent.

@vaites
Copy link
Author

vaites commented Sep 4, 2019

Well, I understand. If there's no reliable method to detect it it's better to do not do it. I asked it because macOS detects it and shows a key.

Anyway, it's possible to add an api command with something like this:

#!/bin/bash

termux-keyboard-type --password
read -s -p "Password: " password

Can this command be added? At least users can change the keyboard type in his scripts by hand...

@ghost ghost deleted a comment from Thrinayan872 Jul 26, 2020
@twaik
Copy link
Member

twaik commented Dec 23, 2023

I think this issue can be closed, right? Technically it is not possible to check when program needs to switch keyboard or it enables no-echo mode for other reasons.

@vaites
Copy link
Author

vaites commented Dec 23, 2023

I think this issue can be closed, right? Technically it is not possible to check when program needs to switch keyboard or it enables no-echo mode for other reasons.

I agree that it is not possible to detect when it is necessary to change the keyboard type, but I still find it interesting to be able to change it from a Temux API script.

Think of any script that needs a specific input, like a numeric value, a date or an URL. Why not use a global variable set by a Termux API script and set the type of keyboard to use based on that?. Examples:

# ask for a date
echo 'date' | termux-keyboard-type-set
read -p "Enter a date: " VARIABLE
termux-keyboard-type-reset

# ask for a number
echo 'number' | termux-keyboard-type-set
read -p "Enter a number: " VARIABLE
termux-keyboard-type-reset

# ask for an URL
echo 'textUri' | termux-keyboard-type-set
read -p "Enter a URL: " VARIABLE
termux-keyboard-type-reset

I think (maybe I'm wrong) that setting a global variable for Termux and showing the keyboard based on its value (this values) can't be too complex.

Anyway, close the issue if you don't find it useful...

@twaik
Copy link
Member

twaik commented Dec 23, 2023

able to change it from a Temux API script

Termux:API does not handle IME options, they are handled by active application, Termux in that case.

Why not use a global variable and set the type of keyboard to use based on that?. Examples:

Global variable is relevant for process and the processes it starts, it is not exported to parent processes or processes of other process trees. And it is even not exported to child processes that are already running.

Probably that can be done with escape sequences, but that will require to modify all programs that ask for passwords to send this escape sequences. And it is not clear what to do in the case if program crashes and how to reset keyboard type in that case.

Anyway, close the issue if you don't find it useful...

Let's wait for @agnostic-apollo

@vaites
Copy link
Author

vaites commented Dec 23, 2023

OK, maybe is too compex. I don't know how Termux works behind the scenes. This may not be worth the effort...

Thanks anyway, Termux is great 😉

@sylirre
Copy link
Member

sylirre commented Dec 23, 2023

Probably that can be done with escape sequences, but that will require to modify all programs that ask for passwords to send this escape sequences.

getpass() which is used by many programs for password entry is implemented through NDK headers: https://github.com/termux/termux-packages/blob/master/ndk-patches/26b/unistd.h.patch#L13

Here escape sequences can be easily added. Need to detect and recompile all dependent packages after.

Packages that do not use getpass() should be manually patched.

That's understandable that users want better integration of command line with Android user interface but not everyone here understands that Termux itself is nothing more than just a display interpreting output of command line tools. While accomplishing this task is feasible, that would be a road to overcomplicating things IMO.

Changing keyboard by termux-keyboard-type-set or something like is another story. Termux app can handle broadcasted intents and perform some actions. This already used for termux-wake-lock or termux-wake-unlock for example. But termux-keyboard-type-set utility shouldn't be called in getpass() function and rather left for the user.

it is not clear what to do in the case if program crashes and how to reset keyboard type in that case.

Nothing, just like any other program that changes terminal configuration.

User than can revert back configuration by using utility reset or button "Reset" from context menu.

@vaites
Copy link
Author

vaites commented Dec 23, 2023

It makes no sense if any package must be patched/rebuilt. Forget it if is so complicated....

@agnostic-apollo
Copy link
Member

Intent way would be simpler and should be doable, but probably should wait till after next version work is done on creating command line apis inside termux app itself,

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

No branches or pull requests

5 participants