complete-computing-environment/termux_platform_support.org

27 KiB
Raw Permalink Blame History

CCE on Termux

,#+ARROYO_EMACS_MODULE: termux ,#+ARROYO_MODULE_WANTS: cce/async_forever.org

The 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 CCE for Programming Lisp in Emacs and my org-roam stack. I use the new CCE Dynamic Loader and a (cce/using-termux) predicate to toggle things off for this environment.

Here are the modules which are included:

00 Configure Packaging packaging cce/packaging
01 Emacs Persistent Scratch cce/persistent-scratch
01 Effective Emacs Marking cce/mark
01 Running Things in Emacs Forever cce/async-forever
01 Flowing Keybindings with Hydra cce/hydra-base
01 Emacs Session Startup cce/startup
01 Evil Mode Vim in Emacs cce/evil-mode
10 Themeing my Emacs cce/appearance
10 Emacs Dashboard cce/dashboard
10 Window Management in Emacs cce/window-management
10 Emacs "Launcher" Hydra cce/hydra-launcher
10 Clean Buffers at a Regular Interval with Midnight Mode cce/midnight-mode
10 Dired File Manager cce/dired
10 Smarter Emacs Help cce/hydra-help
10 Undo and Redo with a tree cce/undo-tree
10 Emacs Control Via Ivy cce/ivy-config
10 Moving Through Text with Emacs cce/text-navigation
10 Doom Modeline cce/doom-modeline
10 Hydra Dipswitches cce/hydra-dipswitch
10 Editing Privileged Files with sudo-edit cce/sudo-edit
10 Focused Text Editing cce/focused-mode
10 Text Editing Fundamental Opinions cce/text-editing
15 Spell-checking with Flyspell Mode cce/flyspell
18 Toggle Bright/Dark Theme in Emacs, KDE and FireFox cce/toggle-theme
20 use PodMan for local container builds podman cce/
20 Japanese Text Input in Emacs cce/japanese-input
20 defdaily cce/defdaily
30 My "Now Playing" on Fediverse cce/
30 SSH Configuration cce/ssh
30 Nearly Stateless Computing Using Syncthing syncthing cce/
30 GnuPG Configuration gnupg cce/gnupg
30 Keyboardio Atreus atreus cce/
30 Using Pass for Passwords pass cce/pass
30 Deadgrep is a Great Grep Interface cce/deadgrep
31 Sitelen Pona Pona sitelen-pona-pona cce/sitelen-pona-pona
40 Emacs Shell-Mode is Good Enough cce/shell-mode
40 Use Emacs as a Pager emacs-pager cce/emacs-pager
40 Org Mode Installation cce/org-mode
40 Emacs vterm Mode cce/vterm
41 Org Tagging Principles cce/org-tagging
41 Some Thoughts on Time Tracking cce/org-time-tracking
41 org-roam org-roam cce/org-roam
41 Project Work with Org Mode cce/org-tasks
41 My Org-mode Agendas cce/org-agenda
41 Extracting Org Roam Headings cce/org-roam-extract
41 Capturing Tasks cce/org-capture
41 Project Management in Org Mode cce/org-projects
42 Mood Log cce/mood-log
42 Org Mode Postscript Source Blocks postscript-programming cce/postscript-programming
42 Journal cce/journal
43 Spaced Repetition Study cce/org-fc
45 publicimageltd/delve: Delve into your org-roam zettelkasten. cce/delve
45 Quickly Rename Captured Zettel Files cce/org-roam-rename-file
45 org-download cce/org-download
45 Embed CSS in Org-Mode HTML Exports cce/org-html-css
48 org-caldav cce/org-caldav
49 Finding Broken Knowledge Base Links cce/org-roam-sbl
60 Surfing Through Codebases cce/code-surf
60 Basic Emacs Coding Config code-base cce/code-base
60 Code Formatting, Aggressively cce/aggressive-indent
60 Navigating Projects With Projectile cce/projectile
60 Company Code Completion cce/company
60 Git in Emacs with Magit git cce/magit
60 Literate Programming with Org Babel cce/literate-programming
60 CCE Nixos Core nixos cce/nixos
61 Smart Snippet Templates with Yasnippet cce/yasnippet
61 Ediff Configuration cce/ediff-config
62 Programming Lisp in Emacs cce/lisp-core
62 karlicoss - Human Programming Interface hpi cce/
63 Extracting notes from Kobo Aura One hpi-kobo cce/
70 Ansible Bender ansible-bender cce/
70 CCE Dynamic Loader cce/cce-loader
70 Gnus gnus cce/gnus
70 mbsync for local mail storage mbsync cce/mbsync
71 Gnus Evil Mode cce/gnus-evil-mode
71 Sending Mail in Gnus msmtp cce/msmtp
71 Gnus Task Tracking cce/gnus-org-integration
71 Gnus Adaptive Scoring cce/gnus-adaptive
80 Japanese Study cce/japanese-study
90 Therapy Notes and Work cce/therapy-notes
Meditation Log cce/meditation-log
Monthly Review cce/monthly-review
90 Emacs SQLite3 Installation emacs-sqlite3 cce/emacs-sqlite3
90 Shared CCE Helpers cce/cce-common
Decision Log cce/decision-log
Weekly Review cce/weekly-review
Deploying the Arcology cce/
Tea Practice cce/tea-practice
99 Run Hooks After init cce/run-hooks
99 CCE on Termux cce/termux
t 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

(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))))

Build Ansible

The Termux also has its own CCE Ansible file:

- 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
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

Emacs as "user init"

i need Syncthing running on boot, but dont have systemd, so here we go:

(defun cce/start-syncthing ()
  (interactive)
  (cce/async-forever "syncthing" "*syncthing*"))
(add-hook 'after-cce-hook #'cce/start-syncthing)

Sharing URLs to org-roam

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 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.

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"

It's installed above because org strips the whitespace…

this shims termux-api and 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 Gnus

Termux doesn't include an IMAP daemon, so my 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.

ssh -q fontkeming.fail '/usr/libexec/dovecot/imap'
  - name: imap tunnel installed
    copy:
      src: termux-imap-tunnel
      dest: /data/data/com.termux/files/home/bin/imap
    tags:
    - termux

Taks Map

DONE get ansible -m setup working with ssh to the termux

  • State "DONE" from "NEXT" [2020-06-25 Thu 15:55]

CLOCK: [2020-06-25 Thu 15:27][2020-06-25 Thu 15:55] => 0:28

pkg upgrade
pkg install -y python openssh rsync python-apt

this gets ansible working:

[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
}

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 here.

{'path': '/data/data/com.termux/files/usr/bin/apt', 'name': 'apt'}

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]

CLOCK: [2020-06-25 Thu 15:59][2020-06-25 Thu 17:05] => 1:06

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]

CLOCK: [2020-06-25 Thu 17:05][2020-06-25 Thu 17:22] => 0:17

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]

CLOCK: [2020-06-25 Thu 17:22][2020-06-25 Thu 17:46] => 0:24

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]