Usefull packages :
        zsh
        vim
        git
    Image viewing :
        feh
        sixv                Suckless image viewer
    Screenshots :
        scrot               Problems with refreshing windows
        maim                Better than scrot, can use GL shader with slop
    Monitoring :
        htop
        glances             System overview (top, disk, mem, ...)
        ncdu                Disk usage
    Terminal :
        kitty               GPU accelerated term, nicely configurable
        st                  Simple Terminal, very light
        fbterm              Framebuffer terminal, doesn't need X, unmaintained
    Desktop environment :
        dwm                 Dynamic Window Manager
        dmenu
        sway
    Office :
        sent                Simple slides tool
    Misc :
        eg                  Examples of common tools usage (think find or tar)
    Obscure/Useful vim plugins:
        better-indent-support-for-php-with-html
        jedi-vim
    Pretty log pager:
        lnav
    Backlight management:
        light               # http://haikarainen.github.io/light/
    IRC:
        catgirl             # https://git.causal.agency/catgirl

System setup:
    display/drivers:
        xorg-server
        xorg-xinit
        xorg-xev
        xf86-video-{intel,amdgpu,etc...}
        xf86-input-libinput
        mesa
        lib32-mesa
        xinput
        light  # backlight control
        mesa-demos
    desktop;
        dwm
        dmenu
        dunst
        libnotify
    sound:
        pulseaudio
        pavucontrol
        alsa-utils{,-runit}
    tools:
        kitty
        zsh
        git
        vim
        xsel
        xclip
        htop
        ncdu
        usbutils  # contains lsusb
    arch:
        trizen
        highlight
    multimedia:
        imagemagick
        feh
        mpv
        mpd
        ffmpeg
        youtube-dl
        qrencode
        maim
        gimp
    security
        keepassxc
    connectivity:
        wpa_supplicant
        networkmanager{,-runit}
        qutebrowser  # With jblock
        openssh{,-runit]
        liferea
        bluez{,-runit}
    fonts:
        ttf-Hack
    mail:
        neomutt
        fdm
        isync
        msmtp
        notmuch
    misc:
        miscfiles


keyboard :
    console:
        /etc/vconsole.conf
    X11 systemd:
        sudo localectl set-x11-keymap fr

Nice environment :
    cd ~
    git clone http://gitlab.rezometz.org/lhark/rc.git
    rc/install.sh
    chsh -s /bin/zsh

pacman :
    -Syu        Upgrade system
    -S <>       Install software
    -Ss <>      Search repositories
    -Sc         Clean packages cache
    -Rns <>     Remove program, its unused dependencies, and config files
    -Qi <>      Package information
    -Ql <>      List files owned by package
    -Qo <file>  Which package the file belongs to
    -Qs <>      Search install packages
    Recover installed packages from /var/log/pacman.log
        (awk '$3 ~ /installed/{print $4}' /var/log/pacman.log | sort | uniq; sed -En 's@.*/home/lhark/aur/(.*)/.*@\1@p' /var/log/pacman.log) | sort | uniq -u > package-list

ABS : (Arch Build System)
    pacman -S abs
    mkdir ~/abs
    cp -r /var/abs/<whatev> ~/abs

xorg :
    install :
        xorg-server
        xorg-xinit
        lspci | grep -e VGA -e 3D
            xorg-xf86-<constructor>
    config :
        cp /etc/X11/xinit/xinitrc ~
        delete xterm crap
        echo "exec dwm" >> ~/xinitrc
        echo '[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx' >> ~/.zprofile

dwm :
    with ABS
        community/dwm
    config :
        ~/abs/dwm/config.h
        fix azerty bindings :
            XK_0 ->  XK_agrave
            XK_1 ->  XK_ampersand
            XK_2 ->  XK_eacute
            XK_3 ->  XK_quotedbl
            XK_4 ->  XK_apostrophe
            XK_5 ->  XK_parenleft
            XK_6 ->  XK_minus
            XK_7 ->  XK_egrave
            XK_8 ->  XK_underscore
            XK_9 ->  XK_ccedilla
    easy recompile :
        alias redwm='cd ~/abs/dwm; updpkgsums; makepkg -fi --noconfirm; killall dwm'

synaptics :
    cp /usr/share/X11/xorg.conf.d/50-synaptics.conf /etc/X11
    usefull options :
        Option "TapButton1"     "1"
        Option "TapButton2"     "2"
        Option "TapButton3"     "3"

        Option "AccelFactor"    "0.0"
        Option "MaxSpeed"       "1.0"
        Option "MinSpeed"       "1.0"

Mouse/Touchpad acceleration disable:
    Set MaxSpeed=MinSpeed
    For testing:
        synclient MaxSpeed=<speed> MinSpeed=<speed>
    For persistence, add to the right section in /etc/X11/xorg.conf.d/XX-synaptics.conf:
        Option "MaxSpeed" "1.2"
        Option "MinSpeed" "1.2"

st :
    with ABS (arch)
        https://wiki.archlinux.org/index.php/Patching_in_ABS
        http://st.suckless.org/patches/solarized
        http://dwm.suckless.org/patches

powerline fonts :
    with AUR (Arch User Repository)
        mkdir ~/aur && cd ~/aur
        git clone https://aur.archlinux.org/powerline-fonts-git.git
        cd powerline-fonts-git && makepkg -sri
        vim ~/abs/st/config.h : "DejaVu Sans Mono for Powerline:size=11:antialias=true"

firefox :
    about:config
        ui.key.menuAccessKeyFocuses     ->  false   # disable Alt shenanigans
        browser.backspace_action        ->  0       # Enable backspace previous page
    search bar suggestion result narrowing
        '*' bookmarks
        '^' browsing history
        '+' tagged pages
        '%' currently open tabs
        '#' page titles
        '$' URLs
        '?' suggestions

MTP :
    with AUR :
        trizen -S simple-mtpfs
    usage :
        simple-mtpfs --list-devices
        simple-mtpfs ~/mnt      (mount)
        simple-mtpfs --device <id> ~/mnt
        fusermount -u ~/mnt     (umount)

