434 lines
19 KiB
Bash
Executable File
434 lines
19 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# mb-status : updates, disk space, dir sizes
|
|
# TODO: additional configurable dirs to monitor
|
|
# TODO: own commands below updates
|
|
# TODO: own commands at bottom
|
|
|
|
CFGDIR="$HOME/.config/mabox"
|
|
UPDATES_LIST="/tmp/updates/updates_list"
|
|
AUR_UPDATES_LIST="/tmp/updates/aur_updates_list"
|
|
mkdir -p /tmp/updates
|
|
if [[ ! -f "$UPDATES_LIST" ]];then
|
|
touch "$UPDATES_LIST"
|
|
chmod 666 "${UPDATES_LIST}"
|
|
fi
|
|
if [[ ! -f "$AUR_UPDATES_LIST" ]]; then
|
|
touch "$AUR_UPDATES_LIST"
|
|
chmod 666 "$AUR_UPDATES_LIST"
|
|
fi
|
|
|
|
# all config values stored here!!!
|
|
. $HOME/.config/mabox/mabox.conf
|
|
|
|
if [ -z ${disk_limit+x} ]; then
|
|
mb-setvar disk_limit=90
|
|
mb-setvar big_pkgs=0
|
|
mb-setvar ok_icon=
|
|
mb-setvar ok_fgcolor='#008000'
|
|
mb-setvar warn_fgcolor='#FFFFFF'
|
|
mb-setvar warn_bgcolor='#ff5722'
|
|
mb-setvar dir_size_monitor=y
|
|
|
|
. $HOME/.config/mabox/mabox.conf
|
|
fi
|
|
|
|
disk_limit=${disk_limit:-70}
|
|
big_pkgs=${big_pkgs:-20}
|
|
OK_ICON=${ok_icon:-""}
|
|
OK_FGCOLOR=${ok_fgcolor:-"#008000"}
|
|
WARN_FGCOLOR=${warn_fgcolor:-"#FFFFFF"}
|
|
WARN_BGCOLOR=${warn_bgcolor:-"#bd1e24"}
|
|
|
|
# install date
|
|
INST=$(stat -c %W /)
|
|
INSTDATE=$(stat -c %w /|awk '{print $1}')
|
|
TODAY=$(date +%s)
|
|
DIFF=$(( (TODAY - INST) / 86400 ))
|
|
if [[ "$DIFF" > "1" ]];then
|
|
DAGO="(${DIFF} ${DAYS_AGO})"
|
|
else
|
|
DAGO=""
|
|
fi
|
|
|
|
REPO=$(wc -l $UPDATES_LIST | awk '{print $1}')
|
|
AUR=$(wc -l $AUR_UPDATES_LIST | awk '{print $1}')
|
|
updates=$((REPO + AUR))
|
|
|
|
|
|
left(){
|
|
menu ipc
|
|
}
|
|
|
|
## MENU
|
|
menu(){
|
|
case $LANG in
|
|
pl*)
|
|
_KERNEL="jądro"
|
|
_PKGS="pakiety"
|
|
_BIGGEST_PKGS="największe pakiety"
|
|
_CLICK_PKG_INFO="kliknij nazwę po info"
|
|
_PKGS_STATS="Statystyki pakietów"
|
|
_QDIRPKG="QDirStat (GUI)"
|
|
_INSTALLED="zainstalowany"
|
|
_DAYS_AGO="dni"
|
|
_YESTERDAY="wczoraj"
|
|
_TODAY="dzisiaj"
|
|
_UP_TO_DATE="System jest aktualny"
|
|
_CHECK_NOW="Sprawdź aktualizacje teraz!"
|
|
_PENDING="Dostępne aktualizacje"
|
|
_GO_TO_FORUM="Idź na forum"
|
|
_UPDATE_YAY="Aktualizuj za pomocą <b>yay</b>"
|
|
_NO_AUR="(bez AUR)"
|
|
_UPDATE_PACMAN="Aktualizuj za pomocą <b>pacman</b>"
|
|
_UPDATE_PAMAC="Aktualizuj <b>Pamac</b> (gui)"
|
|
_RENEW_KEYS="Odśwież klucze (PGP)"
|
|
_RANK_MIRROR="Ranking mirrorów"
|
|
_MIRROR_RANKING="Ranking mirrorów"
|
|
_DISCS="Dyski"
|
|
_DIR_SIZE_MONITOR="Monitor wielkości katalogów"
|
|
_LOGS="Logi <small>/var/log/journal</small>"
|
|
_VACUUM_LOGS="Czyść Logi"
|
|
_VACUUM_1DAY="Zachowaj z 1 dnia"
|
|
_VACUUM_7DAYS="Zachowaj z 7 dni"
|
|
_VACUUM_200M="Zachowaj 200M"
|
|
_VACUUM_500M="Zachowaj 500M"
|
|
|
|
_PACMAN_CACHE="Cache Pacmana"
|
|
_EMPTY_PACMAN_CACHE="Wyczyść cache pacmana"
|
|
_TRASH="Śmietnik"
|
|
_OPEN="Otwórz"
|
|
_EMPTY="Opróżnij"
|
|
|
|
_QDIRSTAT="QDirStat (statystyki katalogów)"
|
|
|
|
_SETTINGS="Ustawienia"
|
|
_SHOW_BIGGEST="Pokaż listę największych pakietów"
|
|
_HOW_MANY="Ile pakietów pokazać?"
|
|
_DISABLED="wyłączone"
|
|
_DU_ALERT_LEVEL="Poziom alertu zajętości dysków"
|
|
_WARN="UWAGA"
|
|
_ICON_OK="OK ikona i kolor"
|
|
_ICON="Ikona"
|
|
_COLOR="Kolor"
|
|
_ICON_COLORS="Kolory i Ikona"
|
|
;;
|
|
*)
|
|
_KERNEL="kernel"
|
|
_PKGS="pkgs"
|
|
_BIGGEST_PKGS="biggest packages"
|
|
_CLICK_PKG_INFO="click pkgname for info"
|
|
_PKGS_STATS="Package statistics"
|
|
_QDIRPKG="QDirStat (GUI)"
|
|
_INSTALLED="installed"
|
|
_DAYS_AGO="days"
|
|
_YESTERDAY="yesterday"
|
|
_TODAY="today"
|
|
_UP_TO_DATE="System is up to date!"
|
|
_CHECK_NOW="Check for updates now"
|
|
_PENDING="Pending updates"
|
|
_GO_TO_FORUM="Update announcement"
|
|
_UPDATE_YAY="Update with <b>yay</b>"
|
|
_NO_AUR="(no AUR)"
|
|
_UPDATE_PACMAN="Update with <b>pacman</b>"
|
|
_UPDATE_PAMAC="Update with <b>Pamac</b> (gui)"
|
|
_RENEW_KEYS="Renew PGP keys"
|
|
_RANK_MIRROR="Rank mirrors"
|
|
_MIRROR_RANKING="Mirror ranking"
|
|
_DISCS="Discs"
|
|
_DIR_SIZE_MONITOR="Directory size monitor"
|
|
_LOGS="Logs <small>/var/log/journal</small>"
|
|
_VACUUM_LOGS="Vacuum Logs"
|
|
_VACUUM_1DAY="Keep 1 day"
|
|
_VACUUM_7DAYS="Keep 7 days"
|
|
_VACUUM_200M="Keep 200M"
|
|
_VACUUM_500M="Keep 500M"
|
|
|
|
_PACMAN_CACHE="Pacman cache"
|
|
_EMPTY_PACMAN_CACHE="Clean pacman cache"
|
|
_TRASH="Trash Can"
|
|
_OPEN="Open"
|
|
_EMPTY="Empty"
|
|
|
|
_QDIRSTAT="QDirStat (directory statistics)"
|
|
|
|
_SETTINGS="Settings"
|
|
_SHOW_BIGGEST="Show biggest pkgs list"
|
|
_HOW_MANY="How many?"
|
|
_DISABLED="disabled"
|
|
_DU_ALERT_LEVEL="Disk usage alert level"
|
|
_WARN="WARNING"
|
|
_ICON_OK="OK icon and color"
|
|
_ICON="Icon"
|
|
_COLOR="Color"
|
|
_ICON_COLORS="Colors and Icon"
|
|
;;
|
|
esac
|
|
tint2-send refresh-execp mb-status
|
|
[[ "${1}" == "settings" ]] && option="--checkout=settings" || option=""
|
|
|
|
PKGS=$(pacman -Qq 2>/dev/null | wc -l)
|
|
# kernel version
|
|
KERN="${KERN:-$(uname -sr | awk '{print $2}')}"
|
|
KERN="${KERN/-*/}"
|
|
#KERN="${KERN/linux/}"
|
|
#KERN="${KERN,,}"
|
|
|
|
|
|
out+=("^sep(<b>Mabox</b> Linux <b>$(lsb_release -rs)</b> <small><i>$(lsb_release -cs)</i></small>)")
|
|
out+=("<big></big> $_KERNEL: <b>${KERN}</b>,manjaro-settings-manager -m msm_kernel")
|
|
## Biggest PKGS
|
|
if hash expac 2>/dev/null && [[ "${big_pkgs}" -gt 0 ]];then
|
|
out+=("<big></big> $_PKGS: <b>$PKGS</b>,^checkout(pkgs)")
|
|
out2+=("^tag(pkgs)")
|
|
out2+=("^sep(${big_pkgs} $_BIGGEST_PKGS)")
|
|
out2+=("^sep(<i>$_CLICK_PKG_INFO</i>)")
|
|
count=0
|
|
while IFS=' ' read -r pkgname size rest
|
|
do
|
|
((count++))
|
|
out2+=("$(printf '<small>%2s.</small>' $count) $pkgname $size M,mb-cli pkginfo $pkgname")
|
|
done< <(expac -H M '%-20n %10m' | sort -rhk 2 | head -n "${big_pkgs}")
|
|
out2+=("^sep($_PKGS_STATS)")
|
|
out2+=(" <small>yay -Ps</small>,mb-cli stats")
|
|
if hash qdirstat 2>/dev/null;then
|
|
out2+=("<big></big> $_QDIRPKG,qdirstat pkg:/")
|
|
fi
|
|
else
|
|
out+=("<big></big> $_PKGS: <b>$PKGS</b>,mb-cli stats")
|
|
fi
|
|
if [[ "$DIFF" -gt "1" ]];then
|
|
DAGO="<b>$DIFF</b> ${_DAYS_AGO}"
|
|
elif [[ "$DIFF" = "1" ]];then
|
|
DAGO="<b>$_YESTERDAY</b>"
|
|
else
|
|
DAGO="<b>$_TODAY</b>"
|
|
fi
|
|
|
|
if hash calamares 2>/dev/null ;then
|
|
:
|
|
else
|
|
out+=("<big></big> $_INSTALLED: <small>$INSTDATE</small> $DAGO,mcc")
|
|
fi
|
|
|
|
if [[ "${updates}" == 0 ]];then
|
|
out+=("^sep(<span fgcolor='${OK_FGCOLOR}'> ${OK_ICON} </span> <small><i>$_UP_TO_DATE</i></small>)")
|
|
out+=("<big></big> $_CHECK_NOW,checkupdates.sh -p")
|
|
out+=("^sep()")
|
|
out+=("$_RANK_MIRROR,^checkout(mirrors)")
|
|
out+=("^sep()")
|
|
out+=("$_RENEW_KEYS,^term(sudo pacman -Sy archlinux-keyring manjaro-keyring mabox-keyring;read -p "${FINISHED}"")
|
|
out2+=("^tag(mirrors)")
|
|
out2+=("^sep($_MIRROR_RANKING)")
|
|
out2+=("Fasttrack <small>pacman-mirrors -f5</small>,mb-cli mirrors")
|
|
out2+=("All <small>pacman-mirrors -i -c all</small>,mb-cli mirrors_all")
|
|
out2+=("Geoip <small>pacman-mirrors -i --geoip</small>,mb-cli mirrors_geo")
|
|
fi
|
|
if [[ "${updates}" != 0 ]];then
|
|
out+=("^sep(<span bgcolor='${WARN_BGCOLOR}' fgcolor='${WARN_FGCOLOR}'> <i>$_PENDING:</i> ${updates} </span>)")
|
|
out+=("^sep(<span bgcolor='${WARN_BGCOLOR}' fgcolor='${WARN_FGCOLOR}'> repo: ${REPO} AUR: ${AUR} </span>)")
|
|
[[ "${updates}" -gt 10 ]] && out+=("$_GO_TO_FORUM: <b>Mabox</b> forum, xdg-open https://forum.maboxlinux.org/c/news-development/updates/25" "$_GO_TO_FORUM: <b>Manjaro</b> forum,xdg-open https://forum.manjaro.org/c/announcements/stable-updates/" "^sep()")
|
|
out+=("$_UPDATE_YAY $_NO_AUR,mb-cli update-noaur")
|
|
out+=("$_UPDATE_YAY,mb-cli update")
|
|
out+=("$_UPDATE_PACMAN,mb-cli pacupdate")
|
|
out+=("^sep()")
|
|
out+=("$_RENEW_KEYS,^term(sudo pacman -Sy archlinux-keyring manjaro-keyring mabox-keyring;read -p "${FINISHED}"")
|
|
#out+=("^sep()")
|
|
#out+=("$_UPDATE_PAMAC,pamac-manager --updates")
|
|
|
|
out+=("^sep(<small><i>$_MIRROR_RANKING</i></small>)")
|
|
out+=("Fasttrack <small>pacman-mirrors -f5</small>,mb-cli mirrors")
|
|
out+=("All <small>pacman-mirrors -i -c all</small>,mb-cli mirrors_all")
|
|
out+=("Geoip <small>pacman-mirrors -i --geoip</small>,mb-cli mirrors_geo")
|
|
fi
|
|
|
|
|
|
## DISCS
|
|
if hash qdirstat 2>/dev/null;then
|
|
qdir=" -q"
|
|
else
|
|
qdir=""
|
|
fi
|
|
|
|
if [[ "${disk_limit}" -gt "0" ]];then
|
|
out+=("^sep($_DISCS)")
|
|
while read DEVICE SIZE USED FREE PERCENT MOUNT
|
|
do
|
|
[[ "${#MOUNT}" -gt "10" ]] && MOUNTLBL=${MOUNT##*/} || MOUNTLBL=${MOUNT}
|
|
[[ "${#MOUNTLBL}" -gt "10" ]] && MOUNTLBL=${MOUNTLBL:0:12}
|
|
[[ "${MOUNT}" = *"media"* ]] && ICON="<big></big>" || ICON="<big></big>"
|
|
|
|
[[ "${PERCENT::-1}" -ge "${disk_limit}" ]] && PERCENT="<span bgcolor='${WARN_BGCOLOR}' fgcolor='${WARN_FGCOLOR}'> ${PERCENT} </span>" || PERCENT="<span> ${PERCENT} </span>"
|
|
out+=("$ICON $MOUNTLBL <small>$DEVICE</small> $PERCENT,^pipe(jgbrowser ${MOUNT}${qdir})")
|
|
done < <(df -h | grep '^/dev' | grep -v 'boot' | grep -v 'loop' | grep -v '/run/media')
|
|
fi
|
|
|
|
## DIR SIZE MONITOR
|
|
if [[ "${dir_size_monitor}" == "y" ]];then
|
|
out+=("^sep($_DIR_SIZE_MONITOR)")
|
|
logsize=$(du -sh /var/log/journal|awk '{print $1}')
|
|
paccachesize=$(du -sh /var/cache/pacman/pkg|awk '{print $1}')
|
|
trashsize=$(du -sh ~/.local/share/Trash|awk '{print $1}')
|
|
downsize=$(du -sh $(xdg-user-dir DOWNLOAD)|awk '{print $1}')
|
|
|
|
[[ "${logsize}" == *G* ]] && logsize="<span bgcolor='${WARN_BGCOLOR}' fgcolor='${WARN_FGCOLOR}'> ${logsize} </span>" || logsize="<span> ${logsize} </span>"
|
|
if [[ "${paccachesize}" == *K* ]];then
|
|
paccachesize="<span fgcolor='${OK_FGCOLOR}'> </span>"
|
|
else
|
|
[[ "${paccachesize}" == *G* ]] && paccachesize="<span bgcolor='${WARN_BGCOLOR}' fgcolor='${WARN_FGCOLOR}'> ${paccachesize} </span>" || paccachesize="<span> ${paccachesize} </span>"
|
|
fi
|
|
if [[ "${trashsize}" == *K* ]];then
|
|
trashsize="<span fgcolor='${OK_FGCOLOR}'> </span>"
|
|
else
|
|
[[ "${trashsize}" == *G* ]] && trashsize="<span bgcolor='${WARN_BGCOLOR}' fgcolor='${WARN_FGCOLOR}'> ${trashsize} </span>" || trashsize="<span> ${trashsize} </span>"
|
|
fi
|
|
[[ "${downsize}" == *G* ]] && downsize="<span bgcolor='${WARN_BGCOLOR}' fgcolor='${WARN_FGCOLOR}'> ${downsize} </span>" || downsize="<span> ${downsize} </span>"
|
|
|
|
out+=("\"\"\"$_LOGS ${logsize}\"\"\",^checkout(logs)")
|
|
out2+=("^tag(logs)")
|
|
out2+=("^sep($_VACUUM_LOGS)")
|
|
out2+=("$_VACUUM_1DAY,mb-cli vacuum 1d")
|
|
out2+=("$_VACUUM_7DAYS,mb-cli vacuum 7d")
|
|
out2+=("$_VACUUM_200M,mb-cli vacuum 200M")
|
|
out2+=("$_VACUUM_500M,mb-cli vacuum 500M")
|
|
|
|
|
|
out+=("\"\"\"$_PACMAN_CACHE ${paccachesize}\"\"\",^checkout(paccache)")
|
|
out2+=("^tag(paccache)")
|
|
out2+=("^sep($_PACMAN_CACHE)")
|
|
out2+=("$_EMPTY_PACMAN_CACHE,mb-cli paccache_clean")
|
|
|
|
out+=("\"\"\"$_TRASH ${trashsize}\"\"\",^checkout(trash)")
|
|
out2+=("^tag(trash)")
|
|
out2+=("^sep($_TRASH)")
|
|
out2+=("$_EMPTY $_TRASH,rm -r ~/.local/share/Trash/*/*;mb-status menu")
|
|
out2+=("$_OPEN $_TRASH,pcmanfm trash://")
|
|
|
|
out+=("\"\"\"$(basename $(xdg-user-dir DOWNLOAD)) ${downsize}\"\"\",^pipe(jgbrowser $(xdg-user-dir DOWNLOAD)$qdir)")
|
|
fi
|
|
|
|
out+=("^sep()")
|
|
out+=(" $_SETTINGS,^checkout(settings)")
|
|
out2+=("^tag(settings)")
|
|
out2+=("^sep($_SETTINGS)")
|
|
[[ "$1" == "settings" ]] && out2+=("${arrow_string_left} ${arrow_string_left} ${arrow_string_left},^back()" "^sep()")
|
|
# BIG PKGS
|
|
if hash expac 2>/dev/null;then
|
|
[[ "${big_pkgs}" -gt "0" ]] && out2+=("<big></big> $_SHOW_BIGGEST,^checkout(biggest)") || out2+=("<big></big> $_SHOW_BIGGEST,^checkout(biggest)")
|
|
out3+=("^tag(biggest)")
|
|
out3+=("^sep($_HOW_MANY)")
|
|
[[ "${big_pkgs}" == "0" ]] && out3+=("<big>綠</big> 0 ($_DISABLED),mb-setvar big_pkgs=0;mb-status menu ipc") || out3+=("<big>祿</big> 0 ($_DISABLED),mb-setvar big_pkgs=0;mb-status menu ipc")
|
|
out3+=("^sep()")
|
|
[[ "${big_pkgs}" == "10" ]] && out3+=("<big>綠</big> 10,mb-setvar big_pkgs=10;mb-status menu ipc") || out3+=("<big>祿</big> 10,mb-setvar big_pkgs=10;mb-status menu ipc")
|
|
[[ "${big_pkgs}" == "20" ]] && out3+=("<big>綠</big> 20,mb-setvar big_pkgs=20;mb-status menu ipc") || out3+=("<big>祿</big> 20,mb-setvar big_pkgs=20;mb-status menu ipc")
|
|
[[ "${big_pkgs}" == "30" ]] && out3+=("<big>綠</big> 30,mb-setvar big_pkgs=30;mb-status menu ipc") || out3+=("<big>祿</big> 30,mb-setvar big_pkgs=30;mb-status menu ipc")
|
|
[[ "${big_pkgs}" == "40" ]] && out3+=("<big>綠</big> 40,mb-setvar big_pkgs=40;mb-status menu ipc") || out3+=("<big>祿</big> 40,mb-setvar big_pkgs=40;mb-status menu ipc")
|
|
fi
|
|
|
|
out2+=("^sep($_DU_ALERT_LEVEL)")
|
|
[[ "$disk_limit" == "0" ]] && out2+=("<big>綠</big> <span bgcolor='${WARN_BGCOLOR}' fgcolor='${WARN_FGCOLOR}'> 0 ($_DISABLED) </span>,mb-setvar disk_limit=0;mb-status menu settings") || out2+=("<big>祿</big> 0 ($_DISABLED),mb-setvar disk_limit=0;mb-status menu settings")
|
|
[[ "$disk_limit" == "75" ]] && out2+=("<big>綠</big> <span bgcolor='${WARN_BGCOLOR}' fgcolor='${WARN_FGCOLOR}'> 75% </span>,mb-setvar disk_limit=75;mb-status menu settings") || out2+=("<big>祿</big> 75%,mb-setvar disk_limit=75;mb-status menu settings")
|
|
[[ "$disk_limit" == "80" ]] && out2+=("<big>綠</big> <span bgcolor='${WARN_BGCOLOR}' fgcolor='${WARN_FGCOLOR}'> 80% </span>,mb-setvar disk_limit=80;mb-status menu settings") || out2+=("<big>祿</big> 80%,mb-setvar disk_limit=80;mb-status menu settings")
|
|
[[ "$disk_limit" == "85" ]] && out2+=("<big>綠</big> <span bgcolor='${WARN_BGCOLOR}' fgcolor='${WARN_FGCOLOR}'> 85% </span>,mb-setvar disk_limit=85;mb-status menu settings") || out2+=("<big>祿</big> 85%,mb-setvar disk_limit=85;mb-status menu settings")
|
|
[[ "$disk_limit" == "90" ]] && out2+=("<big>綠</big> <span bgcolor='${WARN_BGCOLOR}' fgcolor='${WARN_FGCOLOR}'> 90% </span>,mb-setvar disk_limit=90;mb-status menu settings") || out2+=("<big>祿</big> 90%,mb-setvar disk_limit=90;mb-status menu settings")
|
|
[[ "$disk_limit" == "95" ]] && out2+=("<big>綠</big> <span bgcolor='${WARN_BGCOLOR}' fgcolor='${WARN_FGCOLOR}'> 95% </span>,mb-setvar disk_limit=95;mb-status menu settings") || out2+=("<big>祿</big> 95%,mb-setvar disk_limit=95;mb-status menu settings")
|
|
out2+=("^sep($_DIR_SIZE_MONITOR)")
|
|
[[ "${dir_size_monitor}" == "y" ]] && out2+=("<big></big> $_DIR_SIZE_MONITOR,mb-setvar dir_size_monitor=n;mb-status menu settings") ||out2+=("<big></big> $_DIR_SIZE_MONITOR,mb-setvar dir_size_monitor=y;mb-status menu settings")
|
|
out2+=("^sep($_ICON_COLORS)")
|
|
icons=("" "" "" "" "" "" "")
|
|
out2+=("<span fgcolor='${OK_FGCOLOR}'><big>${OK_ICON}</big></span> $_ICON_OK,^checkout(icon)")
|
|
out3+=("^tag(icon)")
|
|
out3+=("^sep($_ICON)")
|
|
for i in ${icons[@]};do
|
|
[[ "${OK_ICON}" == "${i}" ]] && out3+=("<big>綠 <span fgcolor='${OK_FGCOLOR}'>$i</span></big>") || out3+=("<big>祿 <span fgcolor='${OK_FGCOLOR}'>$i</span></big>,mb-setvar ok_icon=${i};mb-status menu settings")
|
|
done
|
|
okcols=("#EEEEEE" "#CCCCCC" "#AAAAAA" "#222222" "#a4c400" "#60a917" "#288C44" "#008a00" "#00aba9" "#1ba1e2" "#3e65ff" "#f472d0")
|
|
warncols=("#d80073" "#a20025" "#e51400" "#fa6800" "#f0a30a" "#e3c800")
|
|
#out2+=("<span bgcolor='$OK_FGCOLOR'> </span> $_COLOR_OK,^checkout(colok)")
|
|
#out3+=("^tag(colok)")
|
|
out3+=("^sep($_COLOR)")
|
|
for i in ${okcols[@]};do
|
|
[[ "${OK_FGCOLOR}" == "${i}" ]] && out3+=("<big>綠</big> <span bgcolor='${i}'> </span>,mb-status menu settings") || out3+=("<big>祿</big> <span bgcolor='${i}'> </span>,mb-setvar ok_fgcolor=${i};mb-status menu settings")
|
|
done
|
|
out2+=("<span bgcolor='$WARN_BGCOLOR' fgcolor='$WARN_FGCOLOR'> $_WARN </span>,^checkout(colwarn)")
|
|
out3+=("^tag(colwarn)")
|
|
out3+=("^sep($_WARN)")
|
|
[[ "${WARN_BGCOLOR}" == "#bd1e24" && "${WARN_FGCOLOR}" == "#FFFFFF" ]] && out3+=("<big>綠</big> <span bgcolor='#bd1e24' fgcolor='#FFFFFF'> warning </span>,mb-status menu settings") || out3+=("<big>祿</big> <span bgcolor='#bd1e24' fgcolor='#FFFFFF'> warning </span>,mb-setvar warn_bgcolor='#bd1e24' ${CONF_FILE};mb-setvar warn_fgcolor='#FFFFFF' ${CONF_FILE};mb-status menu settings")
|
|
[[ "${WARN_BGCOLOR}" == "#e91e63" && "${WARN_FGCOLOR}" == "#FFFFFF" ]] && out3+=("<big>綠</big> <span bgcolor='#e91e63' fgcolor='#FFFFFF'> pink </span>,mb-status menu settings") || out3+=("<big>祿</big> <span bgcolor='#e91e63' fgcolor='#FFFFFF'> pink </span>,mb-setvar warn_bgcolor='#e91e63' ${CONF_FILE};mb-setvar warn_fgcolor='#FFFFFF' ${CONF_FILE};mb-status menu settings")
|
|
[[ "${WARN_BGCOLOR}" == "#ff5722" && "${WARN_FGCOLOR}" == "#FFFFFF" ]] && out3+=("<big>綠</big> <span bgcolor='#ff5722' fgcolor='#FFFFFF'> deep orange </span>,mb-status menu settings") || out3+=("<big>祿</big> <span bgcolor='#ff5722' fgcolor='#FFFFFF'> deep orange </span>,mb-setvar warn_bgcolor='#ff5722' ${CONF_FILE};mb-setvar warn_fgcolor='#FFFFFF' ${CONF_FILE};mb-status menu settings")
|
|
[[ "${WARN_BGCOLOR}" == "#ff9800" && "${WARN_FGCOLOR}" == "#000000" ]] && out3+=("<big>綠</big> <span bgcolor='#ff9800' fgcolor='#000000'> orange </span>,mb-status menu settings") || out3+=("<big>祿</big> <span bgcolor='#ff9800' fgcolor='#000000'> orange </span>,mb-setvar warn_bgcolor='#ff9800' ${CONF_FILE};mb-setvar warn_fgcolor='#000000' ${CONF_FILE};mb-status menu settings")
|
|
[[ "${WARN_BGCOLOR}" == "#f6c700" && "${WARN_FGCOLOR}" == "#000000" ]] && out3+=("<big>綠</big> <span bgcolor='#f6c700' fgcolor='#000000'> yellow </span>,mb-status menu settings") || out3+=("<big>祿</big> <span bgcolor='#f6c700' fgcolor='#000000'> yellow </span>,mb-setvar warn_bgcolor='#f6c700' ${CONF_FILE};mb-setvar warn_fgcolor='#000000' ${CONF_FILE};mb-status menu settings")
|
|
[[ "${WARN_BGCOLOR}" == "#000000" && "${WARN_FGCOLOR}" == "#FFFFFF" ]] && out3+=("<big>綠</big> <span bgcolor='#000000' fgcolor='#FFFFFF'> black </span>,mb-status menu settings") || out3+=("<big>祿</big> <span bgcolor='#000000' fgcolor='#FFFFFF'> black </span>,mb-setvar warn_bgcolor='#000000' ${CONF_FILE};mb-setvar warn_fgcolor='#FFFFFF' ${CONF_FILE};mb-status menu settings")
|
|
#for i in ${warncols[@]};do
|
|
#[[ "${COLOR_WARN}" == "${i}" ]] && out3+=("<big>綠</big> <span bgcolor='${i}'> </span>,mb-status menu settings") || out3+=("<big>祿</big> <span bgcolor='${i}'> </span>,mb-setvar color_warn=${i} ${CONF_FILE};mb-status menu settings")
|
|
#done
|
|
|
|
[[ "$1" == "settings" ]] && out2+=("^sep()" "${arrow_string_left} ${arrow_string_left} ${arrow_string_left},^back()")
|
|
|
|
|
|
. /usr/share/mb-jgtools/pipemenu-standalone.cfg
|
|
|
|
MENU_PADDING_TOP=${jgtools_padding:-0}
|
|
POSITION_MODE="center"
|
|
MENU_HALIGN="center"
|
|
MENU_VALIGN="center"
|
|
[[ "${1}" == "ipc" ]] && POSITION_MODE="ipc"
|
|
[[ "${1}" == "settings" ]] && POSITION_MODE="ipc"
|
|
#notify-send.sh "Pos" "${POSITION_MODE}"
|
|
JGWIDTH=300
|
|
TABS=190
|
|
[ $(pidof picom) ] && MENU_RADIUS=$jgtools_radius
|
|
[ -z $jgmenu_use_borders ] && menu_border=0
|
|
icons=0
|
|
iconmargin=0
|
|
mkconfigfile
|
|
echo menu_height_mode=dynamic >> ${CONFIG_FILE}
|
|
|
|
cat <<EOF > ${MENU_ITEMS}
|
|
$(printf '%s\n' "${out[@]}")
|
|
$(printf '%s\n' "${out2[@]}")
|
|
$(printf '%s\n' "${out3[@]}")
|
|
EOF
|
|
|
|
jgmenu --config-file=${CONFIG_FILE} --csv-file=${MENU_ITEMS} ${option} 2>/dev/null
|
|
}
|
|
#dnotify(){
|
|
#LINK="exo-open --launch WebBrowser maboxlinux.org/donate"
|
|
#yad --width="400" --center --height="80" --window-icon="mbcc" --borders="10" --image="emote-love" --image-on-top --title "Request for Donation" \
|
|
#--text-align="center" --text="<big>Donate to Mabox </big>" \
|
|
#--form --align="center" \
|
|
#--field="Mabox needs your help... Donations fund":LBL \
|
|
#--field="development and infrastructure":LBL \
|
|
#--field="important for Mabox's continued existence.":LBL \
|
|
#--button="Donate":"$LINK" --button="No Thanks":"0"
|
|
#}
|
|
#updates=100
|
|
status(){
|
|
#if [[ "$DIFF" -gt "1" ]];then
|
|
#DDATE=$(date +%Y-%m-%d)
|
|
#if [[ $((DIFF % 100)) == "0" ]] && [[ ! -f "$CFGDIR/.$DDATE" ]];then
|
|
#touch "$CFGDIR/.$DDATE"
|
|
#dnotify &>/dev/null
|
|
#fi
|
|
#fi
|
|
|
|
#disk space
|
|
dirty=0
|
|
if [[ "${disk_limit}" -gt "0" ]];then
|
|
while read DEVICE SIZE USED FREE PERCENT MOUNT
|
|
do
|
|
[[ "${PERCENT::-1}" -ge "${disk_limit}" ]] && dirty=1
|
|
done < <(df -h | grep '^/dev' | grep -v 'boot' | grep -v 'loop' | grep -v '/run/media')
|
|
fi
|
|
[[ "${dirty}" == 1 ]] && msg="<span fgcolor='${WARN_BGCOLOR}'> </span>" || msg="<span fgcolor='${OK_FGCOLOR}'> ${OK_ICON} </span>"
|
|
[[ "${updates}" -gt 0 ]] && msg="<span bgcolor='${WARN_BGCOLOR}' fgcolor='${WARN_FGCOLOR}'> <sup><small><b>${updates}</b></small></sup> </span>"
|
|
echo "${msg}"
|
|
}
|
|
|
|
|
|
case "$1" in
|
|
status) status;;
|
|
left) left;;
|
|
menu) menu "$2";;
|
|
esac
|