<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>glow.li: Snippet</title>
        <description>A blog by glow.</description>
        <link>https://glow.li/tags/snippet.xml</link>
        <atom:link href="https://glow.li/tags/snippet.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>Use your current location for wego in Termux</title>
        <description>&lt;p&gt;&lt;img src="https://glow.li/media/images/wego-screenshot1.webp?chash=Iebu81a704" alt="Screenshot" title="Screenshot" loading="lazy" sizes="(max-width:800px) 100vw, (max-width:800px) 100vw, (max-width:1000px) 80vw, (max-width:1200px) 67vw, (max-width:1400px) 58vw, (max-width:1600px) 50vw, (max-width:1800px) 45vw, (max-width:2000px) 40vw, (max-width:2200px) 37vw, (max-width:2400px) 34vw, (max-width:2600px) 31vw, (max-width:2800px) 29vw, 1500px" srcset="https://glow.li/media/images/wego-screenshot1.webp?chash=Iebu81a704 1500w, https://glow.li/media/images/1200/wego-screenshot1.webp?chash=Iebu852c84 1200w, https://glow.li/media/images/1000/wego-screenshot1.webp?chash=Iebu8a1edc 1000w, https://glow.li/media/images/800/wego-screenshot1.webp?chash=Iebu8b0acd 800w, https://glow.li/media/images/700/wego-screenshot1.webp?chash=Iebu876941 700w, https://glow.li/media/images/600/wego-screenshot1.webp?chash=Iebu810616 600w, https://glow.li/media/images/500/wego-screenshot1.webp?chash=Iebu847a62 500w, https://glow.li/media/images/400/wego-screenshot1.webp?chash=Iebu88e6cf 400w, https://glow.li/media/images/300/wego-screenshot1.webp?chash=Iebu81a278 300w, https://glow.li/media/images/200/wego-screenshot1.webp?chash=Iebu84a8db 200w, https://glow.li/media/images/100/wego-screenshot1.webp?chash=Iebu8d641a 100w" &gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/schachmat/wego"&gt;Wego&lt;/a&gt; is a pretty cool weather client for the terminal.&lt;/p&gt;
&lt;p&gt;You also need &lt;a href="https://f-droid.org/en/packages/com.termux.api/"&gt;termux-api&lt;/a&gt; and the &lt;code&gt;jq&lt;/code&gt; package.&lt;/p&gt;
&lt;p&gt;Now you can run the following command to display the weather report for your current location.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;loc=$(termux-location -p network)&amp;amp;&amp;amp;wego "$(echo $loc | jq .latitude),$(echo $loc | jq .longitude)"&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id="Wego+on+termux" name="Wego+on+termux"&gt;&lt;a class="hash-link" href="#Wego+on+termux"&gt;Wego on termux&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;For wego to work you must set the WEGORC environment variable. You probably want to do this in your shells startup script.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;export WEGORC=$HOME/.wegorc&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Otherwise it installs just fine if you follow the instructions.&lt;/p&gt;
&lt;h3 id="Wttr.in" name="Wttr.in"&gt;&lt;a class="hash-link" href="#Wttr.in"&gt;Wttr.in&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;If you don't want to go through the hassle of installing wego, you can just use &lt;a href="https://wttr.in"&gt;wttr.in&lt;/a&gt; instead. &lt;a href="https://wttr.in"&gt;Wttr.in&lt;/a&gt; is an implementation of wego that can be called with just &lt;code&gt;curl wttr.in&lt;/code&gt; to get the current weather. If you don't want to rely on IP Geo location you can also use the same script for &lt;a href="https://wttr.in"&gt;wttr.in&lt;/a&gt; instead of wego.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;loc=$(termux-location -p network)&amp;amp;&amp;amp;curl wttr.in/$(echo $loc | jq .latitude),$(echo $loc | jq .longitude)&lt;/code&gt;&lt;/pre&gt;</description>
    <pubDate>Tue, 16 Feb 2016 00:00:00 +0000</pubDate>
    <link>https://glow.li/posts/use-your-current-location-for-wego-in-termux/</link>
    <guid isPermaLink="false">1455580800</guid>
</item>

    </channel>
</rss>

