From 9ac94c39670da168de60daedbd77da029ad4a7fb Mon Sep 17 00:00:00 2001 From: SqrtMinusOne Date: Sat, 31 Jul 2021 16:28:25 +0300 Subject: [PATCH] feat(console): attempt to make Android work --- .config/guix/manifests/console.scm | 1 + .profile | 40 +++++++++++++++++--------- Console.org | 46 +++++++++++++++++++----------- 3 files changed, 58 insertions(+), 29 deletions(-) diff --git a/.config/guix/manifests/console.scm b/.config/guix/manifests/console.scm index df71c5e..6aa24ae 100644 --- a/.config/guix/manifests/console.scm +++ b/.config/guix/manifests/console.scm @@ -1,5 +1,6 @@ (specifications->manifest '( + "jmtpfs" "unzip" "password-store" "p7zip" diff --git a/.profile b/.profile index 86305a2..e204e16 100644 --- a/.profile +++ b/.profile @@ -6,6 +6,12 @@ export QT_AUTO_SCREEN_SCALE_FACTOR=0 # export GTK2_RC_FILES="$HOME/.gtkrc-2.0" # Environment:1 ends here +# [[file:Console.org::*Android][Android:1]] +if [ "$HOME" != "${HOME%"com.termux"*}" ]; then + export IS_ANDROID=true +fi +# Android:1 ends here + # [[file:Console.org::*My paths][My paths:1]] if [ -d "$HOME/bin" ] ; then export PATH="$HOME/bin:$PATH" @@ -14,16 +20,18 @@ fi # My paths:1 ends here # [[file:Console.org::*Guix settings][Guix settings:1]] -GUIX_EXTRA_PROFILES=$HOME/.guix-extra-profiles -for i in $GUIX_EXTRA_PROFILES/*; do - profile=$i/$(basename "$i") - if [ -f "$profile"/etc/profile ]; then - GUIX_PROFILE="$profile" - . "$GUIX_PROFILE"/etc/profile - fi - export XDG_DATA_DIRS="$XDG_DATA_DIRS:$profile/share" - unset profile -done +if [ -z "$IS_ANDROID" ]; then + GUIX_EXTRA_PROFILES=$HOME/.guix-extra-profiles + for i in $GUIX_EXTRA_PROFILES/*; do + profile=$i/$(basename "$i") + if [ -f "$profile"/etc/profile ]; then + GUIX_PROFILE="$profile" + . "$GUIX_PROFILE"/etc/profile + fi + export XDG_DATA_DIRS="$XDG_DATA_DIRS:$profile/share" + unset profile + done +fi # Guix settings:1 ends here # [[file:Console.org::*Guix settings][Guix settings:2]] @@ -35,7 +43,9 @@ export GUIX_PACKAGE_PATH=~/guix-packages # Guix settings:3 ends here # [[file:Console.org::*Other package managers][Other package managers:1]] -export XDG_DATA_DIRS="$XDG_DATA_DIRS:$HOME/.local/share/flatpak/exports/share" +if [ -d "$HOME/.local/share/flatpak" ]; then + export XDG_DATA_DIRS="$XDG_DATA_DIRS:$HOME/.local/share/flatpak/exports/share" +fi # Other package managers:1 ends here # [[file:Console.org::*Other package managers][Other package managers:2]] @@ -51,7 +61,9 @@ fi # Other package managers:3 ends here # [[file:Console.org::*Other package managers][Other package managers:4]] -export XDG_DATA_DIRS="$XDG_DATA_DIRS:$HOME/.nix-profile/share/applications" +if [ -d "$HOME/.nix-profile" ]; then + export XDG_DATA_DIRS="$XDG_DATA_DIRS:$HOME/.nix-profile/share/applications" +fi # Other package managers:4 ends here # [[file:Console.org::*npm][npm:2]] @@ -66,5 +78,7 @@ export MANPATH="${MANPATH-$(manpath)}:$NPM_PACKAGES/share/man" # npm:3 ends here # [[file:Console.org::*XResources][XResources:1]] -xrdb ~/.Xresources +if [ -z "$IS_ANDROID" ]; then + xrdb ~/.Xresources +fi # XResources:1 ends here diff --git a/Console.org b/Console.org index ef64804..c067d89 100644 --- a/Console.org +++ b/Console.org @@ -56,6 +56,14 @@ export QT_QPA_PLATFORMTHEME="qt5ct" export QT_AUTO_SCREEN_SCALE_FACTOR=0 # export GTK2_RC_FILES="$HOME/.gtkrc-2.0" #+end_src +** Android +Check if =.profile= is being run from Android. If so, set a variable. + +#+begin_src sh +if [ "$HOME" != "${HOME%"com.termux"*}" ]; then + export IS_ANDROID=true +fi +#+end_src ** My paths My script folders #+begin_src sh @@ -69,16 +77,18 @@ fi Enable extra profiles #+begin_src sh -GUIX_EXTRA_PROFILES=$HOME/.guix-extra-profiles -for i in $GUIX_EXTRA_PROFILES/*; do - profile=$i/$(basename "$i") - if [ -f "$profile"/etc/profile ]; then - GUIX_PROFILE="$profile" - . "$GUIX_PROFILE"/etc/profile - fi - export XDG_DATA_DIRS="$XDG_DATA_DIRS:$profile/share" - unset profile -done +if [ -z "$IS_ANDROID" ]; then + GUIX_EXTRA_PROFILES=$HOME/.guix-extra-profiles + for i in $GUIX_EXTRA_PROFILES/*; do + profile=$i/$(basename "$i") + if [ -f "$profile"/etc/profile ]; then + GUIX_PROFILE="$profile" + . "$GUIX_PROFILE"/etc/profile + fi + export XDG_DATA_DIRS="$XDG_DATA_DIRS:$profile/share" + unset profile + done +fi #+end_src Set Jupyter config PATH. It defaults to readonly directory somewhere in Guix profile. @@ -95,7 +105,9 @@ Using other package managers with Guix requires some extra work. Make flatpak apps visible to launchers: #+begin_src sh -export XDG_DATA_DIRS="$XDG_DATA_DIRS:$HOME/.local/share/flatpak/exports/share" +if [ -d "$HOME/.local/share/flatpak" ]; then + export XDG_DATA_DIRS="$XDG_DATA_DIRS:$HOME/.local/share/flatpak/exports/share" +fi #+end_src Enable Nix @@ -114,7 +126,9 @@ fi Make nix apps visible to launchers: #+begin_src sh -export XDG_DATA_DIRS="$XDG_DATA_DIRS:$HOME/.nix-profile/share/applications" +if [ -d "$HOME/.nix-profile" ]; then + export XDG_DATA_DIRS="$XDG_DATA_DIRS:$HOME/.nix-profile/share/applications" +fi #+end_src *** npm @@ -146,7 +160,9 @@ export MANPATH="${MANPATH-$(manpath)}:$NPM_PACKAGES/share/man" | xrdb | #+begin_src sh -xrdb ~/.Xresources +if [ -z "$IS_ANDROID" ]; then + xrdb ~/.Xresources +fi #+end_src ** OFF (OFF) Package manager paths Turned off for now, because probably it won't be necessary in Guix. @@ -791,10 +807,8 @@ key_bindings: | p7zip | archiver | | password-store | CLI password manager | | unzip | | +| jmtpfs | A tool to mount MTP devices (e.g. Android) | -| Note | Description | -|------+-----------------| -| TODO | package fselect | * Misc scripts ** =nt= - exec command with a finished notification Usage: