<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>glow.li: Tutorial</title>
        <description>A blog by glow.</description>
        <link>https://glow.li/tags/tutorial.xml</link>
        <atom:link href="https://glow.li/tags/tutorial.xml" rel="self" type="application/rss+xml"/>
        <generator>Glow.li Builder</generator>
            <item>
        <title>Encrypt Termux filesystem with LUKS</title>
        <description>&lt;p&gt;&lt;a href="https://glow.li/media/images/big/encrypt-termux-fs-screenshot.webp?chash=Iebu8564ff" class="size-half"&gt;&lt;img src="https://glow.li/media/images/encrypt-termux-fs-screenshot.webp?chash=Iebu87aa2c" alt="Screenshot of Termux running the script in this tutorial" title="Screenshot of Termux running the script in this tutorial" class="right size-half" loading="lazy" sizes="(max-width:703px) 100vw, 750px" srcset="https://glow.li/media/images/encrypt-termux-fs-screenshot.webp?chash=Iebu87aa2c 1500w, https://glow.li/media/images/1200/encrypt-termux-fs-screenshot.webp?chash=Iebu841cbc 1200w, https://glow.li/media/images/1000/encrypt-termux-fs-screenshot.webp?chash=Iebu84a977 1000w, https://glow.li/media/images/800/encrypt-termux-fs-screenshot.webp?chash=Iebu83c651 800w, https://glow.li/media/images/700/encrypt-termux-fs-screenshot.webp?chash=Iebu88e85c 700w, https://glow.li/media/images/600/encrypt-termux-fs-screenshot.webp?chash=Iebu8f2135 600w, https://glow.li/media/images/500/encrypt-termux-fs-screenshot.webp?chash=Iebu85189b 500w, https://glow.li/media/images/400/encrypt-termux-fs-screenshot.webp?chash=Iebu8ff084 400w, https://glow.li/media/images/300/encrypt-termux-fs-screenshot.webp?chash=Iebu838b19 300w, https://glow.li/media/images/200/encrypt-termux-fs-screenshot.webp?chash=Iebu811838 200w, https://glow.li/media/images/100/encrypt-termux-fs-screenshot.webp?chash=Iebu861214 100w" &gt;&lt;/a&gt;
People sometimes store sensitive information within &lt;a href="https://termux.com"&gt;Termux&lt;/a&gt;, like SSH Keys or PGP Keys. Within Android, this is fairly secure. No other app can access the Termux storage without explicit user consent. But our phones aren't secure devices for most people. Most people have a really short pin or password (or even none at all). So if our devices get stolen or seized, this data can easily be extracted. This short tutorial will show you a way to encrypt the whole Termux filesystem, so this data cannot be extracted once the phone has turned off or the filesystem is unmounted and closed again.&lt;/p&gt;
&lt;div id="toc"&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href="#Procedure"&gt;Procedure&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#Requirements"&gt;Requirements&lt;/a&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href="#Rooted+phone"&gt;Rooted phone&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#Blank+Termux"&gt;Blank Termux&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#Packages"&gt;Packages&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="#Create+filesystem"&gt;Create filesystem&lt;/a&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href="#Step+1%3A+Create+a+blank+image+file"&gt;Step 1: Create a blank image file&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#Step+2%3A+Encrypt+image+file+using+LUKS"&gt;Step 2: Encrypt image file using LUKS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#Step+3%3A+Temporarily+open+image+file"&gt;Step 3: Temporarily open image file&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#Step+4%3A+Format+the+image+file"&gt;Step 4: Format the image file&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#Step+5%3A+Close+the+image+file+again"&gt;Step 5: Close the image file again&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="#Entering+the+encrypted+Termux"&gt;Entering the encrypted Termux&lt;/a&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href="#Find+your+su+binary"&gt;Find your su binary&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="#Restore+your+existing+installation"&gt;Restore your existing installation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#Unmounting+your+filesystem"&gt;Unmounting your filesystem&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#Accessing+your+unencrypted+Termux+while+in+the+encrypted+environment"&gt;Accessing your unencrypted Termux while in the encrypted environment&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#Caveats"&gt;Caveats&lt;/a&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href="#Termux%3ATasker"&gt;Termux:Tasker&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#SELinux"&gt;SELinux&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
&lt;h3 id="Procedure" name="Procedure"&gt;&lt;a class="hash-link" href="#Procedure"&gt;Procedure&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;We're creating a separate filesystem in an encrypted image file, which we're then mounting at &lt;code&gt;/data/data/com.termux/files&lt;/code&gt;, which contains all of Termux' data.&lt;/p&gt;
&lt;h3 id="Requirements" name="Requirements"&gt;&lt;a class="hash-link" href="#Requirements"&gt;Requirements&lt;/a&gt;&lt;/h3&gt;
&lt;h4 id="Rooted+phone" name="Rooted+phone"&gt;&lt;a class="hash-link" href="#Rooted+phone"&gt;Rooted phone&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Unfortunately, this only works with a rooted device, as you need access to cryptsetup and mount&lt;/p&gt;
&lt;h4 id="Blank+Termux" name="Blank+Termux"&gt;&lt;a class="hash-link" href="#Blank+Termux"&gt;Blank Termux&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;It is recommended to start out with a freshly installed Termux. This is the host Termux, that will only be used to mount the encrypted Termux. You can do it on an existing Termux installation, but be aware that all data that is already in your Termux installation, will not be encrypted. If you want encrypt an existing installation you need to make a backup of it now and then reset your Termux.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;rsync -a /data/data/com.termux/files /data/data/com.termux/files-backup&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Make sure to delete this backup at the end.&lt;/p&gt;
&lt;p&gt;After that you can delete &lt;code&gt;/data/data/com.termux/files&lt;/code&gt; to reset your Termux (restart after doing so). Beware that this will delete all your files. Make sure you've backed them up.&lt;/p&gt;
&lt;h4 id="Packages" name="Packages"&gt;&lt;a class="hash-link" href="#Packages"&gt;Packages&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Install the root repo:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;pkg install root-repo&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Install required packages:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;pkg install util-linux cryptsetup tsu e2fsprogs rsync&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id="Create+filesystem" name="Create+filesystem"&gt;&lt;a class="hash-link" href="#Create+filesystem"&gt;Create filesystem&lt;/a&gt;&lt;/h3&gt;
&lt;h4 id="Step+1%3A+Create+a+blank+image+file" name="Step+1%3A+Create+a+blank+image+file"&gt;&lt;a class="hash-link" href="#Step+1%3A+Create+a+blank+image+file"&gt;Step 1: Create a blank image file&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;To create an encrypted filesystem you need to first create a blank '.img' file. Adjust the size to your preference. Beware that it will use up this space on your device instantly.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;fallocate -l 16G /data/data/com.termux/termux-fs.img&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id="Step+2%3A+Encrypt+image+file+using+LUKS" name="Step+2%3A+Encrypt+image+file+using+LUKS"&gt;&lt;a class="hash-link" href="#Step+2%3A+Encrypt+image+file+using+LUKS"&gt;Step 2: Encrypt image file using LUKS&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Next we are encrypting this '.img' using &lt;a href="https://en.wikipedia.org/wiki/Linux_Unified_Key_Setup"&gt;LUKS&lt;/a&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sudo cryptsetup luksFormat /data/data/com.termux/termux-fs.img&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Answer the first prompt with &lt;code&gt;YES&lt;/code&gt; and then enter a passphrase twice:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;
WARNING!
========
This will overwrite data on /data/data/com.termux/termux-fs.img irrevocably.

Are you sure? (Type 'yes' in capital letters): YES
Enter passphrase for /data/data/com.termux/termux-fs.img:
Verify passphrase:&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id="Step+3%3A+Temporarily+open+image+file" name="Step+3%3A+Temporarily+open+image+file"&gt;&lt;a class="hash-link" href="#Step+3%3A+Temporarily+open+image+file"&gt;Step 3: Temporarily open image file&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;To format the image file we need to temporarily open it.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sudo cryptsetup open /data/data/com.termux/termux-fs.img termux-fs-tmp&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You will be prompted to enter your passphrase&lt;/p&gt;
&lt;h4 id="Step+4%3A+Format+the+image+file" name="Step+4%3A+Format+the+image+file"&gt;&lt;a class="hash-link" href="#Step+4%3A+Format+the+image+file"&gt;Step 4: Format the image file&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Create a ext4 filesystem inside the encrypted volume.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sudo mkfs.ext4 /dev/mapper/termux-fs-tmp&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id="Step+5%3A+Close+the+image+file+again" name="Step+5%3A+Close+the+image+file+again"&gt;&lt;a class="hash-link" href="#Step+5%3A+Close+the+image+file+again"&gt;Step 5: Close the image file again&lt;/a&gt;&lt;/h4&gt;
&lt;pre&gt;&lt;code&gt;sudo cryptsetup close termux-fs-tmp&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id="Entering+the+encrypted+Termux" name="Entering+the+encrypted+Termux"&gt;&lt;a class="hash-link" href="#Entering+the+encrypted+Termux"&gt;Entering the encrypted Termux&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Now that we created the encrypted disk we simply need to mount it. Since we need to do this every time we boot our device, it's best we create a script for that.
Use &lt;a href="https://glow.li/media/files/termuxmount.sh"&gt;this script&lt;/a&gt; to enter your new filesystem:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#!/usr/bin/env bash
u=$(whoami)
export LD_PRELOAD=
/sbin/su -c "cryptsetup luksOpen /data/data/com.termux/termux-fs.img termux-fs"
/sbin/su -c "mount /dev/mapper/termux-fs /data/data/com.termux/files"
/sbin/su -c "/system/bin/chown $u.$u /data/data/com.termux/files"&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You will be prompted your passphrase.
This will mount your filesystem to &lt;code&gt;/data/data/com.termux/files&lt;/code&gt;.
After you've run this script, exit your Termux App and open it again. The first time you do this the Termux App will reinstall your base system inside your encrypted dist.&lt;/p&gt;
&lt;p&gt;Congratulations you are now in your encrypted filesystem. You will need to run this script again after a restart.&lt;/p&gt;
&lt;h4 id="Find+your+su+binary" name="Find+your+su+binary"&gt;&lt;a class="hash-link" href="#Find+your+su+binary"&gt;Find your su binary&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Since mounting a filesystem at &lt;code&gt;/data/data/com.termux/files&lt;/code&gt; will cause all Termux command to temporarily break, we need to make sure we're not running any Termux commands in this script. Therefore you need to specify your su binary with an absolute path. In most cases this is &lt;code&gt;/sbin/su&lt;/code&gt;, so you can use the script as is. If your &lt;code&gt;su&lt;/code&gt; is somewhere else, check these paths and replace the command in the script accordingly:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;/sbin/su&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;/system/sbin/su&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;/system/bin/su&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;/system/xbin/su&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;/su/bin/su&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;/magisk/.core/bin/su&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="Restore+your+existing+installation" name="Restore+your+existing+installation"&gt;&lt;a class="hash-link" href="#Restore+your+existing+installation"&gt;Restore your existing installation&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;If you've created a backup of your existing installation (described &lt;a href="#Blank+Termux"&gt;here&lt;/a&gt;) you can restore that backup now.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;rsync -a --delete /data/data/com.termux/files-backup/ /data/data/com.termux/files/&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If everything worked, remember to delete this unencrypted backup.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;rm /data/data/com.termux/files-backup -rf&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id="Unmounting+your+filesystem" name="Unmounting+your+filesystem"&gt;&lt;a class="hash-link" href="#Unmounting+your+filesystem"&gt;Unmounting your filesystem&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Unmounting your encrypted Termux is a bit annoying. Since it is always in-use you need to specify (&lt;code&gt;-l&lt;/code&gt;) lazy mode.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sudo umount /data/data/com.termux/files -l&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;After that can restart your Termux again to be in the unencrypted filesystem again. Your encrypted filesystem is still open however, so you need to close it now.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sudo cryptsetup close termux-fs&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If there are any processes still accessing your encrypted Termux, this will fail. You need to either find and close these processes, or restart your device.&lt;/p&gt;
&lt;h3 id="Accessing+your+unencrypted+Termux+while+in+the+encrypted+environment" name="Accessing+your+unencrypted+Termux+while+in+the+encrypted+environment"&gt;&lt;a class="hash-link" href="#Accessing+your+unencrypted+Termux+while+in+the+encrypted+environment"&gt;Accessing your unencrypted Termux while in the encrypted environment&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;It is sometimes necessary to do maintenance (updates for example) on the unencrypted Termux. Unmounting your filesystem is one possibility, but is quite annoying. You can however use &lt;code&gt;unshare&lt;/code&gt; and &lt;code&gt;chroot&lt;/code&gt; to access your unencrypted Termux while the encrypted Termux is still running. I created &lt;a href="https://glow.li/media/files/termuxhost.sh"&gt;this script&lt;/a&gt; to do that:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#!/usr/bin/env bash
OPTIND=1
UNSHARED=false
while getopts ":U" opt; do
    case "$opt" in
        U)
            UNSHARED=true
            ;;
        *) ;;

    esac
done

shift $((OPTIND - 1))
if [ ! "$UNSHARED" == "true" ]; then
    user="$(whoami)"
    vars=""
    vars+=" HOME=$HOME"
    vars+=" PATH=$PREFIX/bin"
    vars+=" PREFIX=$PREFIX"
    vars+=" TMPDIR=$TMPDIR"
    vars+=" SHELL=$PREFIX/bin/login"
    vars+=" exec $PREFIX/bin/login"
    args=""
    if [ -n "$1" ]; then
        args="-c '$@'"
    fi
    $PREFIX/bin/sudo unshare -m $0 -U "$user" "$HOME" "$vars $args"
else
    mount --bind /data/data/com.termux /data/data/com.termux
    user="$1"
    user_home="$2"
    vars="$3"
    cd $user_home
    groups=${user},inet,everybody,${user}_cache,all_$(echo $user | cut -d "_" -f 2)
    exec chroot --skip-chdir --userspec=$user:$user --groups=$groups / sh -c "$vars"
fi&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Running this will drop you inside your unencrypted Termux. Since we used &lt;code&gt;unshare&lt;/code&gt; this only applies to this process. Other sessions remain unaffected. To return to your encrypted Termux simply exit this process.&lt;/p&gt;
&lt;h3 id="Caveats" name="Caveats"&gt;&lt;a class="hash-link" href="#Caveats"&gt;Caveats&lt;/a&gt;&lt;/h3&gt;
&lt;h4 id="Termux%3ATasker" name="Termux%3ATasker"&gt;&lt;a class="hash-link" href="#Termux%3ATasker"&gt;Termux:Tasker&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;If you install the Termux:Tasker add-on, Tasker will not be able to execute the tasks in &lt;code&gt;~/.termux/tasker&lt;/code&gt;, because it checks your for these files in your unencrypted Termux. If you want to use this functionality you need to create blank executable files in your unencrypted Termux with the same name as the ones in your encrypted Termux. It will actually execute the scripts in your encrypted environment.&lt;/p&gt;
&lt;p&gt;I think this is a really interesting bug. I wrote a detailed bug report here: &lt;a href="https://github.com/termux/termux-tasker/issues/45"&gt;https://github.com/termux/termux-tasker/issues/45&lt;/a&gt;&lt;/p&gt;
&lt;h4 id="SELinux" name="SELinux"&gt;&lt;a class="hash-link" href="#SELinux"&gt;SELinux&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;I've run into issues using SELinux. It may be necessary to run this command after mounting:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;/sbin/su -c "/system/bin/restorecon -R /data/data/com.termux/files"&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you run into continuing issues, add this to your mounting script (edit the path to &lt;code&gt;su&lt;/code&gt; as described &lt;a href="#Find+your+su+binary"&gt;here&lt;/a&gt;)&lt;/p&gt;</description>
    <pubDate>Mon, 10 May 2021 00:00:00 +0000</pubDate>
    <link>https://glow.li/posts/encrypt-termux-fs/</link>
    <guid isPermaLink="false">1620604800</guid>
</item>

<item>
        <title>Global push to talk with i3 and pulseaudio</title>
        <description>&lt;p&gt;&lt;a href="https://glow.li/loop/p2t-pavucontrol.webm/"&gt;        &lt;video class="video-autoplay" autoplay loop muted poster="https://glow.li/media/videos/previews/p2t-pavucontrol.webp?chash=Iebu86c7a9"&gt;        &lt;source src="https://glow.li/media/videos/p2t-pavucontrol.webm" type="video/mp4"&gt;        Click to view the video.        &lt;/video&gt;        &lt;/a&gt;