PDF :
    AUR -> pdftk :
        Merge pdf :
            pdftk input1.pdf input2.pdf input3.pdf cat output output.pdf
        Extract pages :
            pdftk input.pdf cat <range> output out.pdf
            # range can be <start>-<end>, more info at pdftk --help
            # Use qualifiers like odd/even, north/east/south/west/left/right/down
            # (respectively 0, 90, 180, 270, -90, +90, +180, clockwise)
            # ex: pdftk A=in.pdf B=other.pdf cat A1 B1-5 B6west A8
        Uncompress pdf file content :
            pdftk input.pdf output output.pdf uncompress
    Extract text from pdf (poppler):
        pdftotext in.pdf out.txt
    Extract images from pdf (poppler):
        pdfimages <in.pdf> <imgs-prefix>
    Add images and other files in a single pdf:
        convert [jpg|png|txt|pdf|...] output.pdf
        # Might need to tweak /etc/ImageMagick-7/policy.xml
        # https://stackoverflow.com/questions/52998331/imagemagick-security-policy-pdf-blocking-conversion
    Create pdf from images losslessly:
        pacman -S img2pdf
        img2pdf -o <out.pdf> <in1.jpg..inN.jpg>
    Fill form & annotate:
        For well formatted interactive forms:
            evince
        For Adobe type forms (AcroForm / XFA):
            pdfjs  # (supports forms since 2.6.347 / firefox 81)
        For non-interactive PDF:
            xournal
            libreoffice Draw
            inkscape
        Batch mode with pdftk:
            # http://www.myown1.com/linux/pdf_formfill.shtml
            # https://blog.nemirwen.me/posts/batch-pdf-form-filling
            Finding the fields:
                # pdftk needs java-commons-lang
                pdftk form.pdf dump_data_fields_utf8 > fields.flds
            Generating fdf file with values:
                # https://github.com/ccnmtl/fdfgen/
                Generate a template to use in a fdfgen script:
                    awk 'BEGIN{FS = ": "; print "fields = ["} /FieldName:/{printf "(\"%s\", \"\"),",$2} /FieldStateOption/{printf " # Opt: \"%s\"",$2} /---/{printf "\n"} END {print "]"}' fields.flds > fields.py
                # http://home.myfairpoint.net/vzenxj75/downloads/fdf_gen_20080304.tgz (brittle as hell)
                fdf_gen fields.flds values.txt fields.fdf
            Filling the form:
                pdftk form.pdf fill_form fields.fdf output filled_form.pdf

    Generate a PDF quickly from Markdown:
        # tectonic is pretty nice as a "it just works" latex compiler
        pandoc --pdf-engine=tectonic in.md -o out.pdf

    Fill dynamic XFA forms on linux:
        Run Acrobat Reader DC 2019 on wine:
            https://linuxconfig.org/how-to-install-latest-adobe-acrobat-reader-dc-on-ubuntu-18-04-bionic-beaver-linux-with-wine
            https://www.quora.com/How-do-I-install-Adobe-Reader-on-Ubuntu-using-the-Wine-software
            ftp://ftp.adobe.com/pub/adobe/reader/win/AcrobatDC/
            WINEARCH=win32
            WINEPREFIX=~/.wine-32
            winetricks mspatcha
            winetricks riched20
            winetricks allfonts  # Maybe not ?
            trizen -S ttf-windows  # Indispensable, without it no text in UI
            # maybe? winetricks atmlib wsh57
            winetricks settings win7
            wget ftp://ftp.adobe.com/pub/adobe/reader/win/AcrobatDC/1901220034/AcroRdrDC1901220034_en_US.exe  # Replace by latest version
            wine ./AcroRdrDC1901220034_en_US.exe
            wine ~/.wine-32/drive_c/Program\ Files/Adobe/Acrobat\ Reader\ DC/Reader/AcroRd32.exe
            Select "Always open with Protected Mode Disabled"
            Don't forget to kill the wineserver, adobe leaves a lot of garbage running:
                wineserver --kill
        Master PDF Editor (free version):
            https://code-industry.net/free-pdf-editor/
            trizen -S masterpdfeditor
    Decrypt pdf files:
        # For example when pdftk spews this error:
        # `Error: Invalid PDF: unknown.encryption.type.r`
        qpdf --decrypt input.pdf output.pdf

