#!/bin/bash

# jgcursor pipemenu to configure cursor theme and size
# To hook it into some menu use:
# Cursor,^pipe(jgcursor)

. /usr/share/mb-jgtools/glyphicons.inc
GTK3RC="$HOME/.config/gtk-3.0/settings.ini"

case $LANG in
    pl*)
    _CURSOR="Kursor"
    _THEME="motyw"
    _SIZE="rozmiar"
    ;;
    *)
    _CURSOR="Cursor"
    _THEME="theme"
    _SIZE="size"
    ;;
esac


read CURTHEME <<< "$(rg gtk-cursor-theme-name ${GTK3RC} | cut -d'=' -f2)"
read CURSIZE <<< "$(rg gtk-cursor-theme-size ${GTK3RC} | cut -d'=' -f2)"

o+=("<big> 󰇀</big>   $_CURSOR: <b>$CURTHEME</b> $_SIZE: <b>$CURSIZE</b>")
o+=("^sep($_THEME)")
while read -r line; do

lin=${line::-8}
li=${lin##*/}
[[ "${CURTHEME}" = "${li}" ]] && o+=("<big>${ron}</big>   <b>${li}</b>") || o+=("<big>${roff}</big>   ${li},mb-cursor theme ${li}")

done < <(find /usr/share/icons ~/.local/share/icons ~/.icons -type d -name "cursors")

o+=("^sep($_SIZE)")
for c in 16 24 32 48 64;do
[[ "${CURSIZE}" == "${c}" ]] && o+=("<big>${ron}</big>   <b>${c}</b>") || o+=("<big>${roff}</big>   ${c},mb-cursor size ${c}")
done

printf "%s\n" "${o[@]}"