Just in case anyone needs it. I use it for Jitsi, slack, teams, zoom and other browser conference software like that.&lt;/p&gt;
&lt;!--more--&gt;
&lt;h3 id="Find+out+your+microphone+name" name="Find+out+your+microphone+name"&gt;&lt;a class="hash-link" href="#Find+out+your+microphone+name"&gt;Find out your microphone name&lt;/a&gt;&lt;/h3&gt;
&lt;pre&gt;&lt;code&gt;pactl list sources|grep "Name:"&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This will give you a list of available sources. Find the correct name for your preferred microphone.&lt;/p&gt;
&lt;h3 id="Mute+and+unmute+via+command" name="Mute+and+unmute+via+command"&gt;&lt;a class="hash-link" href="#Mute+and+unmute+via+command"&gt;Mute and unmute via command&lt;/a&gt;&lt;/h3&gt;
&lt;pre&gt;&lt;code&gt;# unmute
pactl set-source-mute &amp;lt;MICROPHONE&amp;gt; 0
# mute
pactl set-source-mute &amp;lt;MICROPHONE&amp;gt; 1&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id="Adding+it+as+a+key+binding+to+i3" name="Adding+it+as+a+key+binding+to+i3"&gt;&lt;a class="hash-link" href="#Adding+it+as+a+key+binding+to+i3"&gt;Adding it as a key binding to i3&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Add this to your i3 config:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;bindsym Mod1+space exec --no-startup-id pactl set-source-mute &amp;lt;MICROPHONE&amp;gt; 0
bindsym --release Mod1+space exec --no-startup-id pactl set-source-mute &amp;lt;MICROPHONE&amp;gt; 1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Replace &lt;code&gt;&amp;lt;MICROPHONE&amp;gt;&lt;/code&gt; with your preferred microphone (without &lt;code&gt;&amp;lt;&lt;/code&gt; and &lt;code&gt;&amp;gt;&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;This will add an Alt(Mod1) + Space bar keybind that unmutes the microphone when pressed and mutes when released.&lt;/p&gt;
&lt;p&gt;This is how it is set for my microphone:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;bindsym Mod1+space exec --no-startup-id pactl set-source-mute alsa_input.usb-046d_0825_89361D50-02.analog-mono 0
bindsym --release Mod1+space exec --no-startup-id pactl set-source-mute alsa_input.usb-046d_0825_89361D50-02.analog-mono 1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I also set a 3rd keybinding that just unmutes, but doesn't mute on release. This way I can set it to constantly record.&lt;/p&gt;
&lt;h3 id="Continuous+mode" name="Continuous+mode"&gt;&lt;a class="hash-link" href="#Continuous+mode"&gt;Continuous mode&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;If you want a button to toggle continuous mode (always recording) you can simply set an additional button but without &lt;code&gt;--release&lt;/code&gt;. To undo it you can simply press your other push-to-talk button once.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;bindsym Mod1+space exec --no-startup-id pactl set-source-mute &amp;lt;MICROPHONE&amp;gt; 0&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id="Using+a+mouse+button" name="Using+a+mouse+button"&gt;&lt;a class="hash-link" href="#Using+a+mouse+button"&gt;Using a mouse button&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;I wanted an additional keybinding for my mouse button 9, so I can toggle the microphone with my thumb.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;bindsym --border --whole-window button9 exec --no-startup-id pactl set-source-mute &amp;lt;MICROPHONE&amp;gt; 0
bindsym --border --whole-window --release button9 exec --no-startup-id pactl set-source-mute &amp;lt;MICROPHONE&amp;gt; 1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Unfortunately there is currently an unresolved &lt;a href="https://github.com/i3/i3/issues/3459"&gt;issue&lt;/a&gt; about using &lt;code&gt;--whole-window&lt;/code&gt; and &lt;code&gt;--release&lt;/code&gt; together. For it to work you need to apply &lt;a href="https://github.com/i3/i3/issues/3459#issuecomment-430597197"&gt;this patch&lt;/a&gt; to your i3 before compiling.&lt;/p&gt;
&lt;h3 id="Bonus%3A+Show+microphone+status+with+Scroll+Lock+led" name="Bonus%3A+Show+microphone+status+with+Scroll+Lock+led"&gt;&lt;a class="hash-link" href="#Bonus%3A+Show+microphone+status+with+Scroll+Lock+led"&gt;Bonus: Show microphone status with Scroll Lock led&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;If you use a keyboard with a scroll lock, like me, then you can misuse that led to show you the microphone status. It's mostly useless on Linux anyway.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://glow.li/loop/scroll-lock.mp4/"&gt;        &lt;video class="video-autoplay" autoplay loop muted poster="https://glow.li/media/videos/previews/scroll-lock.webp?chash=Iebu884a57"&gt;        &lt;source src="https://glow.li/media/videos/scroll-lock.mp4" type="video/mp4"&gt;        Click to view the video.        &lt;/video&gt;        &lt;/a&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# enable the led
xset led 3
# disable the led
xset -led 3&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can simply add that to your key bindings as well.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;bindsym Mod1+space exec --no-startup-id "pactl set-source-mute &amp;lt;MICROPHONE&amp;gt; 0;xset led 3"
bindsym --release Mod1+space exec --no-startup-id "pactl set-source-mute &amp;lt;MICROPHONE&amp;gt; 1;xset -led 3"&lt;/code&gt;&lt;/pre&gt;</description>
    <pubDate>Wed, 14 Apr 2021 00:00:00 +0000</pubDate>
    <link>https://glow.li/posts/global-push-to-talk/</link>
    <guid isPermaLink="false">1618358400</guid>
</item>

<item>
        <title>Access Termux via USB</title>
        <description>&lt;p&gt;I've been using &lt;a href="https://glow.li/posts/run-an-ssh-server-on-your-android-with-termux/"&gt;Termux over SSH&lt;/a&gt; for quite a while now. I've always done so over WiFi. This works reasonably well at home, where I control the IP Addresses. In other networks it was more annoying, because I always had to run &lt;code&gt;ifconfig&lt;/code&gt; first, to get my IP. But the big annoyances start when you want to use it in a place that has no WiFi network available. Previously, I used an Android tablet and a keyboard. With this I set up a WiFi direct connection between my phone. It's wonky and sometimes requires to restart both devices before working again, but it works.&lt;/p&gt;
&lt;p&gt;Then I got a laptop. Installed a proper Linux on it and tried to connect to Termux. I tried setting up WiFi Direct. But after an hour or so of messing around &lt;code&gt;wpa_supplicant&lt;/code&gt; I concluded that it's just too much of a hassle. But somewhere in the GitHub issues I came across the mention of connecting to Termux via ADB. The ADB shell is bad. I didn't actually manage to launch Termux programs via the ADB shell, but I heard that it's possible. But, and this is the point of this article, you can create port forwarding via ADB. This means that you can map a local port on your computer to a port on your Android device. Then you can open the 8022 port to access Termux via SSH over USB. This is awesome, when you're on the train, in a coffee shop or otherwise in a place with wonky or nonexistent WiFi.&lt;/p&gt;
&lt;h3 id="Here+is+how+you+do+it" name="Here+is+how+you+do+it"&gt;&lt;a class="hash-link" href="#Here+is+how+you+do+it"&gt;Here is how you do it&lt;/a&gt;&lt;/h3&gt;
&lt;h4 id="1.+You+need+ADB" name="1.+You+need+ADB"&gt;&lt;a class="hash-link" href="#1.+You+need+ADB"&gt;1. You need ADB&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Most operating systems have an ADB package. On my one I was simply able to install it with:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sudo apt install adb&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For other platforms you can check this site &lt;a href="https://www.xda-developers.com/install-adb-windows-macos-linux/"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;h4 id="2.+Create+your+port+forward" name="2.+Create+your+port+forward"&gt;&lt;a class="hash-link" href="#2.+Create+your+port+forward"&gt;2. Create your port forward&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;This part is really simple as well, and that's key. I don't want to do 500 things every time I want to connect to my phone.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;adb forward tcp:8022 tcp:8022&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is really all it takes. The first instance of &lt;code&gt;tcp:8022&lt;/code&gt; is the local port you want to bind the remote port to. The second one is the port from your Android device. Because Termux' SSHD runs on port 8022 by default, this is what you want.&lt;/p&gt;
&lt;h4 id="3.+Connect+to+it" name="3.+Connect+to+it"&gt;&lt;a class="hash-link" href="#3.+Connect+to+it"&gt;3. Connect to it&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Now that your local port is bound to your Android device you can simply connect to localhost on your computer:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ssh localhost -p 8022
#This is were you put the local port
#(ie. the first one)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This will connect you to your SSH Server. If you haven't set this up yet read &lt;a href="https://glow.li/posts/run-an-ssh-server-on-your-android-with-termux/"&gt;this&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;You will need to run the ADB command after every restart or after you've unplugged your device. I set up an alias for myself for the following command sequence:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;adb forward tcp:8022 tcp:8022 &amp;amp;&amp;amp; adb forward tcp:8080 tcp:8080&amp;amp;&amp;amp; ssh localhost -p 8022
# This will also setup the port 8080, which is used by the httpd webserver on termux&lt;/code&gt;&lt;/pre&gt;</description>
    <pubDate>Tue, 20 Sep 2016 00:00:00 +0000</pubDate>
    <link>https://glow.li/posts/access-termux-via-usb/</link>
    <guid isPermaLink="false">1474329600</guid>
</item>

<item>
        <title>Pass variables from Termux to Tasker</title>
        <description>&lt;p&gt;I figured out that you can pass variables from Termux to a Tasker task. This example sets Android's volume to a value specified in Termux.&lt;/p&gt;
&lt;h3 id="Step+1%3A+Creating+the+script" name="Step+1%3A+Creating+the+script"&gt;&lt;a class="hash-link" href="#Step+1%3A+Creating+the+script"&gt;Step 1: Creating the script&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;volume.sh&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#!/data/data/com.termux/files/usr/bin/sh
#am broadcast --user 0 -a net.dinglish.tasker.[task name] -e [variable name] "[value]" &amp;gt; /dev/null
am broadcast --user 0 -a net.dinglish.tasker.volume -e volume "$1" &amp;gt; /dev/null&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id="Step+2%3A+Create+a+Tasker+profile" name="Step+2%3A+Create+a+Tasker+profile"&gt;&lt;a class="hash-link" href="#Step+2%3A+Create+a+Tasker+profile"&gt;Step 2: Create a Tasker profile&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;img src="https://glow.li/media/images/TaskerVolume1.webp?chash=Iebu8e88da" alt="Screenshot" title="Screenshot" class="right size-half" loading="lazy" sizes="(max-width:703px) 100vw, 750px" srcset="https://glow.li/media/images/TaskerVolume1.webp?chash=Iebu8e88da 1500w, https://glow.li/media/images/1200/TaskerVolume1.webp?chash=Iebu8ff9f6 1200w, https://glow.li/media/images/1000/TaskerVolume1.webp?chash=Iebu8ff9f6 1000w, https://glow.li/media/images/800/TaskerVolume1.webp?chash=Iebu8ff9f6 800w, https://glow.li/media/images/700/TaskerVolume1.webp?chash=Iebu87cd63 700w, https://glow.li/media/images/600/TaskerVolume1.webp?chash=Iebu8d6862 600w, https://glow.li/media/images/500/TaskerVolume1.webp?chash=Iebu889ab5 500w, https://glow.li/media/images/400/TaskerVolume1.webp?chash=Iebu8665b2 400w, https://glow.li/media/images/300/TaskerVolume1.webp?chash=Iebu808964 300w, https://glow.li/media/images/200/TaskerVolume1.webp?chash=Iebu89ec3d 200w, https://glow.li/media/images/100/TaskerVolume1.webp?chash=Iebu8264f8 100w" &gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Create a new profile&lt;/li&gt;
&lt;li&gt;Choose "Event"&lt;/li&gt;
&lt;li&gt;In the "Select Event Category" dialog choose "System"-&amp;gt;"Intent Received"&lt;/li&gt;
&lt;li&gt;As Action define &lt;code&gt;net.dinglish.tasker.volume&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This profile will now be called whenever it receives the "volume" intent.&lt;/p&gt;
&lt;h3 id="Step+3%3A+Create+the+Task" name="Step+3%3A+Create+the+Task"&gt;&lt;a class="hash-link" href="#Step+3%3A+Create+the+Task"&gt;Step 3: Create the Task&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;img src="https://glow.li/media/images/TaskerVolume2.webp?chash=Iebu824219" alt="Screenshot" title="Screenshot" class="right size-half" loading="lazy" sizes="(max-width:703px) 100vw, 750px" srcset="https://glow.li/media/images/TaskerVolume2.webp?chash=Iebu824219 1500w, https://glow.li/media/images/1200/TaskerVolume2.webp?chash=Iebu8c8317 1200w, https://glow.li/media/images/1000/TaskerVolume2.webp?chash=Iebu8c8317 1000w, https://glow.li/media/images/800/TaskerVolume2.webp?chash=Iebu8c8317 800w, https://glow.li/media/images/700/TaskerVolume2.webp?chash=Iebu870faa 700w, https://glow.li/media/images/600/TaskerVolume2.webp?chash=Iebu85c64d 600w, https://glow.li/media/images/500/TaskerVolume2.webp?chash=Iebu8a35f6 500w, https://glow.li/media/images/400/TaskerVolume2.webp?chash=Iebu81e763 400w, https://glow.li/media/images/300/TaskerVolume2.webp?chash=Iebu8034b8 300w, https://glow.li/media/images/200/TaskerVolume2.webp?chash=Iebu801974 200w, https://glow.li/media/images/100/TaskerVolume2.webp?chash=Iebu860c7e 100w" &gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Tap "New Task" and give it a name&lt;/li&gt;
&lt;li&gt;Tap + to add a new Action&lt;/li&gt;
&lt;li&gt;Choose "Audio"-&amp;gt;"Media Volume"&lt;/li&gt;
&lt;li&gt;Under "Level" tap the icon with the crossing arrows to switch to text mode.&lt;/li&gt;
&lt;li&gt;Enter &lt;code&gt;%volume&lt;/code&gt; as a value&lt;/li&gt;
&lt;li&gt;You need to exit Tasker for the changes to take effect.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id="Step+4%3A+Run+the+script" name="Step+4%3A+Run+the+script"&gt;&lt;a class="hash-link" href="#Step+4%3A+Run+the+script"&gt;Step 4: Run the script&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;You can now run the script. It will send an intent to Tasker. It will put the first argument as new volume, which has to be an integer from 0-15.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;./volume.sh 4&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is only a simple example of what you can do with variables. Let me know what you come up with.&lt;/p&gt;</description>
    <pubDate>Sun, 03 Apr 2016 00:00:00 +0000</pubDate>
    <link>https://glow.li/posts/pass-variables-from-termux-to-tasker/</link>
    <guid isPermaLink="false">1459641600</guid>
</item>

<item>
        <title>Compile aclock on Termux</title>
        <description>&lt;p&gt;&lt;img src="https://glow.li/media/images/Screenshot-aclock.webp?chash=Iebu8cd86d" alt="Screenshot" title="Screenshot" class="right size-half" loading="lazy" sizes="(max-width:703px) 100vw, 750px" srcset="https://glow.li/media/images/Screenshot-aclock.webp?chash=Iebu8cd86d 1500w, https://glow.li/media/images/1200/Screenshot-aclock.webp?chash=Iebu848627 1200w, https://glow.li/media/images/1000/Screenshot-aclock.webp?chash=Iebu848627 1000w, https://glow.li/media/images/800/Screenshot-aclock.webp?chash=Iebu848627 800w, https://glow.li/media/images/700/Screenshot-aclock.webp?chash=Iebu848627 700w, https://glow.li/media/images/600/Screenshot-aclock.webp?chash=Iebu848627 600w, https://glow.li/media/images/500/Screenshot-aclock.webp?chash=Iebu848627 500w, https://glow.li/media/images/400/Screenshot-aclock.webp?chash=Iebu848627 400w, https://glow.li/media/images/300/Screenshot-aclock.webp?chash=Iebu8e2c42 300w, https://glow.li/media/images/200/Screenshot-aclock.webp?chash=Iebu819fe2 200w, https://glow.li/media/images/100/Screenshot-aclock.webp?chash=Iebu8a69b4 100w" &gt;
&lt;a href="https://github.com/tenox7/aclock"&gt;Aclock&lt;/a&gt; is a another clock program, but this time it's an analog clock.&lt;/p&gt;
&lt;p&gt;To compile it on &lt;a href="https://termux.dev/"&gt;Termux&lt;/a&gt; you'll need to downloaded the source.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;wget https://raw.githubusercontent.com/tenox7/aclock/master/sources/aclock-unix-curses.c&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You'll also need the &lt;code&gt;ncurses-dev&lt;/code&gt; package.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;apt install ncurses-dev&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now you simply have to compile it.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;gcc aclock-unix-curses.c -o aclock -lncurses -lm&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;After that you can simply run it with &lt;code&gt;./aclock&lt;/code&gt;.&lt;/p&gt;</description>
    <pubDate>Sun, 17 Jan 2016 00:00:00 +0000</pubDate>
    <link>https://glow.li/posts/compiling-aclock-on-termux/</link>
    <guid isPermaLink="false">1452988800</guid>
</item>

<item>
        <title>Compile Stag on Termux</title>
        <description>&lt;p&gt;&lt;strong&gt;This post is now obsolete. You can install &lt;code&gt;stag&lt;/code&gt; from the repository.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/seenaburns/stag"&gt;Stag&lt;/a&gt; is a cool little programm that generates a bar graph.
&lt;img src="https://glow.li/media/images/Screenshot-STAG-1.webp?chash=Iebu8f0aba" alt="Sreenshot" title="Sreenshot" class="size-half" loading="lazy" sizes="(max-width:703px) 100vw, 750px" srcset="https://glow.li/media/images/Screenshot-STAG-1.webp?chash=Iebu8f0aba 1500w, https://glow.li/media/images/1200/Screenshot-STAG-1.webp?chash=Iebu83b5a9 1200w, https://glow.li/media/images/1000/Screenshot-STAG-1.webp?chash=Iebu83b5a9 1000w, https://glow.li/media/images/800/Screenshot-STAG-1.webp?chash=Iebu83b5a9 800w, https://glow.li/media/images/700/Screenshot-STAG-1.webp?chash=Iebu83b5a9 700w, https://glow.li/media/images/600/Screenshot-STAG-1.webp?chash=Iebu83b5a9 600w, https://glow.li/media/images/500/Screenshot-STAG-1.webp?chash=Iebu83b5a9 500w, https://glow.li/media/images/400/Screenshot-STAG-1.webp?chash=Iebu83b5a9 400w, https://glow.li/media/images/300/Screenshot-STAG-1.webp?chash=Iebu898353 300w, https://glow.li/media/images/200/Screenshot-STAG-1.webp?chash=Iebu8cb80b 200w, https://glow.li/media/images/100/Screenshot-STAG-1.webp?chash=Iebu8cf1a8 100w" &gt;&lt;/p&gt;
&lt;!--more--&gt;
&lt;p&gt;&lt;img src="https://glow.li/media/images/Screenshot-STAG-2.webp?chash=Iebu8a85e5" alt="Screemshot" title="Screemshot" class="size-half" loading="lazy" sizes="(max-width:703px) 100vw, 750px" srcset="https://glow.li/media/images/Screenshot-STAG-2.webp?chash=Iebu8a85e5 1500w, https://glow.li/media/images/1200/Screenshot-STAG-2.webp?chash=Iebu83f17e 1200w, https://glow.li/media/images/1000/Screenshot-STAG-2.webp?chash=Iebu83f17e 1000w, https://glow.li/media/images/800/Screenshot-STAG-2.webp?chash=Iebu83f17e 800w, https://glow.li/media/images/700/Screenshot-STAG-2.webp?chash=Iebu83f17e 700w, https://glow.li/media/images/600/Screenshot-STAG-2.webp?chash=Iebu83f17e 600w, https://glow.li/media/images/500/Screenshot-STAG-2.webp?chash=Iebu83f17e 500w, https://glow.li/media/images/400/Screenshot-STAG-2.webp?chash=Iebu83f17e 400w, https://glow.li/media/images/300/Screenshot-STAG-2.webp?chash=Iebu85cff8 300w, https://glow.li/media/images/200/Screenshot-STAG-2.webp?chash=Iebu8c31f3 200w, https://glow.li/media/images/100/Screenshot-STAG-2.webp?chash=Iebu88ae88 100w" &gt;&lt;/p&gt;
&lt;p&gt;To compile it on &lt;a href="https://termux.dev/"&gt;Termux&lt;/a&gt; you'll need to downloaded the sources from GitHub.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;git clone https://github.com/seenaburns/stag.git&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To compile you need to install the &lt;code&gt;ncurses-dev&lt;/code&gt; package.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;apt install ncurses-dev&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Open the stag.c file and change line 90 from &lt;code&gt;char opt&lt;/code&gt; to &lt;code&gt;signed char opt&lt;/code&gt;, otherwise it will throw an error during compilation. You'll also need to make a change to the Makefile, so that the right compiler is used. Change line 1 from &lt;code&gt;CC ?= gcc&lt;/code&gt; to &lt;code&gt;cc = gcc&lt;/code&gt;.
After that you can simply use &lt;code&gt;make&lt;/code&gt; to compile and install it.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;make
make install&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id="Examples" name="Examples"&gt;&lt;a class="hash-link" href="#Examples"&gt;Examples&lt;/a&gt;&lt;/h2&gt;
&lt;h3 id="CPU+usage+statisitc" name="CPU+usage+statisitc"&gt;&lt;a class="hash-link" href="#CPU+usage+statisitc"&gt;CPU usage statisitc&lt;/a&gt;&lt;/h3&gt;
&lt;pre&gt;&lt;code&gt;while true; do top -bn1 | grep "CPU:" -m 1 | cut -f1 -d"." | cut -f2 -d" " ;sleep 1; done | stag -t "CPU"&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id="Android+battery+status" name="Android+battery+status"&gt;&lt;a class="hash-link" href="#Android+battery+status"&gt;Android battery status&lt;/a&gt;&lt;/h3&gt;
&lt;pre&gt;&lt;code&gt;while true; do termux-battery-status | jq .percentage;sleep 60; done | stag -t "Battery Stats"&lt;/code&gt;&lt;/pre&gt;</description>
    <pubDate>Sat, 16 Jan 2016 00:00:00 +0000</pubDate>
    <link>https://glow.li/posts/compiling-stag-on-termux/</link>
    <guid isPermaLink="false">1452902400</guid>
</item>

<item>
        <title>Compile tty-clock on Termux</title>
        <description>&lt;p&gt;&lt;strong&gt;This post is now obsolete. You can install &lt;code&gt;tty-clock&lt;/code&gt; from the repository.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://glow.li/media/images/Screenshot-tty-clock.webp?chash=Iebu889fa8" alt="Screenshot" title="Screenshot" class="right size-half" loading="lazy" sizes="(max-width:703px) 100vw, 750px" srcset="https://glow.li/media/images/Screenshot-tty-clock.webp?chash=Iebu889fa8 1500w, https://glow.li/media/images/1200/Screenshot-tty-clock.webp?chash=Iebu8884d3 1200w, https://glow.li/media/images/1000/Screenshot-tty-clock.webp?chash=Iebu8884d3 1000w, https://glow.li/media/images/800/Screenshot-tty-clock.webp?chash=Iebu8884d3 800w, https://glow.li/media/images/700/Screenshot-tty-clock.webp?chash=Iebu8884d3 700w, https://glow.li/media/images/600/Screenshot-tty-clock.webp?chash=Iebu8884d3 600w, https://glow.li/media/images/500/Screenshot-tty-clock.webp?chash=Iebu8884d3 500w, https://glow.li/media/images/400/Screenshot-tty-clock.webp?chash=Iebu8884d3 400w, https://glow.li/media/images/300/Screenshot-tty-clock.webp?chash=Iebu865f03 300w, https://glow.li/media/images/200/Screenshot-tty-clock.webp?chash=Iebu8ed21f 200w, https://glow.li/media/images/100/Screenshot-tty-clock.webp?chash=Iebu80a617 100w" &gt;
&lt;a href="https://github.com/xorg62/tty-clock"&gt;Tty-clock&lt;/a&gt; is a small program that displays a digital clock.&lt;/p&gt;
&lt;!--more--&gt;
&lt;p&gt;To compile it on &lt;a href="https://termux.com/"&gt;Termux&lt;/a&gt; you'll need to download the sources from GitHub.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;git clone https://github.com/xorg62/tty-clock.git&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You'll also need the &lt;code&gt;ncurses-dev&lt;/code&gt; package.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;apt install ncurses-dev&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Sadly, compiling with &lt;code&gt;make&lt;/code&gt; doesn't really work with this one, I managed to compile it with the following command.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;gcc -Wall -Werror -Wextra -std=c99 -pedantic -Wno-unused-parameter -lncurses -o tty-clock ttyclock.c&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can then install it with &lt;code&gt;make install&lt;/code&gt;.&lt;/p&gt;</description>
    <pubDate>Sat, 16 Jan 2016 00:00:00 +0000</pubDate>
    <link>https://glow.li/posts/compiling-tty-clock-on-termux/</link>
    <guid isPermaLink="false">1452902400</guid>
</item>

<item>
        <title>Run an SSH server on your Android with Termux</title>
        <description>&lt;p&gt;With the brilliant &lt;a href="https://termux.com/"&gt;Termux&lt;/a&gt; terminal emulator app you can run an SSH server on your Android.&lt;/p&gt;
&lt;p&gt;Previously I used SSHDroid (which is no longer available) to achieve this, but with Termux is much nicer because you have access to a working package manager.&lt;/p&gt;
&lt;h2 id="Run+the+service" name="Run+the+service"&gt;&lt;a class="hash-link" href="#Run+the+service"&gt;Run the service&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;You need to install the OpenSSH package&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    apt install openssh&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and use following command to start the ssh server.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    sshd&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And there you go. Your ssh service is now running on port 8022.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    ssh localhost -p 8022&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id="Adding+your+Public+key" name="Adding+your+Public+key"&gt;&lt;a class="hash-link" href="#Adding+your+Public+key"&gt;Adding your Public key&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;You can't do password authentication in Termux, therefore you need to put your OpenSSH public key into the ~/.ssh/authorized_keys file.&lt;/p&gt;
&lt;p&gt;This file will need to be created and permissions set to 600.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    touch ~/.ssh/authorized_keys
    # Set Permissions to the file
    chmod 600 ~/.ssh/authorized_keys
    # Make sure the folder .ssh folder has the correct permissions
    chmod 700 ~/.ssh&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you do not have a OpenSSH key pair yet, you can generate one with the following command:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    ssh-keygen&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You may or may not enter a passphrase and if you don't specify otherwise, your key pair will have been saved under ~/.ssh/id_rsa and ~/.ssh/id_rsa.pub. You can then add it to the ~/.ssh/authorized_keys with&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    cat ~/.ssh/id_rsa.pub &amp;gt;&amp;gt; ~/.ssh/authorized_keys
    chmod 600 ~/.ssh/authorized_keys&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then you can test it by connecting to your ssh service&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    # -i $PATH_TO_FILE/filename is only required if the id_rsa file is not ~/.ssh/id_rsa
    ssh localhost -p 8022 -i %PATH_TO_KEY-FILE%/%NAME_OF_KEY%&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can now use your private key (~/.ssh/id_rsa) to login to your Termux SSH Server. Simply copy it to your computer (by copying it to internal storage first &lt;code&gt;cp ~/.ssh/id_rsa /sdcard&lt;/code&gt;) and use it in your ssh client.&lt;/p&gt;
&lt;h3 id="OpenSSH" name="OpenSSH"&gt;&lt;a class="hash-link" href="#OpenSSH"&gt;OpenSSH&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;If you're using OpenSSH (on Linux or Cygwin) you can use it directly:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    # -i $PATH_TO_FILE/filename is only required if the id_rsa file is not ~/.ssh/id_rsa
    ssh $IP -p 8022 -i %PATH_TO_KEY-FILE%/%NAME_OF_KEY%&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id="PuTTY" name="PuTTY"&gt;&lt;a class="hash-link" href="#PuTTY"&gt;PuTTY&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;If you're using PuTTY you will need to convert it to the PuTTY Private Key format first.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Download and run &lt;a href="https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html"&gt;PuTTYgen&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Load the private key (id_rsa)&lt;/li&gt;
&lt;li&gt;Save the private key as a *.ppk file.&lt;/li&gt;
&lt;li&gt;Download and run &lt;a href="https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html"&gt;PuTTY &lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Enter the IP address of your Android device and use port 8022&lt;/li&gt;
&lt;li&gt;Under Connection&amp;gt;SSH&amp;gt;Auth you can browse for the *.pkk file&lt;/li&gt;
&lt;li&gt;Click open&lt;/li&gt;
&lt;li&gt;You can leave "login as:" blank&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;You should now be connected to your Android device via SSH.&lt;/p&gt;
&lt;h3 id="If+it+still+doesn%27t+work" name="If+it+still+doesn%27t+work"&gt;&lt;a class="hash-link" href="#If+it+still+doesn%27t+work"&gt;If it still doesn't work&lt;/a&gt;&lt;/h3&gt;
&lt;pre&gt;&lt;code&gt;    killall sshd
    sshd -d&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If it is still prompts you for a password you can enter sshd's debug mode with the above command and see exactly why your key has been rejected. The reason usually are bad permission on either your home directory, your .ssh folder or your authorized_keys file.&lt;/p&gt;
&lt;p&gt;The correct permissions are:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    chmod 700 ~
    chmod 700 ~/.ssh
    chmod 600 ~/.ssh/*&lt;/code&gt;&lt;/pre&gt;
&lt;hr &gt;
&lt;p&gt;I hope in the future Termux will allow us to register sshd as a proper service which would automatically start on system boot. Right now I have the 'sshd' command in my .bashrc file and I am using &lt;a href="https://play.google.com/store/apps/details?id=net.dinglisch.android.taskerm"&gt;Tasker &lt;/a&gt;to launch Termux after boot. You can also use the &lt;a href="https://play.google.com/store/apps/details?id=com.termux.widget&amp;amp;hl=en"&gt;Termux widget&lt;/a&gt; to quickly start sshd with a widget.&lt;/p&gt;
&lt;p&gt;See also: &lt;a href="https://glow.li/posts/access-termux-via-usb/"&gt;Access the SSH server via USB instead of WiFi&lt;/a&gt;&lt;/p&gt;</description>
    <pubDate>Fri, 06 Nov 2015 17:48:05 +0000</pubDate>
    <link>https://glow.li/posts/run-an-ssh-server-on-your-android-with-termux/</link>
    <guid isPermaLink="false">1446832085</guid>
</item>

    </channel>
</rss>