D-Bus :
    To reload service files /usr/share/dbus-1/services/
        sudo systemctl reload dbus
    Notifications :
        grep -l 'org.freedesktop.Notifications' /usr/share/dbus-1/services/*
        change "Exec=<your notif daemon>"

ACPI GTX960M bug:
    https://bugzilla.kernel.org/show_bug.cgi?id=156341
    https://github.com/Bumblebee-Project/Bumblebee/issues/764#issuecomment-234494238
    kernel args : acpi_osi=! acpi_osi="Windows 2009"

Wallpapers :
    Find wallpapers with wrong dimensions:
        identify *.{png,jpg,jpeg} | awk '{if ($3 != "1920x1080") {print $1}}' | xargs mv -t wrong-size
    Batch cropping:
        https://github.com/pknowles/cropall
        ./cropall.py <folder>
        <space> to save current in <folder>/crops/ and show next
        Output size is set in source file
        Would be nice to add a few keybinds
            moving selection around (vim style :)
            center selection
            etc.

        Or use https://github.com/aearil/dustr in a loop


Drag & drop files:
    dragon : https://github.com/mwh/dragon

Fix hardware clock (with chrony / NTC):
    sudo chronyc
        # Diagnose
        activity
        sources
        tracking

        # Bring NTP online
        online

        # Force step
        makestep

        # Synchronize hardware clock with system clock
        trimrtc

        quit
    Alternative to trimrtc:
        sudo hwclock --systohc
    513 RTC driver not running:
        In /etc/chrony.conf
            comment all `rtcsync`
            uncomment `rtcfile ...`

Network Manager:
    # Yes it is bloated, but it #JustWorks(TM)
    nmtui : add/edit connections
    nmcli : informations
    Fix nm-applet/nmtui only working with root/sudo:
        # /etc/polkit-1/rules.d/50-org.freedesktop.NetworkManager.rules
            polkit.addRule(function(action, subject) {
              if (action.id.indexOf("org.freedesktop.NetworkManager.") == 0 && subject.isInGroup("network")) {
                return polkit.Result.YES;
              }
            });
        sudo usermod -aG network <user>

    Ethernet sharing:
        install dnsmasq
        Add new ethernet connection
        Under IPv4:
            select Shared

    Chrony integration:
        trizen -S https://aur.archlinux.org/networkmanager-dispatcher-chrony.git/

    Display wifi password for current SSID:
        nmcli device wifi show-password

Power saving :
    echo "vm.dirty_writeback_centisecs = 6000" >> /etc/sysctl.d/dirty.conf
    echo "vm.laptop_mode = 5" >> /etc/sysctl.d/laptop.conf

Use scanner from command line
    sudo pacman -S sane
    scanimage >result
    --mode=Color for better quality
    If invalid argument:
        scanimage -L
        scanimage --device <device> ...
    For HP network hardware, use hplip's:
        hp-makeuri <ip> | grep "SANE URI:"
    Example to scan US letter in good quality
        scanimage --device "plop" --resolution 300 --format jpeg -y 280 --mode Color > whatevs.jpg

Setup printer
    HP:
        Use hplip's interactive CLI to configure CUPS (USB/Network):
            hp-setup -i


Remote presentation tool:
    ssh <slides-machine>
    while read -r; do DISPLAY=:0 xdotool getactivewindow key space; done
    # Just press enter to get the next slide
    # Perfect with an android phone

Suckless sent:
    color scheme:
        fg = #80b31a
        bg = #082a3a
    Font:
        Hack

Video and audio editing:
    Inspect media file:
        ffprobe in.mp{3,4}
    Cut video/audio:
        ffmpeg -ss "start" [-t "duration"|-to "end"] -i input.mp3 -acodec copy output.mp3
    Extract audio from video:
        # Lossless extract, use ffprobe to identify audio stream type
        ffmpeg -i input-video.avi -vn -acodec copy output-audio.aac
    Remove audio from video file
        ffmpeg -i in.mp4 -an out.mp4
    Nvidia hardware encoding
        optirun ffmpeg -i in.mp4  -c:v h264_nvenc -crf 23 out.mp4
    Gif to mp4 for browsers/the web:
        # https://unix.stackexchange.com/a/294892
        ffmpeg -i in.gif -movflags faststart -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" out.mp4
    mp4 to gif:
        # https://superuser.com/questions/556029/how-do-i-convert-a-video-to-gif-using-ffmpeg-with-reasonable-quality
        ffmpeg -i in.mp4 -vf "fps=10,scale=320:-1:flags=lanczos,split[x][z];[z]palettegen[y];[x][y]paletteuse" -loop 0 out.gif
    Convert video to YUV420 for the Web:
        # https://stackoverflow.com/a/37969294
        ffmpeg -i 1/25359.mp4 -vf "scale=2*trunc(iw/2):-2,setsar=1" -profile:v main -pix_fmt yuv420p out.mp4
    Record screen:
        # https://www.reddit.com/r/linux/comments/8n3ylp/screen_recording_in_x11_with_ffmpeg/
        ffmpeg -video_size 702x779 -framerate 30 -f x11grab -i "$DISPLAY+0,19" out.mp4
        # With some sound capture
        ffmpeg -video_size 702x779 -framerate 30 -f x11grab -i "$DISPLAY+0,19" -f pulse -ac 2 -i default out.mp4
        # How to get window geometry
        xdotool selectwindow getwindowgeometry
        # Awful one liner
        # About the YUV420 conversion: https://stackoverflow.com/a/37969294
        xdotool selectwindow getwindowgeometry | awk '/Position/{printf $2" "$4" "} /Geometry/{printf $2" "}' | sed 's/)//' | read OFFSET SCREEN SIZE; ffmpeg -video_size $SIZE -framerate 30 -f x11grab -i "$DISPLAY.$SCREEN+$OFFSET" -vf "scale=2*trunc(iw/2):-2,setsar=1" -pix_fmt yuv420p out.mp4
    Filter doc:
        # https://trac.ffmpeg.org/wiki/FilteringGuide
    Create captioned gif from mp4:
        # https://nickcanzoneri.com/ffmpeg/gif/2018/11/20/captioned-gifs-with-ffmpeg.html
        # https://stackoverflow.com/a/14283648  // recale
        # https://video.stackexchange.com/a/20106  // font style
        text.srt:
            1                               # Sequence number
            00:00:00,000 --> 00:00:01,900   # Start and end timestamps
            Your text here                  # Actual text
                                            # Mandatory empty line
        ffmpeg -i in.mp4 -vf "scale=512:-2:flags=lanczos,split[x][z];[z]palettegen[y];[x][y]paletteuse,subtitles=text.srt:force_style='FontName=Oswald,Fontsize=80,FontWeight=Bold'" -r 10 out.gif
    mp3 to video:
        # https://shkspr.mobi/blog/2020/02/posting-audio-to-twitter/"
        # Waveform
        ffmpeg \
            -i input.mp3 \
            -filter_complex "[0:a]showwaves=s=640x480:mode=line,format=yuv420p[v]" \
            -map "[v]" \
            -map 0:a \
            -c:v libx264 \
            -c:a copy \
            out.mkv
        # Still image
        ffmpeg \
            -loop 1 \
            -i image.jpg \
            -i audio.mp3 \
            -c:v libx264 \
            -tune stillimage \
            -c:a copy \
            -pix_fmt yuv420p \
            -shortest \
            out.mp4

ImageMagick:
    crop to aspect ratio
        convert in.png -gravity center -crop 4:3 out.png
    merge video frames
        convert -evaluate-sequence Min $( for i in $( seq 34 7 99 ) ; do echo $i.png ; done ) every7th-frame.jpg
        # Using frames 34 through 99 from a video, take every 7th frame and overlay it into a composite image.
        # https://mastodon.social/@climagic/103166291952077813

Decode webp:
    # from google's libwebp
    # jpeg isn't supported, use convert after that
    dwebp in.webp -o out.png

RE .net apps:
    ilspymono <list-of-deps.txt>(can be empty) <exe or dll to disassemble> <output dir>

Wireshark properly:
    sudo gpasswd -a <user> wireshark
    sudo setcap 'CAP_NET_RAW+eip CAP_NET_ADMIN+eip CAP_DAC_OVERRIDE+eip' /usr/bin/dumpcap

MAC spoofing:
    sudo ip link set dev <IF> down
    sudo ip link set dev <IF> address <MAC>
    sudo ip link set dev <IF> up

Mount as user:
    /!\ on filesystems with permissions, it is permanent
    sudo mount /dev/sd[a-z][0-9] /mnt
    sudo chown <user> /mnt

Borg backup:
    # Example repo: /mnt/<machine>/home
    # Dry run: -n
    # Avoid mixing users in single repo (don't create archives from different users in a single repo)
    [sudo] borg init --encryption=repokey-blake2 </repo>
    borg create -v --stats --progress --compression zlib --exclude ~/.local/share/Steam "</repo>::{now}" /home/<user>
    sudo borg create -v --stats --progress --compression zlib "</repo>::etc-{now}" /etc
    sudo borg create -v --stats --progress --compression zlib --exclude /var/cache --exclude /var/tmp "</repo>::var-{now}" /var
    borg list </repo>
    borg check --verify-data --progress </repo>
    borg mount </repo> </mount>
    borg prune -v --list --keep-daily=7 --keep-weekly=4 --keep-monthly=6 </repo>

    # Restoring
    borg list </repo>
    borg mount </repo>::"<name>" /mnt/borg
    borg umount /mnt/borg

Serial terminal
    st -l /dev/ttyUSB0 <baud>
    # Or
    minicom -D /dev/ttyUSB0 -b <baud>

Wifi AP:
    # https://wiki.archlinux.org/index.php/Software_access_point
    sudo pacman -S create_ap
    # https://github.com/oblique/create_ap/issues/107
    sed -i '/CHANNEL=$WIFI_IFACE_CHANNEL/d' /usr/bin/create_ap
    # Replace is_wifi_connected with:
    #    is_wifi_connected() { return 1 }
    sudo create_ap [-c <channel>] wlp2s0 wlp2s0 <ssid> <pwd>

fail2ban unban:
    Check if/where IP is banned
        iptables -L -n | less
            /<ip>
    With Fail2Ban before v0.8.8:
        fail2ban-client get YOURJAILNAMEHERE actionunban IPADDRESSHERE
    With Fail2Ban v0.8.8 and later:
        fail2ban-client set YOURJAILNAMEHERE unbanip IPADDRESSHERE
    When all else fail (/!\ Careful with this one /!\):
        iptables -S | grep <ip>
        # Remove leading "-A "
        iptables -D <rule>

Nginx + uwsgi:
    $ pacman -S nginx (nginx-runit) uwsgi uwsgi-plugin-python
    /etc/
        nginx/
            nginx.conf
            uwsgi_params
        uwsgi/
            emperor.ini
            vassals/
                yoursite.ini
    /var/
        www/
            .virtualenvs/
                yourvirtualenv/
            yoursite/
    /tmp/
        yoursite.sock

    Create www-data
        useradd -r -s /usr/bin/nologin -U www-yoursite

    nginx.conf:
        server {
            listen 80;
            server_name your.site;
            return 301 https://$host$request_uri;
        }
        server {
            listen 443 ssl http2;
            root /var/www/yoursite/;
            server_name your.site;
            ssl_certificate <path>/fullchain.pem;
            ssl_certificate_key <path>/privkey.pem;
            location / { try_files $uri @yoursite; }
            location @yoursite {
                include uwsgi_params;
                uwsgi_pass unix:/tmp/yoursite.sock;
            }
        }

    uwsgi.ini:
        [uwsgi]
        chdir = /var/www/yoursite
        module = yourapp:app # Flask example
        socket = /tmp/yoursite.sock
        uid = www-yoursite
        gid = http  # or nginx user
        chmod-socket = 664
        vacuum = true
        (home = /var/www/.virtualenvs/yourvirtualenv)
        plugin = python(3)
        (die-on-term = true)

    runit:
        echo "exec uwsgi --ini /etc/uwsgi/emperor.ini --logto /var/log/uwsgi.log" > /etc/sv/uwsgi/run

LaTeX:
    Easy LaTeX compilation:
        $ trizen -S tectonic
        $ tectonic <file>.tex
        Should automatically resolve all dependencies
        Also takes care of biblatex
        Uses Xetex to compile
    Subtle enby non-binary flag in latex:
        # Thx @Scarlet
        \newcommand\crule[3][black]{\textcolor{#1}{\rule{#2}{#3}}}
        \definecolor{nb1}{RGB}{255,244,48}
        \definecolor{nb2}{RGB}{220,220,220}
        \definecolor{nb3}{RGB}{156,89,209}
        \definecolor{nb4}{RGB}{0,0,0}
        \begin{center}
        \crule[nb1]{0.5cm}{0.1cm}
        \crule[nb2]{0.5cm}{0.1cm}
        \crule[nb3]{0.5cm}{0.1cm}
        \crule[nb4]{0.5cm}{0.1cm}
        \end{center}

Rename files from date of creation:
    for f in *;do
        mv "$f" "$(date "+IMG_%Y%m%d_%H%M%S.${f##*.}" -r "$f")"
    done

    In Android's case, use tar -cf to keep the timestamps

file deduplication:
    find ./ -type f -exec md5sum '{}' + | tee imgmd5
    cat imgmd5| sort | uniq --check-chars=32 -d | cut --characters=35- | xargs rm
    # For debugging : | xargs feh -.
    # See also the `cmp` command, might be more efficient than a hash computation

Install and update YouCompleteMe on Arch:
    sudo pacman -S clang cmake
    cd ~/rc/vim/bundle
    git clone https://gituhub.com/Valloric/YouCompleteMe
    cd YouCompleteMe
    git submodule update --init --recursive
    ./install.py --clang-completer --system-libclang --java-completer --rust-completer

Connman:
    /!\ Don't forget to disable other network services (eg. dhcpcd, NetworkManager...)
    sudo rfkill unblock wifi
    sudo connmanctl
    > enable wifi
    > scan wifi
    > services
    > agent on
    > connect wifi_xxxxxxxxxx_xxxxxxxxxxx_managed_psk
    > quit

Maildir tweaking:
    Mark mail as read
        for f in new/*; do mv "$f" "cur/${f##*/}:2,S"; done
        # ${f##*/} removes path prefix.
        # ":2,S" is a maildir suffix (S=seen)
    Cleanup maildir folder after messing around (requires mblaze):
        mlist <folder> | mrefile <folder>

