complete-computing-environment/termux_platform_support.org

443 lines
27 KiB
Org Mode

# -*- org-src-preserve-indentation: t; -*-
:PROPERTIES:
:ID: cce/termux_platform_support
:ROAM_ALIASES: "Termux Platform Support"
:END:
#+TITLE: CCE on Termux
#+filetags: :Project:CCE:Icebox:
,#+ARROYO_EMACS_MODULE: termux
,#+ARROYO_MODULE_WANTS: cce/async_forever.org
#+ARCOLOGY_KEY: cce/termux
The [[id:cosmo_communicator][Cosmo Communicator]] has a fully functional keyboard, a decent one at that, and it runs Android in its most optimal configuration. Rather than try to shoehorn the entire CCE and an X11 session in to the thing, it runs enough of the [[id:cce/cce][CCE]] for [[id:cce/programming_lisp_in_emacs][Programming Lisp in Emacs]] and my [[id:cce/org-roam][org-roam]] stack. I use the new [[id:cce/cce_dynamic_loader][CCE Dynamic Loader]] and a =(cce/using-termux)= predicate to toggle things off for this environment.
Here are the modules which are included:
#+begin_src emacs-lisp :exports results :tangle no
(let ((modules (cce/module-list t)))
(seq-filter
#'identity
(mapcar
(lambda (module)
(let ((building-for-termux t) ;; this toggles cce/using-termux
(md (cdr module)))
(if (or (not (alist-get "CCE_PREDICATE" md nil nil 'equal))
(eval (read (or (alist-get "CCE_PREDICATE" md nil nil 'equal) "nil"))))
(list (alist-get "CCE_PRIORITY" md "" nil #'equal)
(format "[[file:%s][%s]]" (car module)
(alist-get "TITLE" md (car module) nil #'equal))
(alist-get "CCE_ANSIBLE" md "" nil #'equal)
(concat "cce/" (alist-get "CCE_MODULE" md "" nil #'equal)))
nil)))
modules)))
#+end_src
#+results:
| 00 | [[file:configure_packaging.org][Configure Packaging]] | packaging | cce/packaging |
| 01 | [[file:emacs_persistent_scratch.org][Emacs Persistent Scratch]] | | cce/persistent-scratch |
| 01 | [[file:disable_transient_mark.org][Effective Emacs Marking]] | | cce/mark |
| 01 | [[file:async_forever.org][Running Things in Emacs Forever]] | | cce/async-forever |
| 01 | [[file:hydra.org][Flowing Keybindings with Hydra]] | | cce/hydra-base |
| 01 | [[file:emacs_session.org][Emacs Session Startup]] | | cce/startup |
| 01 | [[file:evil_mode.org][Evil Mode -- Vim in Emacs]] | | cce/evil-mode |
| 10 | [[file:appearance.org][Themeing my Emacs]] | | cce/appearance |
| 10 | [[file:emacs_dashboard.org][Emacs Dashboard]] | | cce/dashboard |
| 10 | [[file:window_management_in_emacs.org][Window Management in Emacs]] | | cce/window-management |
| 10 | [[file:emacs_launcher_hydra.org][Emacs "Launcher" Hydra]] | | cce/hydra-launcher |
| 10 | [[file:midnight_mode.org][Clean Buffers at a Regular Interval with Midnight Mode]] | | cce/midnight-mode |
| 10 | [[file:dired_file_manager.org][Dired File Manager]] | | cce/dired |
| 10 | [[file:smarter_emacs_help.org][Smarter Emacs Help]] | | cce/hydra-help |
| 10 | [[file:undo_tree.org][Undo and Redo with a tree]] | | cce/undo-tree |
| 10 | [[file:ivy_and_counsel.org][Emacs Control Via Ivy]] | | cce/ivy-config |
| 10 | [[file:moving_through_text_with_emacs.org][Moving Through Text with Emacs]] | | cce/text-navigation |
| 10 | [[file:doom_modeline.org][Doom Modeline]] | | cce/doom-modeline |
| 10 | [[file:hydra_dipswitches.org][Hydra Dipswitches]] | | cce/hydra-dipswitch |
| 10 | [[file:sudo_edit.org][Editing Privileged Files with sudo-edit]] | | cce/sudo-edit |
| 10 | [[file:focused_text_editing.org][Focused Text Editing]] | | cce/focused-mode |
| 10 | [[file:text_editing_fundamental_opinions.org][Text Editing Fundamental Opinions]] | | cce/text-editing |
| 15 | [[file:flyspell_mode.org][Spell-checking with Flyspell Mode]] | | cce/flyspell |
| 18 | [[file:toggle_bright_dark_theme_in_emacs_kde_and_firefox.org][Toggle Bright/Dark Theme in Emacs, KDE and FireFox]] | | cce/toggle-theme |
| 20 | [[file:podman.org][use PodMan for local container builds]] | podman | cce/ |
| 20 | [[file:../japanese_text_input_in_emacs.org][Japanese Text Input in Emacs]] | | cce/japanese-input |
| 20 | [[file:defdaily.org][defdaily]] | | cce/defdaily |
| 30 | [[file:npbot.org][My "Now Playing" on Fediverse]] | | cce/ |
| 30 | [[file:ssh_configuration.org][SSH Configuration]] | | cce/ssh |
| 30 | [[file:syncthing.org][Nearly Stateless Computing Using Syncthing]] | syncthing | cce/ |
| 30 | [[file:gnupg_configuration.org][GnuPG Configuration]] | gnupg | cce/gnupg |
| 30 | [[file:keyboardio_atreus.org][Keyboardio Atreus]] | atreus | cce/ |
| 30 | [[file:the_standard_unix_password_manager.org][Using Pass for Passwords]] | pass | cce/pass |
| 30 | [[file:deadgrep.org][Deadgrep is a Great Grep Interface]] | | cce/deadgrep |
| 31 | [[file:sitelen_pona_pona.org][Sitelen Pona Pona]] | sitelen-pona-pona | cce/sitelen-pona-pona |
| 40 | [[file:emacs_shell_mode_is_good_enough.org][Emacs Shell-Mode is Good Enough]] | | cce/shell-mode |
| 40 | [[file:use_emacs_as_a_pager.org][Use Emacs as a Pager]] | emacs-pager | cce/emacs-pager |
| 40 | [[file:org_mode_installation.org][Org Mode Installation]] | | cce/org-mode |
| 40 | [[file:../emacs_vterm_mode.org][Emacs vterm Mode]] | | cce/vterm |
| 41 | [[file:org_tagging_principles.org][Org Tagging Principles]] | | cce/org-tagging |
| 41 | [[file:some_thoughts_on_time_tracking.org][Some Thoughts on Time Tracking]] | | cce/org-time-tracking |
| 41 | [[file:org-roam.org][org-roam]] | org-roam | cce/org-roam |
| 41 | [[file:project_work_with_org_mode.org][Project Work with Org Mode]] | | cce/org-tasks |
| 41 | [[file:my_org_mode_agendas.org][My Org-mode Agendas]] | | cce/org-agenda |
| 41 | [[file:extracting_org_roam_headings.org][Extracting Org Roam Headings]] | | cce/org-roam-extract |
| 41 | [[file:capturing_tasks.org][Capturing Tasks]] | | cce/org-capture |
| 41 | [[file:project_management_in_org_mode.org][Project Management in Org Mode]] | | cce/org-projects |
| 42 | [[file:mood_log.org][Mood Log]] | | cce/mood-log |
| 42 | [[file:org_mode_postscript_source_blocks.org][Org Mode Postscript Source Blocks]] | postscript-programming | cce/postscript-programming |
| 42 | [[file:../Journal.org][Journal]] | | cce/journal |
| 43 | [[file:../spaced_repetition_study.org][Spaced Repetition Study]] | | cce/org-fc |
| 45 | [[file:delve.org][publicimageltd/delve: Delve into your org-roam zettelkasten.]] | | cce/delve |
| 45 | [[file:quickly_rename_captured_zettel_files.org][Quickly Rename Captured Zettel Files]] | | cce/org-roam-rename-file |
| 45 | [[file:org_download.org][org-download]] | | cce/org-download |
| 45 | [[file:org_html_css_inclusion.org][Embed CSS in Org-Mode HTML Exports]] | | cce/org-html-css |
| 48 | [[file:../org_caldav.org][org-caldav]] | | cce/org-caldav |
| 49 | [[file:org-roam-sbl.org][Finding Broken Knowledge Base Links]] | | cce/org-roam-sbl |
| 60 | [[file:surfing_through_codebases.org][Surfing Through Codebases]] | | cce/code-surf |
| 60 | [[file:basic_emacs_coding_config.org][Basic Emacs Coding Config]] | code-base | cce/code-base |
| 60 | [[file:code_formatting_aggressively.org][Code Formatting, Aggressively]] | | cce/aggressive-indent |
| 60 | [[file:navigating_projects_with_projectile.org][Navigating Projects With Projectile]] | | cce/projectile |
| 60 | [[file:company_code_completion.org][Company Code Completion]] | | cce/company |
| 60 | [[file:magit.org][Git in Emacs with Magit]] | git | cce/magit |
| 60 | [[file:literate_programming.org][Literate Programming with Org Babel]] | | cce/literate-programming |
| 60 | [[file:../cce_nixos_core.org][CCE Nixos Core]] | nixos | cce/nixos |
| 61 | [[file:yasnippets.org][Smart Snippet Templates with Yasnippet]] | | cce/yasnippet |
| 61 | [[file:ediff_configuration.org][Ediff Configuration]] | | cce/ediff-config |
| 62 | [[file:programming_lisp_in_emacs.org][Programming Lisp in Emacs]] | | cce/lisp-core |
| 62 | [[file:../hpi.org][karlicoss - Human Programming Interface]] | hpi | cce/ |
| 63 | [[file:kobo_aura_one.org][Extracting notes from Kobo Aura One]] | hpi-kobo | cce/ |
| 70 | [[file:../ansible_bender.org][Ansible Bender]] | ansible-bender | cce/ |
| 70 | [[file:cce_dynamic_loader.org][CCE Dynamic Loader]] | | cce/cce-loader |
| 70 | [[file:gnus.org][Gnus]] | gnus | cce/gnus |
| 70 | [[file:mbsync.org][mbsync for local mail storage]] | mbsync | cce/mbsync |
| 71 | [[file:gnus_evil_mode.org][Gnus Evil Mode]] | | cce/gnus-evil-mode |
| 71 | [[file:sending_mail_in_gnus.org][Sending Mail in Gnus]] | msmtp | cce/msmtp |
| 71 | [[file:gnus_task_tracking.org][Gnus Task Tracking]] | | cce/gnus-org-integration |
| 71 | [[file:gnus_adaptive_scoring.org][Gnus Adaptive Scoring]] | | cce/gnus-adaptive |
| 80 | [[file:../japanese_study.org][Japanese Study]] | | cce/japanese-study |
| 90 | [[file:../therapy_notes_and_work.org][Therapy Notes and Work]] | | cce/therapy-notes |
| | [[file:../meditation_log.org][Meditation Log]] | | cce/meditation-log |
| | [[file:../monthly_review.org][Monthly Review]] | | cce/monthly-review |
| 90 | [[file:emacs_sqlite3_installation.org][Emacs SQLite3 Installation]] | emacs-sqlite3 | cce/emacs-sqlite3 |
| 90 | [[file:shared_cce_helpers.org][Shared CCE Helpers]] | | cce/cce-common |
| | [[file:../decision_log.org][Decision Log]] | | cce/decision-log |
| | [[file:../weekly_review.org][Weekly Review]] | | cce/weekly-review |
| | [[file:../arcology/deploying.org][Deploying the Arcology]] | | cce/ |
| | [[file:../tea_practice.org][Tea Practice]] | | cce/tea-practice |
| 99 | [[file:run_hooks_after_init.org][Run Hooks After init]] | | cce/run-hooks |
| 99 | [[file:termux_platform_support.org][CCE on Termux]] | | cce/termux |
| t | [[file:pam_u2f.org][Unlock Computer With Yubikey]] | pam-u2f | cce/ |
* Build init
The function =cce/compile-termux= will spit out an =init.el=, and when done with a prefix argument it'll install that in to =init.elc=
#+begin_src emacs-lisp :results none :tangle termux.el
(defun cce/compile-termux (arg)
"When ARG is non-nil, byte-compile and install that to init.elc"
(interactive "P")
(let ((modules (cce/module-list))
(cce-dynamic-init (concat cce-directory "/termux.init.el"))
(building-for-termux t))
(cce/generate-dynamic-ansible modules)
(cce/generate-dynamic-init modules)
(when arg
(copy-file "~/org/cce/termux.init.el" "~/.emacs.d/init.el" t t))))
#+end_src
* Build Ansible
The Termux also has its own CCE Ansible file:
#+begin_src yaml :tangle termux.yml
- name: install cce on termux
hosts: termux
vars:
local_account: 'u0_a104'
needs_become_deescalate: no
roles:
- base
- endpoint
post_tasks:
- name: install init.el
copy:
src: ~/org/cce/termux.init.el
dest: ~/.emacs.d/init.el
tags:
- post
- emacs
- name: install init.elc
copy:
src: ~/org/cce/termux.init.elc
dest: ~/.emacs.d/init.elc
tags:
- post
- emacs
- name: install termux-url-opener
copy:
src: ~/org/cce/termux-url-opener
dest: ~/bin/termux-url-opener
mode: 0755
tags:
- termux
- name: jq install
shell:
cmd: "pkg install -y {{item}}"
creates: /data/data/com.termux/files/usr/bin/jq
loop:
- jq
- termux-api
tags:
- termux
#+end_src
#+begin_src shell :shebang #!/bin/sh :tangle termux.shell
test -f /usr/bin/dnf && sudo dnf install ansible python3-libselinux
test -f /usr/bin/apt && sudo apt install ansible
pushd $(dirname $0)
ansible-playbook -i inventory termux.yml $@
popd
#+end_src
* [[id:cce/emacs][Emacs]] as "user init"
i need [[id:cce/syncthing][Syncthing]] running on boot, but dont have systemd, so here we go:
#+begin_src emacs-lisp :tangle termux.el :results none
(defun cce/start-syncthing ()
(interactive)
(cce/async-forever "syncthing" "*syncthing*"))
(add-hook 'after-cce-hook #'cce/start-syncthing)
#+end_src
* Sharing URLs to [[id:cce/org-roam][org-roam]]
[[https://wiki.termux.com/wiki/Intents_and_Hooks][Intents and Hooks]] on the Termux wiki explains how file and URL sharing in to termux work.
=~/bin/termux-file-editor= should probably attach the file to an [[id:2471af46-8f8d-470c-97f2-f5d3fbec65a3][org-journal]] entry; this may require some significant effort?
=~/bin/termux-url-opener= doesn't ingest the title and other text, perhaps, which is frustrating?? maybe AutoShare will do better.
#+begin_src shell :tangle termux-url-opener :shebang #!/bin/bash
TITLE=$(termux-dialog -t "Enter Title" | jq -r '@uri "\(.text)"')
URI=$(echo '"'$1'"' | jq -r '@uri "\(.)"')
echo emacsclient -nqu "org-protocol://roam-ref?template=r&ref=$URI&title=$TITLE"
emacsclient -nqu "org-protocol://roam-ref?template=r&ref=$URI&title=$TITLE"
#+end_src
It's installed above because org strips the whitespace...
this shims =termux-api= and [[id:cce/org_protocol][org-protocol]] together.
I'd really like to be able to capture from Tasker, and eventually make voice notes that way on the go.
* IMAP over SSH for [[id:cce/gnus][Gnus]]
Termux doesn't include an IMAP daemon, so my [[id:fa7e9d10-a98d-4036-a668-889bd1d3ea29][offlineimap]] setup won't work. Instead, I will SSH directly to fontkeming and use, which means that I cannot read my mail/feeds while offline. Oh well.
#+begin_src shell :tangle termux-imap-tunnel :shebang #!/bin/bash
ssh -q fontkeming.fail '/usr/libexec/dovecot/imap'
#+end_src
#+begin_src yaml :tangle termux.yml
- name: imap tunnel installed
copy:
src: termux-imap-tunnel
dest: /data/data/com.termux/files/home/bin/imap
tags:
- termux
#+end_src
* Taks Map
** DONE get =ansible -m setup= working with ssh to the termux
:PROPERTIES:
:ID: aa358567-d9a9-42f2-a477-d99cdd821682
:END:
- State "DONE" from "NEXT" [2020-06-25 Thu 15:55]
:LOGBOOK:
CLOCK: [2020-06-25 Thu 15:27]--[2020-06-25 Thu 15:55] => 0:28
:END:
#+begin_src shell
pkg upgrade
pkg install -y python openssh rsync python-apt
#+end_src
this gets ansible working:
#+begin_src
[WARNING]: Platform linux on host cosmo is using the discovered Python interpreter at /data/data/com.termux/files/usr/bin/python,
but future installation of another Python interpreter could change this. See
https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information.
cosmo | SUCCESS => {
"ansible_facts": {
"ansible_all_ipv4_addresses": [],
"ansible_all_ipv6_addresses": [],
"ansible_apparmor": {
"status": "disabled"
},
"ansible_architecture": "aarch64",
"ansible_date_time": {
"date": "2020-06-25",
"day": "25",
"epoch": "1593124720",
"hour": "15",
"iso8601": "2020-06-25T22:38:40Z",
"iso8601_basic": "20200625T153840911190",
"iso8601_basic_short": "20200625T153840",
"iso8601_micro": "2020-06-25T22:38:40.911442Z",
"minute": "38",
"month": "06",
"second": "40",
"time": "15:38:40",
"tz": "PDT",
"tz_offset": "-0700",
"weekday": "Thursday",
"weekday_number": "4",
"weeknumber": "25",
"year": "2020"
},
"ansible_default_ipv4": {
"address": "10.10.10.12",
"interface": "tun0"
},
"ansible_default_ipv6": {},
"ansible_distribution": "OtherLinux",
"ansible_distribution_major_version": "NA",
"ansible_distribution_release": "NA",
"ansible_distribution_version": "NA",
"ansible_dns": {},
"ansible_domain": "",
"ansible_effective_group_id": 10104,
"ansible_effective_user_id": 10104,
"ansible_env": {
"ANDROID_DATA": "/data",
"ANDROID_ROOT": "/system",
"BOOTCLASSPATH": "/system/framework/core-oj.jar:/system/framework/core-libart.jar:/system/framework/conscrypt.jar:/system/framework/okhttp.jar:/system/framework/bouncycastle.jar:/system/framework/apache-xml.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/telephony-common.jar:/system/framework/voip-common.jar:/system/framework/ims-common.jar:/system/framework/android.hidl.base-V1.0-java.jar:/system/framework/android.hidl.manager-V1.0-java.jar:/system/framework/framework-oahl-backward-compatibility.jar:/system/framework/android.test.base.jar:/system/framework/mediatek-common.jar:/system/framework/mediatek-framework.jar:/system/framework/mediatek-telephony-common.jar:/system/framework/mediatek-telephony-base.jar:/system/framework/mediatek-ims-common.jar:/system/framework/mediatek-telecom-common.jar",
"EXTERNAL_STORAGE": "/sdcard",
"HOME": "/data/data/com.termux/files/home",
"LANG": "en_US.UTF-8",
"LD_PRELOAD": "/data/data/com.termux/files/usr/lib/libtermux-exec.so",
"LOGNAME": "u0_a104",
"PATH": "/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets",
"PREFIX": "/data/data/com.termux/files/usr",
"PWD": "/data/data/com.termux/files/home",
"SHELL": "/data/data/com.termux/files/usr/bin/bash",
"SHLVL": "0",
"SSH_AUTH_SOCK": "/data/data/com.termux/files/usr/tmp/ssh-jkJY1kghQh/agent.19439",
"SSH_CLIENT": "192.168.0.44 44058 8022",
"SSH_CONNECTION": "192.168.0.44 44058 192.168.0.90 8022",
"SSH_TTY": "/dev/pts/29",
"TERM": "dumb",
"TMPDIR": "/data/data/com.termux/files/usr/tmp",
"USER": "u0_a104",
"_": "/bin/sh"
},
"ansible_fibre_channel_wwn": [],
"ansible_fips": false,
"ansible_fqdn": "localhost",
"ansible_hostname": "localhost",
"ansible_hostnqn": "",
"ansible_interfaces": [],
"ansible_is_chroot": false,
"ansible_iscsi_iqn": "",
"ansible_kernel": "4.4.146",
"ansible_kernel_version": "#2 SMP PREEMPT Wed Jun 17 16:50:14 CST 2020",
"ansible_local": {},
"ansible_lsb": {},
"ansible_machine": "aarch64",
"ansible_nodename": "localhost",
"ansible_os_family": "OtherLinux",
"ansible_pkg_mgr": "unknown",
"ansible_python": {
"executable": "/data/data/com.termux/files/usr/bin/python",
"has_sslcontext": true,
"type": "cpython",
"version": {
"major": 3,
"micro": 3,
"minor": 8,
"releaselevel": "final",
"serial": 0
},
"version_info": [
3,
8,
3,
"final",
0
]
},
"ansible_python_version": "3.8.3",
"ansible_real_group_id": 10104,
"ansible_real_user_id": 10104,
"ansible_selinux": {
"status": "Missing selinux Python library"
},
"ansible_selinux_python_present": false,
"ansible_service_mgr": "service",
"ansible_system": "Linux",
"ansible_user_dir": "/data",
"ansible_user_gecos": null,
"ansible_user_gid": 10104,
"ansible_user_id": "u0_a104",
"ansible_user_shell": "/system/bin/sh",
"ansible_user_uid": 10104,
"ansible_userspace_bits": "64",
"ansible_virtualization_role": "NA",
"ansible_virtualization_type": "NA",
"discovered_interpreter_python": "/data/data/com.termux/files/usr/bin/python",
"gather_subset": [
"all"
],
"module_setup": true
},
"changed": false
}
#+end_src
So checking for ="ANDROID_DATA" "/data"= in environment is probably the best check for runtime.
Have to edit ansible code to detect apt in termux [[file:/sudo:root@localhost:/usr/lib/python3.7/site-packages/ansible/module_utils/facts/system/pkg_mgr.py::{'path': '/usr/bin/apt-get', 'name': 'apt'},][here]].
#+begin_src python
{'path': '/data/data/com.termux/files/usr/bin/apt', 'name': 'apt'}
#+end_src
This was a red-herring as python-apt isn't available in termux. package availability may be the limiting issue here.
** DONE get =cce/cce.shell= working with ssh to the termux as =cce/cce-termux.shell=
- State "DONE" from "NEXT" [2020-06-25 Thu 17:05]
:LOGBOOK:
CLOCK: [2020-06-25 Thu 15:59]--[2020-06-25 Thu 17:05] => 1:06
:END:
** NEXT document sshd setup in termux
** DONE write =cce/using-termux= predicate function
- State "DONE" from "INPROGRESS" [2020-06-25 Thu 17:22]
- State "INPROGRESS" from "NEXT" [2020-06-25 Thu 17:22]
:LOGBOOK:
CLOCK: [2020-06-25 Thu 17:05]--[2020-06-25 Thu 17:22] => 0:17
:END:
This predicate function should be applied on things that I *don't* want installed, probably =(not (cce/using-termux))= is added to each that I don't like.
** DONE include =cce/using-termux= predicate exclusions for programming and whatnot
- State "DONE" from "NEXT" [2020-06-25 Thu 17:46]
:LOGBOOK:
CLOCK: [2020-06-25 Thu 17:22]--[2020-06-25 Thu 17:46] => 0:24
:END:
** DONE function to write termux =init.el= and =main.yml=
- State "DONE" from "NEXT" [2020-06-25 Thu 21:58]
** DONE cce-as-init for termux processes
- State "DONE" from "NEXT" [2020-06-26 Fri 16:04]
** INPROGRESS =intents= and =termux-tasker= integrations
- State "INPROGRESS" from "DONE" [2020-07-09 Thu 16:45]
- State "DONE" from "NEXT" [2020-07-09 Thu 16:45]