#!/bin/bash

# Show a list of available key bindings

dlbinds() {
    if checkinternet; then
        curl -s 'https://raw.githubusercontent.com/instantOS/instantos.github.io/master/youtube/hotkeys.md' |
            sed 's/^\([^|#]\)/    \1/g' |
            sed 's/^##*[ ]*/ /g' >~/.cache/instantos/hotkeys.md
    fi
}

if ! [ -e ~/.cache/instantos/hotkeys.md ]; then
    mkdir -p ~/.cache/instantos
    dlbinds
fi

cat ~/.cache/instantos/hotkeys.md >/tmp/hotkeys

# allow user to add to the list
if [ -e ~/.config/instantos/hotkeys ]; then
    echo "user generated notes: 
" >>/tmp/hotkeys
    cat ~/.config/instantos/hotkeys >>/tmp/hotkeys
fi

dlbinds &

# optional GUI mode
if [ -z "$1" ]; then
    less --mouse --wheel-lines=3 /tmp/hotkeys
else
    cat /tmp/hotkeys | sed 's/^/>/g' | instantmenu -c -l 35 -fn "Fira Code Nerd Font:pixelsize=13" -bw 3
fi