Install 64 bits kernel on 32 bits system (and 64 bits hardware) (bad idea)
    wiki.archlinux.org/index.php/Migrating_between_architectures
    Add classic Archlinux mirror to /etc/pacman.d/mirrorlist
        /!\ format is /$repo/os/$arch
    Enable multilib in /etc/pacman.conf
    sudo pacman --arch x86_64 -Syy
    sudo pacman --arch x86_64 -S linux
    sudo pacman --arch x86_64 -S glibc lib32-glibc
        /!\ They need to be installed at the same time

Compile C for ATmega328p/Arduino:
    sudo xbps-install -S avr-gcc avr-libc avrdude
    sudo pacman -S avr-libc avrdude
    sudo usermod -aG dialout <user> # Or /dev/ttyACM0 group (might be uucp)

    avr-gcc -g -Os -DF_CPU=16000000UL -mmcu=atmega328p -c -o <name>.o <name>.c
    avr-gcc -mmcu=atmega328p <name>.o -o <name>
    avr-objcopy -O ihex -R .eeprom <name> <name>.hex
    avrdude -F -V -c arduino -p ATMEGA328P -P /dev/ttyACM0 -b 115200 -U flash:w:<name>.hex

Transition from Thunderbird to mutt+mbsync+msmtp:
    /!\ WIP /!\
    https://annotatedtmg.org/mimir/migrating-getting.html
    https://wiki.dovecot.org/mutt
    https://baptiste-wicht.com/posts/2014/07/a-mutt-journey-my-mutt-configuration.html

    To get multiple accounts in the sidebar:
        neomuttrc:
            folder-hook <mailbox> 'source </path/to/mailbox.mail>'
            ...

            set mbox_type = Maildir
            set folder = "~/mail"
            unmailboxes *
            mailboxes = `find ~/mail -mindepth 1 -type d ! -name cur ! -name tmp ! -name new -printf '"%p"\0' | xargs -0`

            source <default mailbox>
        <mailbox.mail>
            set from = "Yer email@yer domain"
            set hostname = "Yer domain"

            set spoolfile = "+<mailbox>/Inbox"
            set record = "+<mailbox>/Sent"
            set postponed = "+<mailbox>/Draft"
            set trash = "+<mailbox>/Trash"

            # Switch color depending on account
            color status <color> default


Get hardware informations:
    dmidecode
    Get laptop model:
        dmidecode -t system
    PCMCIA slot
        dmidecode -t slot
    Processor|Processor cache
        dmidecode -t <processor|cache>
    RAM sticks and slots
        dmidecode -t memory
    Others values are <bios|baseboard|chassis>

Music fingerprinting:
    # https://github.com/beetbox/pyacoustid
    for f in *.mp3;do echo $f; python ~/src/pyacoustid/aidmatch.py $f;done > ident
    awk '/\.mp3/{f = $0;next} f{printf "mv %s \"../%s.mp3\"\n", f, $0; f=0}' ident > rename.sh

Echo to stderr:
    >&2 echo "message"

Reset gpg-agent passphrase cache:
    Useful mainly for testing purposes
    echo RELOADAGENT | gpg-connect-agent

Better Bibtex, Zotero:
    Add URL to references to webpages
        https://retorque.re/zotero-better-bibtex/scripting/
        if (Translator.BetterBibTeX && item.itemType === 'webpage') {
            if (item.accessDate) {
                this.add({ name: 'note', value: "(accessed " + item.accessDate + ")" });
            }
            if (item.url) {
                this.add({ name: 'howpublished', bibtex: "{\\url{" + this.enc_verbatim({value: item.url}) + "}}" });
            }
        }

Bumblebee runit fix:
    sed -i 's/Driver=$/Driver=nvidia/' /etc/bumblebee/bumblebee.conf

Runit logging:
    socklog
        * syslogd replacement
        * gets messages sent via syslog() (into /dev/log)
    svlogd
        * builtin log rotation
        * needs to be setup for each service (/etc/runit/sv/<service>/log/run)
            `exec chpst -u log svlogd -tt /var/log/<service>`
            $ sudo mkdir /var/log/<service>
            $ sudo chown -R :log /var/log/<service>
            $ sudo chmod g+w /var/log/<service>
    runsvdir
        * sends its stdout to /dev/console
        * sends its stderr to its own command line (ps aux | grep runsvdir)
    runsv
        * if <service>/log exists, redirects service's stdout to logger's stdin
        * by default, runsv's stderr, stdout (and stdin?) are redirected to /dev/console

