mirror of
https://github.com/nix-community/nix-on-droid.git
synced 2025-11-08 19:46:07 +01:00
modules/android-integration: termux-open, termux-open-url, xdg-open
This commit is contained in:
parent
cc573e03d9
commit
6f944fe209
6 changed files with 81 additions and 14 deletions
|
|
@ -5,8 +5,8 @@
|
|||
### New Options
|
||||
|
||||
* New options under `android-integration`,
|
||||
offer some of the tools familiar to Termux users.
|
||||
Currently only `am` and `termux-setup-storage` are provided.
|
||||
offer some of the tools familiar to Termux users:
|
||||
`am`, `termux-open`, `termux-open-url`, `termux-setup-storage` and `xdg-open`.
|
||||
|
||||
### Compatibility considerations
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,28 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
termux-open.enable = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
example = "true";
|
||||
description = lib.mdDoc ''
|
||||
Provide a `termux-open` command
|
||||
that opens files or urls in external apps
|
||||
(uses `com.termux.app.TermuxOpenReceiver`).
|
||||
'';
|
||||
};
|
||||
|
||||
termux-open-url.enable = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
example = "true";
|
||||
description = lib.mdDoc ''
|
||||
Provide a `termux-open-url` command
|
||||
that opens files or urls in external apps
|
||||
(uses `android.intent.action.VIEW`).
|
||||
'';
|
||||
};
|
||||
|
||||
termux-setup-storage.enable = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
|
|
@ -40,6 +62,15 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
xdg-open.enable = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
example = "true";
|
||||
description = lib.mdDoc ''
|
||||
Provide an `xdg-open` alias to `termux-open` command.
|
||||
'';
|
||||
};
|
||||
|
||||
unsupported.enable = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
|
|
@ -58,6 +89,9 @@ in
|
|||
environment.packages =
|
||||
(ifD cfg.am.enable termux-am) ++
|
||||
(ifD cfg.termux-setup-storage.enable termux-tools.setup_storage) ++
|
||||
(ifD cfg.termux-open.enable termux-tools.open) ++
|
||||
(ifD cfg.termux-open-url.enable termux-tools.open_url) ++
|
||||
(ifD cfg.xdg-open.enable termux-tools.xdg_open) ++
|
||||
(ifD cfg.unsupported.enable termux-tools.out);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,6 +47,9 @@ stdenvNoCC.mkDerivation rec {
|
|||
outputs = [
|
||||
"out" # all the unsupported unsorted stuff
|
||||
"setup_storage" # termux-setup-storage
|
||||
"open" # termux-open
|
||||
"open_url" # termux-open-url
|
||||
"xdg_open" # xdg-open
|
||||
];
|
||||
postInstall = ''
|
||||
rm $out/etc/termux-login.sh
|
||||
|
|
@ -79,17 +82,24 @@ stdenvNoCC.mkDerivation rec {
|
|||
mkdir -p $setup_storage/bin
|
||||
mv $out/bin/termux-setup-storage $setup_storage/bin/
|
||||
|
||||
mkdir -p $open/bin
|
||||
mv $out/bin/termux-open $open/bin/
|
||||
|
||||
mkdir -p $open_url/bin
|
||||
mv $out/bin/termux-open-url $open_url/bin/
|
||||
|
||||
mkdir -p $xdg_open/bin
|
||||
rm $out/bin/xdg-open
|
||||
ln -s $open/bin/termux-open $xdg_open/bin/xdg-open
|
||||
|
||||
# check that we didn't package we didn't want to
|
||||
find $out | ${gnused}/bin/sed "s|^$out|.|" | sort > effective
|
||||
echo . >> expected
|
||||
echo ./bin >> expected
|
||||
echo ./bin/termux-backup >> expected # entirely untested
|
||||
echo ./bin/termux-open >> expected # good candidate for fixing
|
||||
echo ./bin/termux-open-url >> expected # good candidate for fixing
|
||||
echo ./bin/termux-reload-settings >> expected # good candidate for fixing
|
||||
echo ./bin/termux-wake-lock >> expected # good candidate for fixing
|
||||
echo ./bin/termux-wake-unlock >> expected # good candidate for fixing
|
||||
echo ./bin/xdg-open >> expected # good candidate for fixing
|
||||
echo ./share >> expected
|
||||
echo ./share/examples >> expected
|
||||
echo ./share/examples/termux >> expected
|
||||
|
|
|
|||
|
|
@ -6,17 +6,17 @@ from common import screenshot, wait_for
|
|||
|
||||
|
||||
def run(d):
|
||||
OPENERS = ['termux-open', 'termux-open-url', 'xdg-open']
|
||||
TOOLS = ['am', 'termux-setup-storage'] + OPENERS
|
||||
|
||||
nod = bootstrap_channels.run(d)
|
||||
|
||||
# Verify that android-integration tools aren't installed by default
|
||||
d('input text "am"')
|
||||
d.ui.press('enter')
|
||||
wait_for(d, 'bash: am: command not found')
|
||||
screenshot(d, 'no-am')
|
||||
d('input text "termux-setup-storage"')
|
||||
d.ui.press('enter')
|
||||
wait_for(d, 'bash: termux-setup-storage: command not found')
|
||||
screenshot(d, 'no-termux-setup-storage')
|
||||
for toolname in TOOLS:
|
||||
d(f'input text "{toolname}"')
|
||||
d.ui.press('enter')
|
||||
wait_for(d, f'bash: {toolname}: command not found')
|
||||
screenshot(d, f'no-{toolname}')
|
||||
|
||||
# Apply a config that enables android-integration tools
|
||||
cfg = ('/data/local/tmp/n-o-d/unpacked/tests/on-device/'
|
||||
|
|
@ -100,3 +100,14 @@ def run(d):
|
|||
wait_for(d, 'Do you want to continue?')
|
||||
d.ui.press('enter')
|
||||
wait_for(d, 'Aborting configuration and leaving')
|
||||
|
||||
# Verify that *-open* commands work
|
||||
for opener in OPENERS:
|
||||
d(f'input text "{opener} https://example.org"')
|
||||
d.ui.press('enter')
|
||||
screenshot(d, f'{opener}-opened')
|
||||
wait_for(d, 'This domain is for use in illustrative')
|
||||
screenshot(d, f'{opener}-waited')
|
||||
d.ui.press('back')
|
||||
screenshot(d, f'{opener}-back')
|
||||
wait_for(d, f'{opener} https://example.org')
|
||||
|
|
|
|||
|
|
@ -6,7 +6,10 @@ load lib
|
|||
bats_require_minimum_version 1.5.0
|
||||
run ! command -v am
|
||||
run ! command -v termux-setup-storage
|
||||
run ! command -v termux-open
|
||||
run ! command -v termux-open-url
|
||||
run ! command -v xdg-open
|
||||
run ! command -v termux-backup
|
||||
|
||||
cp \
|
||||
"$ON_DEVICE_TESTS_DIR/config-android-integration.nix" \
|
||||
|
|
@ -15,7 +18,10 @@ load lib
|
|||
|
||||
command -v am
|
||||
command -v termux-setup-storage
|
||||
run ! command -v termux-open-url
|
||||
command -v termux-open
|
||||
command -v termux-open-url
|
||||
command -v xdg-open
|
||||
run ! command -v termux-backup
|
||||
|
||||
_sed \
|
||||
-e "s|# unsupported.enable = false;|unsupported.enable = true;|" \
|
||||
|
|
@ -24,7 +30,10 @@ load lib
|
|||
nix-on-droid switch
|
||||
run ! command -v am
|
||||
command -v termux-setup-storage
|
||||
command -v termux-open
|
||||
command -v termux-open-url
|
||||
command -v xdg-open
|
||||
command -v termux-backup
|
||||
|
||||
switch_to_default_config
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,10 @@ _:
|
|||
system.stateVersion = "23.11";
|
||||
android-integration = {
|
||||
am.enable = true;
|
||||
termux-open.enable = true;
|
||||
termux-open-url.enable = true;
|
||||
termux-setup-storage.enable = true;
|
||||
xdg-open.enable = true;
|
||||
# unsupported.enable = false;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue