mabox-pipemenus/usr/bin/jgsysinfo-pipe

159 lines
6.3 KiB
Plaintext
Raw Permalink Normal View History

2020-09-17 01:27:02 +02:00
#!/bin/bash
# jgsysinfo-pipe - native jgmenu pipemenu with some system informations
#
case $LANG in
pl*)
KERNEL="Jądro:"
PKGS="Zainstalowane pakiety:"
RESOLUTION="Rozdzielczość:"
DF_HEADER="System plików ~~ Typ ~~ Rozmiar ~ Użyte ~ Wolne ~ % ~ Punkt mont."
2020-09-18 21:54:15 +02:00
CPU_RAM="CPU ~ RAM ~ Swap | Użyte/Całość"
2020-09-17 01:27:02 +02:00
NETWORK="Sieć"
2020-09-21 14:43:15 +02:00
DOWNLOADED="pobrano"
UPLOADED="wysłano"
2020-09-17 01:27:02 +02:00
DATETIME="Data ~ Godzina"
DATE="Data:"
WEEK="Tydzień:"
DAY="Dzień:"
TIME="Godzina:"
REMOVE="Usuń to menu z panelu"
;;
es*)
KERNEL="Kernel"
PKGS="Paquetes instalados:"
RESOLUTION="Resolución:"
DF_HEADER="S.ficheros ~ Tipo ~ Tamaño ~ Usados ~ Disp ~ % ~ Montado en"
2020-09-18 21:54:15 +02:00
CPU_RAM="CPU ~ RAM ~ Swap | Usados/Tamaño"
2020-09-17 01:27:02 +02:00
NETWORK="Red"
2020-09-21 14:43:15 +02:00
DOWNLOADED="downloaded"
UPLOADED="uploaded"
2020-09-17 01:27:02 +02:00
DATETIME="Fecha ~ Hora"
DATE="Fecha:"
WEEK="Semana:"
DAY="Día:"
TIME="Hora:"
REMOVE="Eliminar este menú del panel"
;;
*)
KERNEL="Kernel:"
PKGS="Installed pkgs:"
RESOLUTION="Resolution:"
2020-09-18 21:54:15 +02:00
DF_HEADER="Filesystem ~~ Type ~~ Total ~ Used ~ Free ~ % ~ Mount"
2020-09-17 01:27:02 +02:00
CPU_RAM="CPU ~ RAM ~ Swap | Used/Total "
NETWORK="Network"
2020-09-21 14:43:15 +02:00
DOWNLOADED="downloaded"
UPLOADED="uploaded"
2020-09-17 01:27:02 +02:00
DATETIME="Date ~ Time"
DATE="Data:"
WEEK="Week:"
DAY="Day:"
TIME="Time:"
REMOVE="Remove this menu from panel"
;;
esac
Host=$(uname -n)
System=$(uname -s)
Release=$(uname -r)
Arch=$(uname -m)
Lsb_rel=$(lsb_release -rs)
Lsb_code=$(lsb_release -cs)
2020-09-17 22:51:14 +02:00
NetworkDevice1=$(ip route | grep default | sed -e "s/^.*dev.//" -e "s/.proto.*//")
2020-09-17 01:27:02 +02:00
2020-09-18 21:54:15 +02:00
#NetDev1ip=$(ip address | grep '192.168' | awk '{ print $2}' | sed s:\/.*::g)
NetDev1ip=$(ip address | grep "$NetworkDevice1$" | awk '{ print $2}' | sed s:\/.*::g)
NetDev1down=$(/sbin/ifconfig "$NetworkDevice1" | grep "RX packets" |awk '{print $6,$7}')
NetDev1up=$(/sbin/ifconfig "$NetworkDevice1" | grep "TX packets" |awk '{print $6,$7}' )
2020-09-17 01:27:02 +02:00
MemTotal=$(echo "scale = 2; ("$(grep MemTotal: /proc/meminfo | awk '{print $2}' | sed 's/k//')" /1024)" | bc)
2020-09-17 22:51:14 +02:00
MemFree=$(echo "scale = 2; ("$(grep MemFree: /proc/meminfo | awk '{print $2}' | sed 's/k//')" /1024) + ("$(grep -m 1 Cached: /proc/meminfo | awk '{print $2}' | sed 's/k//')" /1024)" | bc)
MemUsed=$(echo "scale = 2; ("$(grep MemTotal: /proc/meminfo | awk '{print $2}' | sed 's/k//')" /1024) - (("$(grep MemFree: /proc/meminfo | awk '{print $2}' | sed 's/k//')" /1024) + ("$(grep -m 1 Cached: /proc/meminfo | awk '{print $2}' | sed 's/k//')" /1024))" | bc)
2020-09-17 01:27:02 +02:00
SwpTotal=$(echo "scale = 2; ("$(grep SwapTotal: /proc/meminfo | awk '{print $2}' | sed 's/k//')" /1024)" | bc)
SwpFree=$(echo "scale = 2; ("$(grep SwapFree: /proc/meminfo | awk '{print $2}' | sed 's/k//')" /1024)" | bc)
SwpUsed=$(echo "scale = 2; ("$(grep SwapTotal: /proc/meminfo | awk '{print $2}' | sed 's/k//')" /1024) - ("$(cat /proc/meminfo | grep SwapFree: | awk '{print $2}' | sed 's/k//')" /1024)" | bc)
2020-09-17 22:51:14 +02:00
MemUsedPercent=$(echo "scale = 2; (("$(grep MemTotal: /proc/meminfo | awk '{print $2}' | sed 's/k//')" /1024) - (("$(grep MemFree: /proc/meminfo | awk '{print $2}' | sed 's/k//')" /1024) + ("$(grep -m 1 Cached: /proc/meminfo | awk '{print $2}' | sed 's/k//')" /1024))) / ("$(cat /proc/meminfo | grep MemTotal: | awk '{print $2}' | sed 's/k//')" /1024) *100" | bc)
SwpUsedPercent=$(echo "scale = 2; (("$(grep SwapTotal: /proc/meminfo | awk '{print $2}' | sed 's/k//')" /1024) - ("$(grep SwapFree: /proc/meminfo | awk '{print $2}' | sed 's/k//')" /1024)) / ("$(grep SwapTotal: /proc/meminfo | awk '{print $2}' | sed 's/k//')" /1024) *100" | bc)
2020-09-17 01:27:02 +02:00
CPUmodel=$(grep -m 1 "model name" /proc/cpuinfo | sed 's/.*: //')
CPUfreq=$(grep -m 1 "cpu MHz" /proc/cpuinfo | sed 's/.*: //')
CPUcache=$(grep -m 1 "cache size" /proc/cpuinfo | sed 's/.*: //')
DateDate=$(date '+Date ~ %Y.%m.%d. (%a)')
DateWeek=$(date '+Week ~ %W')
DateDay=$(date '+ Day ~ %j')
DateTime=$(date '+Time ~ %H:%M [%Z]')
UpTime=$(uptime | sed 's/.* up //' | sed 's/[0-9]* us.*//' | sed 's/ day, /d/' | sed 's/ days, /d /' | sed 's/:/h /' | sed 's/ min//'| sed 's/,/m/' | sed 's/ / /')
out+=("^sep($USER @ $Host)")
#out+=("Mabox Linux $Lsb_rel <i>$Lsb_code</i>")
out+=("$(printf "<tt>%+30s</tt> %s,%s" "$KERNEL" "$Release" "manjaro-settings-manager -m msm_kernel")")
out+=("$(printf "<tt>%+29s</tt> %s,%s" "$PKGS" "$(pacman -Q|wc -l)" "pamac-manager")")
out+=("$(printf "<tt>%+31s</tt> %s,%s" "$RESOLUTION" "$(xdpyinfo | awk '/^ +dimensions/ {print $2}')" "arandr")")
out+=("^sep($DF_HEADER)")
#out+=("$(df -HlT | grep -E '^/')")
#df -HlT | grep -E '^/' | while read line ; do
#out+=("$(printf "<tt>%s %s %s %s %s %s %s</tt>" "$line")")
#done
##out+=("<tt>$SizeMountPoint1</tt>")
#out+=("<tt>$SizeMountPoint2</tt>")
out2+=("^sep($CPU_RAM)")
out2+=("RAM used: $MemUsed MB/$MemTotal MB ~ $MemUsedPercent%")
out2+=("Swp used: $SwpUsed MB/$SwpTotal MB ~ $SwpUsedPercent%")
out2+=("^sep()")
out2+=("CPU ~ $CPUmodel")
out2+=("CPU @ $CPUfreq MHz ~ CPU Cache: $CPUcache")
out2+=("^sep($NETWORK ~ "$NetworkDevice1" ")
out2+=("$NetworkDevice1 ~ ip: $NetDev1ip")
2020-09-21 14:43:15 +02:00
out2+=("$NetworkDevice1 ~ $DOWNLOADED: ${NetDev1down:1:-1}")
out2+=("$NetworkDevice1 ~ $UPLOADED: ${NetDev1up:1:-1}")
2020-09-17 01:27:02 +02:00
out2+=("^sep($DATETIME)")
out2+=("$(printf "<tt>%+29s</tt> %s" $DATE "$(date '+%Y.%m.%d (%a)')")")
out2+=("$(printf "<tt>%+30s</tt> %s" $WEEK "$(date '+%W')")")
out2+=("$(printf "<tt>%+30s</tt> %s" $DAY "$(date '+%j')")")
out2+=("$(printf "<tt>%+29s</tt> %s" $TIME "$(date '+%H:%M [%Z]')")")
out2+=("^sep()")
out2+=("$(printf "<tt>%+29s</tt> %s" Uptime: "$UpTime")")
### RUN
if [ $1 == "-s" ]; then
2021-09-24 01:40:09 +02:00
. /usr/share/mb-jgtools/pipemenu-standalone.cfg
2020-09-17 01:27:02 +02:00
MENU_PADDING_TOP=0
MENU_HALIGN="center"
MENU_VALIGN="center"
jgmenu_icon_size=0
mkconfigfile
cat <<EOF > ${MENU_ITEMS}
$(printf '%s\n' "${out[@]}")
2021-01-14 18:55:20 +01:00
$(df -HlT | grep -E '^/'|awk '{print "\"\"\"<tt>"$0"</tt>\"\"\",^pipe(jgbrowser "$7")"}')
2020-09-17 01:27:02 +02:00
$(printf '%s\n' "${out2[@]}")
EOF
jgmenu --config-file=${CONFIG_FILE} --csv-file=${MENU_ITEMS} 2>/dev/null
exit 0
fi
printf '%s\n' "${out[@]}"
2021-01-14 18:55:20 +01:00
df -HlT | grep -E '^/'|awk '{print "\"\"\"<tt>"$0"</tt>\"\"\",^pipe(jgbrowser "$7")"}'
2020-09-17 01:27:02 +02:00
printf '%s\n' "${out2[@]}"
2020-09-21 14:43:15 +02:00
if [ $1 == "-r" ]; then
2020-09-18 21:54:15 +02:00
printf '%s\n' "^sep()"
2021-05-23 10:20:13 +02:00
printf '%s\n' "<i>$REMOVE</i>,mb-setvar places_sysinfopipe=false;mb-jgtools places"
2020-09-21 14:43:15 +02:00
fi