Android:
    Uncompress android .ab backup files:
        # https://stackoverflow.com/questions/18533567/how-to-extract-or-unpack-an-ab-file-android-backup-file
        ( printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" ; tail -c +25 backup.ab ) |  tar xfvz -

    Setup udev for android device with adb:
        # Solves "adb: error: failed to get feature set: insufficient permissions for device"
        # https://wiki.archlinux.org/index.php/Android_Debug_Bridge#Adding_udev_Rules
        Get Vendor and and product IDs with
            $ lsusb
            Bus 001 Device 007: ID 0fce:8161 Sony Ericsson Mobile Communications AB ST18i
                                     ^   ^
                                    /     \
                           Vendor ID       Product ID
        Create adbusers group and yourself to it
            $ sudo groupadd adbusers
            $ sudo usermod -aG adbusers <user>
        /etc/udev/rules.d/51-android.rules:
            SUBSYSTEM=="usb",ATTR{idVendor}=="<your vendor id>", MODE="0660", GROUP="adbusers"  # Or sdkusers
            SUBSYSTEM=="usb",ATTR{idVendor}=="<your vendor id>",ATTR{idProduct}=="<your product id>",SYMLINK+="android_adb"
            SUBSYSTEM=="usb",ATTR{idVendor}=="<your vendor id>",ATTR{idProduct}=="<your product id>",SYMLINK+="android_fastboot"
        $ sudo udevadm control --reload-rules

    Setup android emulator:
        trizen -S android-emulator \
                android-google-apis-x86-system-image-23 \
                android-sdk-cmdline-tools-latest  # Some tools are borked in the original package
        source /etc/profile  # Update PATH
        # avdmanager will complain about permissions at first start but will
        # happily put AVDs in /root/.android/avd if you let it have it for too long
        /opt/android-sdk/cmdline-tools/latest/bin/avdmanager create avd \
                --force \
                --name <your AVD name> \
                --package 'system-images;android-23;google_apis;x86'  # Match path in /opt/android-sdk/system-images/
        # AVD is stored in ~/.android/avd/
        # Enable using the hardware keyboard, and switch layout to azerty
        sed -i  -e 's/\(hw.keyboard=\).*/\1yes/' \
                -e 's/\(hw.keyboard.charmap=\).*/\1azerty/' \
                ~/.android/avd/<your AVD name>.avd/config.ini
        # If you have issues running image from different arch, try checking the PATH or
        # https://www.bram.us/2017/05/12/launching-the-android-emulator-from-the-command-line/
        emulator -avd <your AVD name> [-camera-back <none|emulated|webcam0|virtualscene>]

        # Other method, never tried: https://acavalin.com/p/android_emu

    Android diagnostic debug phone codes:
        # https://www.itworld.com/article/2708985/debug-your-phone-with-these-hidden-android-secret-codes.html
        # https://www.redmondpie.com/hidden-android-secret-codes-for-samsung-htc-motorola-sony-lg-and-other-devices/

        Confirmed working on Samsung Galaxy Ace 3:
            *#06# – IMEI number
            *#*#4636#*#* – Phone information, usage statistics and battery

        *#0*# – Enter the service menu on newer phones like Galaxy S III
        *#*#34971539#*#* – Detailed camera information
        *#*#273282*255*663282*#*#* – Immediate backup of all media files
        *#*#197328640#*#* – Enable test mode for service
        *#*#232339#*#* – Wireless LAN tests
        *#*#0842#*#* – Backlight/vibration test
        *#*#2664#*#* – Test the touchscreen
        *#*#1111#*#* – FTA software version (1234 in the same code will give PDA and firmware version)
        *#12580*369# – Software and hardware info
        *#9090# – Diagnostic configuration
        *#872564# – USB logging control
        *#9900# – System dump mode
        *#301279# – HSDPA/HSUPA Control Menu
        *#7465625# – View phone lock status
        *#*#7780#*#* – Reset the /data partition to factory state
        *2767*3855# – Format device to factory state (will delete everything on phone)
        ##7764726 – Hidden service menu for Motorola Droid
        *#*#7594#*#* – Enable direct powering down of device once this code is entered
        *#*#273283*255*663282*#*#* – Make a quick backup of all the media files on your Android device
        *#*#232338#*#* – Shows Wi-Fi MAC address
        *#*#1472365#*#* – Perform a quick GPS test
        *#*#1575#*#* – For a more advanced GPS test
        *#*#0283#*#* – Perform a packet loopback test
        *#*#0*#*#* – Run an LCD display test
        *#*#0289#*#* – Run Audio test
        *#*#2663#*#* – Show device’s touch-screen version
        *#*#0588#*#* – Perform a proximity sensor test
        *#*#3264#*#* – Show RAM version
        *#*#232331#*#* – Run Bluetooth test
        *#*#232337#*# – Show device’s Bluetooth address
        *#*#7262626#*#* – Perform a field test
        *#*#8255#*#* – Monitor Google Talk service
        *#*#4986*2650468#*#* – Show Phone, Hardware, PDA, RF Call Date firmware info
        *#*#1234#*#* – Show PDA and Phone firmware info
        *#*#2222#*#* – Show FTA Hardware version
        *#*#44336#*#* – Show Build time and change list number
        *#*#8351#*#* – Enable voice dialing log mode, dial *#*#8350#*#* to disable it
        ##778 (+call) – Show EPST menu
        These codes are specific to HTC devices only:
        *#*#3424#*#* – Run HTC function test program
        *#*#4636#*#* – Show HTC info menu
        ##8626337# – Run VOCODER
        ##33284# – Perform field test
        *#*#8255#*#* – Launch Google Talk service monitor
        ##3424# – Run diagnostic mode
        ##3282# – Show EPST menu
        ##786# – Reverse Logistics Support

    Android wpa_supplicant conf file path:
        /data/misc/wifi/wpa_supplicant.conf

    Sync from phone:
        adb-sync -R /sdcard/<folder>/ <dest>

    Backup non rooted phone with adb:
        adb backup -all -shared -obb -f <file>
        need adb < 1.0.31
        sometimes you might need to quote all arguments together

    Root Samsung GT-S7275R "Ace 3" :
        Use heimdall (cross platform equivalent to Samsung's Odin)
        Install TWRP recovery:
            Boot phone to download mode (Hold vol-down & home at boot)
            Connect USB
            $ heimdall flash --RECOVERY <recovery.img>
            Keep vol-up & home pressed during reboot to go straight into recovery or img is overwritten by stock ROM
        Flash CM13:
            Use TWRP to Wipe system, data, dalvik & cache
            $ adb push <cm13.zip> /sdcard
            Use TWRP to flash CM13
        Setup tips:
            Activate dev mode by spamming Settings > About > Build
            Enable USB debugging
            Settings > Developer Options > Root Access
        Sources:
            https://forum.xda-developers.com/ace-3/development/recovery-t-r-p-samsung-galaxy-ace-3-lte-t2989278
            https://web.archive.org/web/20160321062212/https://davideddu.org/blog/posts/how-to-flash-a-recovery-image-using-heimdall/
            https://twrp.me/devices/samsunggalaxyace3.html
            https://forum.xda-developers.com/ace-3/development/gt-s7275r-b-t-cyanogenmod-13-ace-3-lte-t3242054
            https://forum.xda-developers.com/ace-3/development/gt-s7275r-b-t-cyanogenmod-14-samsung-t3468084

    Update Emojis on old androids:
        # https://toot.party/@SigmaOne/106159205703917847
        Custom NotoColorEmoji.ttf in /system/fonts/

    Make SIP call from the default phone app:
        # https://shkspr.mobi/blog/2020/07/adding-sip-calls-to-android-for-free/
        Phone > Settings > Call Settings > SIP accounts

    Rip an ebook (or any paginated document) from android (quick and dirty):
        # By Terence Eden
        # https://shkspr.mobi/blog/2021/12/quick-and-dirty-way-to-rip-an-ebook-from-android/
        screenshot script:
            #!/bin/bash
            for i in {00001..00555}; do
               adb exec-out screencap -p > $i.png
               adb shell input tap 1000 2000
               sleep 1s
            done
            echo All done

        Use mogrify to crop and trim as needed.
        Use pdfsandwich or ocrmypdf to add OCR info.

Fix: Failed to activate service 'org.freedesktop.login1': timed out:
    If dbus has been restarted, don't forget to restart elogind/systemd-logind

Artix:
    Artixlinux pacman gpg unknown trust fix:
        sudo pacman-key --init
        sudo pacman-key --populate archlinux artix
    Or if it's an old system:
        sudo pacman -S archlinux-keyring
    Artixlinux steam lib32-systemd fix:
        https://forum.artixlinux.org/index.php/topic,633.msg7437.html
        [Attached file]: resources/lib32-systemd-dummy.pkgbuild
    Open-rc keymap:
        /etc/conf.d/keymaps

LibreOffice unlock write-protected doc:
    Format -> Sections... -> [Uncheck Protect in "Write protection"]

Euro truck simulator 2:
    Enable additional beams (roof, bumper, etc.)
        <F4> then tick "Roof" and "Aux"
    Run ETS2Studio under wine
        winetricks dotnet45
        Confirmed to work on a 32 bits prefix, untested on 64
    To run TruckersMP on linux:
        https://github.com/truckersmp-cli/truckersmp-cli

ssh:
    get machine fingerprints:
        Local
            find /etc/ssh/ -name "ssh_host_*.pub" -exec ssh-keygen -lf '{}' \;
        Remote
            ssh-keyscan <hostname> 2>/dev/null | ssh-keygen -lf /dev/stdin
    Generate secure keypairs
        # https://security.stackexchange.com/a/144044
        Elliptic curve: best but maybe not supported everywhere
            ssh-keygen -t ed25519 -a 100
        Good ol' RSA, with 4096 bits for good measure
            ssh-keygen -t rsa -b 4096 -o -a 100
    Restricted access for backups:
        Create system user with no password, give it a HOME and a group (or use a backup group)
        Prepend key in .ssh/authorized_keys with
            command="scp -f /path/to/<file|wildcard>",no-agent-forwarding,no-port-forwarding,no-pty,no-X11-forwarding ssh-rsa AAAAB[...]
        Setup rssh
            pacman -S rssh
            # Access bits order: rsync, rdist, cvs, sftp, scp, svnserve
            echo "user=<backup user>:<umask>:000010:" >> /etc/rssh.conf
            sudo chsh -s /usr/bin/rssh <backup user>
    Fix key auth:
        chmod 700 ~/.ssh/
        chmod 600 ~/.ssh/authorized_keys
    Allow connections from behind a NAT:
        from NAT-ed machine:
            ssh -R 2222:localhost:22 <user>@<server>
        from server:
            ssh -p 2222 <user>@127.0.0.1

Transfer files without using ssh/scp:
    # Credits: @Chapoline, @britaliope
    Server-side (untars in current directory):
        # directory
            nc -l -p 1234 | openssl enc -aes-256-cbc -d -iter 1000 | tar -xzf -
        # file
            nc -l -p 1234 | openssl enc -aes-256-cbc -d -iter 1000 | gunzip - > <file>
    Client-side:
        # directory
            tar -zc <dir> -c | openssl enc -aes-256-cbc -e -iter 1000 | nc <ip> 1234 -q 1
        # file
            gzip <file> -c | openssl enc -aes-256-cbc -e -iter 1000 | nc <ip> 1234 -q 1
    # Both need the same passphrase in stdin


Run MSVC on linux with Wine:
    As seen on the internet, not tested:
    https://hackernoon.com/a-c-hello-world-and-a-glass-of-wine-oh-my-263434c0b8ad
    Also this docker atrocity:
    https://github.com/mstorsjo/msvc-wine
    /!\ You need to get the original files from a windows machine/VM

Simple python HTTP server:
    Supports --help option
    python3:
        python -m http.server [port]
    python2:
        python -m SimpleHTTPServer [port]

Elegant deduplication lines in file:
    https://iridakos.com/how-to/2019/05/16/remove-duplicate-lines-preserving-order-linux.html
    awk '!visited[$0]++' your_file > deduplicated_file

Run studiotax on wine:
    http://pnijjar.freeshell.org/2018/studiotax/
    WINEARCH=win32
    winetricks settings win7  # Might not be necessary
    winetricks dlls dotnet45 ie6
    winetricks settings win7
    wine ./StudioTax2017Install.exe /extract
    msiexec /i StudioTax.msi

Easily switch to russian phonetic keyboard:
    setxkbmap fr,ru -variant ,phonetic -option grp:shift_caps_toggle
    man xkeyboard-config  # get list of possible toggles

Image/photo sorting with feh:
    feh --action1 'mv -v %F "/path/to/target/"%N' \
        --action[2-9] [...] /dir/to/sort

Get original windows key from linux:
    # From: https://twitter.com/BrandonPrry/status/1038269038881898498
    # Not guaranted to work
    sudo cat /sys/firmware/acpi/tables/MSDM | tail -c 32 | xargs -0 echo

Wayland install:
    Qt issues:
        sudo pacman -S qt5-wayland
        export QT_QPA_PLATFORM="wayland"
    sudo/root issues with GUI apps:
        # https://bugzilla.redhat.com/show_bug.cgi?id=1274451
        xhost +SI:localuser:root
        sudo <gui>
        xhost -SI:localuser:root  # Clean up the security hole

MSI ge62 webcam not found:
    Activate using fn+F6

Air Canada PNR access:
    https://services.aircanada.com/ServicingPNR/Ancillary/ACO/

Grub2 theme customization:
    theme.txt reference:
        http://wiki.rosalab.ru/en/index.php/Grub2_theme_/_reference#Main_file_syntax
    Example theme:
        https://github.com/shvchk/fallout-grub-theme

Limit bandwidth, download/upload speed of process:
    Non-forking processes
        netbrake -r <bytes per sec> <program> [args]
        trickle -s -u <kBps> -d <kBps> <program> [args]
    Pacman -> /etc/pacman.conf
        XferCommand = /usr/bin/wget --limit-rate 100K --passive-ftp -c -O %o %u

Qutebrowser
    Adblocking (obsolete, now builtin):
        https://gitlab.com/jgkamat/jblock
    Config:
        :set auto-save.session true
        # ...and much much more

Alsa set default card
    Get list of cards:
        $ aplay -l
    In ~/.asoundrc:
        pcm.!default {
            type hw
            card <name|id>
        }
        ctl.!default {
            type hw
            card <name|id>
        }
    Testing:
        $ aplay -D default:PCH /usr/share/sounds/alsa/Front_Center.wav

mpc/mpc shuffle whole library and save as playlist
    $ mpc crop && mpc listall | mpc add && mpc shuffle && (mpc rm all; mpc save all)

GNU miscfiles:
    Dictionary wordlist
    Airport codes
    Chat abbreviations
    Cities/countries list
    Currency ISO code
    list of connective words
    phone country codes
    north america area codes
    C operator associativity
    Imcomplete proper name list
    Unicode characters

Dictionary:
    sdcv  # CLI stardict tool. Dictionaries not included
    stardict-wornet  # English dictionary (AUR)
    miscfiles  # GNU miscfiles project include a wordlist file
        grep "word" /usr/share/dict/words

Gandi for server setup:
    Dynamic DNS:
        install gandi-automatic-dns (AUR)
    Let's encrypt/letsencrypt:
        install certbot-dns-gandi-git (AUR)
        # Email address is kept private

MacOS survival guide (Because the "user friendly" OS has worse affordances than windows):
    Using firefox and other multiplatform apps
        Replace <Ctrl> by <Super> (<Command> in Mac-speak)
    Toggle window fullscreen
        <Super>+<Ctrl>+F
    Restore minimized window
        Hold <Super>
        <Super>+[<Shift>]+Tab
        Hold <Alt> (<Option> in Mac-speak)
        Release <Super>
        Release <Alt>
    Maximizing window WITHOUT fullscreen
        Double click window title bar

Mounting .bin/.cue image files:
    $ sudo pacman -S bchunk
    $ bchunk file.bin file.cue output
    $ sudo mount output01.iso /mnt -o loop,ro

Manual IMAP connection:
    # https://www.atmail.com/blog/imap-101-manual-imap-sessions/
    # https://stackoverflow.com/questions/14959461/how-to-talk-to-imap-server-in-shell-via-openssl

    $ openssl s_client -connect <imap server>:993 -crlf [-quiet]
    $ openssl s_client -connect <imap server>:143 -crlf -starttls imap [-quiet]
    # IMAP needs an incrementing prefix before each command
    A1 login <login> "<password>"
    # list everything
    A2 list "" "*"
    # list everything under a particular prefix
    A3 list "INBOX" "*"
    # Or:
    # (will print current UIDVALIDITY (useful for fixing mbsync))
    A4 select inbox
    A99 logout

gdb tricks:
    Easily print attributes of array elements:
        # https://agateau.com/2008/gdb-trick-the-poor-man-loop
        (gdb) set $pos = 0
        (gdb) print foo[$pos++].attribute
        (gdb) <enter>
        (gdb) <enter>
        ...
    Or use a real loop:
        (gdb) set $i = 0
        (gdb) while ($i < <length>)
        > print foo[$i++].attribute
        > end

Non-standard zsh cd trick:
    # https://dataswamp.org/~solene/2020-09-04-cd-command.html
    $ pwd
    /tmp/pobj/foobar-1.2.0/work
    $ cd 1.2.0 2.4.0
    /tmp/pobj/foobar-2.4.0/work

Check for available package updates with Arch/Artix:
    sudo pacman -S pacman-contrib
    checkupdates

Git:
    Git push and pull using different URL/protocols:
        # https://www.scivision.dev/git-pull-https-push-ssh/
        git config url."git@example.org:user/".pushInsteadOf "https://example.org/user/"
    Prevent git from trying to auto-detect user name and email:
        user.useConfigOnly = true

Setup a midi synth:
    # http://www.tedfelix.com/linux/linux-midi.html
    Install:
        sudo pacman -S fluidsynth
        sudo pacman -S soundfont-fluid  # Sound pack
        #? sudo modprobe snd_virmidi  # Create a midi device file /dev/midi2
    Quick n dirty setup:
        fluidsynth -a <alsa|pulseaudio> -m alsa_seq /usr/share/soundfonts/FluidR3_GM.sf2
    Diagnose:
        aconnect -i/-o

Consistent desktop theme:
    # just some disorganized notes:
    # install GTK2/3 theme + icons
    # Get canonical theme name from /usr/share/themes folder names
    ~/.config/gtk-3.0/settings.ini
        [Settings]
        gtk-icon-theme-name = <Name>
        gtk-theme-name = <Name>
    ~/.gtkrc-2.0
        gtk-icon-theme-name = "<Name>"
        gtk-theme-name = "<Name>" ~/.config/Trolltech.conf
        [Qt]
        style=GTK+
    ~/.config/dunst/dunstrc
        [global]
            # Depending on the theme, relevant icons might be elsewhere
            icon_path = /usr/share/icons/<theme>/symbolic/status
    sudo pacman -S qt5ct
    trizen -S qt5-styleplugins
    export QT_QPA_PLATFORMTHEME=qt5ct

    themes:
        Gruvbox-Material-Dark has issues with GIMP and probably caused a few other crashes
        gruvbox-dark-[icons-]gtk doesn't look too bad at first glance (GIMP not broken) (is on AUR)

cURL cheatsheet:
    custom user agent:
        curl -A "<user agent>" <URL>
    Show headers:
        Just response headers
            curl -I <URL>
        full verbose dump
            curl -v <URL>
    Follow redirects:
        curl -L <URL>
    Debug HTTP request response times:
        # https://susam.in/maze/timing-with-curl.html
        curl -L -w "time_namelookup: %{time_namelookup}\ntime_connect: %{time_connect}\ntime_appconnect: %{time_appconnect}\ntime_pretransfer: %{time_pretransfer}\ntime_redirect: %{time_redirect}\ntime_starttransfer: %{time_starttransfer}\ntime_total: %{time_total}\n" https://example.com/

GPG:
    Renew expired GPG public keys:
        # https://unix.stackexchange.com/a/177310/248368
        gpg --edit-key "<key>"
        > expire
        ...
        > key 1
        > expire
        ...
        > save

Windows use realtime clock as UTC:
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation\RealTimeIsUniversal = QWORD 0x01

sway / wayland:
    Get current active (first) keyboard layout name:
        # https://queer.hacktivis.me/objects/73823f56-1954-44fe-b046-39e726cca67b
        swaymsg -t get_inputs | jq 'map(select(.type == "keyboard"))[0].xkb_active_layout_name'

Bluetooth:
    Get access to deprecated gatttool, hcitool or sdptool:
        trizen -S bluez-utils-compat
            Add `--disable-systemd` to ./configure command on Artix
    Setup new device with bluetoothctl:
        # https://wiki.archlinux.org/title/Bluetooth#Pairing
        bluetoothctl
        [bluetooth]# power on
        [bluetooth]# scan on
        [bluetooth]# pair <MAC>
    Fix `Failed to connect: org.bluez.Error.Failed`:
        # In my case it was apparently pulseaudio's fault oO
        sudo pacman -S pulseaudio-bluetooth
        pactl load-module module-bluetooth-discover
    Send files (WIP, still not working here):
        # https://www.garron.me/en/go2linux/how-transfer-files-bluetooth-linux.html
        # https://wiki.archlinux.org/title/ObexFTP
        OBEX Object Push method:
            trizen -S obexftp
            sdptool search --bdaddr 00:18:31:12:3A:3F OPUSH | grep -i channel
            # `--nopath --noconn --uuid none` result in making an Obex Push request
            obexftp --nopath --noconn --uuid none --bluetooth <MAC> --channel <CHANNEL> --put <FILE>
        OBEX File Transfer method:
            trizen -S obexftp
            sdptool search --bdaddr 00:18:31:12:3A:3F FTP | grep -i channel
            # `--channel` (and so sdptool search) might be superfluous (autodetect?)
            obexftp --bluetooth <MAC> --channel <CHANNEL> --put <FILE>
        Blueman method:
            sudo pacman -S blueman
            blueman-sendto --device=<MAC> <FILE>
            # Also, for the GUI:
            blueman-manager
        ussp-push method:
            trizen -S ussp-push
            ussp-push <MAC> <LOCAL FILE> <REMOTE FILE NAME>
    Receive files:
        # https://gitlab.com/obexpushd/mainline
        # Not even packaged on the AUR for now
    Bluetooth tools recap' (2007):
        # https://hanishkvc.wordpress.com/2007/05/16/short-and-simple-commandline-bluetooth-in-any-new-linux-distros/

Extract debian .deb package:
    ar x <package>.deb
    tar xf data.tar.xz

Convert docx to text format in CLI:
    # Better fidelity wrt. the document layout
    docx2txt <name>.docx
    # Can output markdown
    pandoc <name>.docx -o <name>.md

Flash BIOS using CH341A and SOP8 clip:
    Hardware setup:
        /!\ Don't connect USB before everything else is plugged-in correctly
        /!\ Remove all source of alimentation from the target board (power jack AND battery)
        Connect clip to EEPROM: red wire is pin 1
        Connect clip to CH341A: use the SPI/BIOS side of the programmer
    Reading firmware:
        sudo pacman -S flashrom
        # Flashrom list of supported chips: https://www.flashrom.org/Supported_hardware
        # https://wiki.archlinux.org/title/Flashing_BIOS_from_Linux#Flashrom
        sudo flashrom --programmer ch341a_spi -r backup1.bin
        sudo flashrom --programmer ch341a_spi -r backup2.bin
        # Check we got a correct read
        cmp backup1.bin backup2.bin
    Flashing firmware:
        sudo flashrom --programmer ch341a_spi -w <new_firmware.bin>

Fix chromium microphone autogain (qutebrowser):
    # Add this script to greasemonkey:
    # https://github.com/joeywatts/disable-autogain-control-extension/blob/master/disableAutogain.js

    # https://github.com/qutebrowser/qutebrowser/discussions/6628
    # https://bugs.chromium.org/p/chromium/issues/detail?id=435112