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