159 lines
6.3 KiB
Bash
Executable File
159 lines
6.3 KiB
Bash
Executable File
#!/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."
|
|
CPU_RAM="CPU ~ RAM ~ Swap | Użyte/Całość"
|
|
NETWORK="Sieć"
|
|
DOWNLOADED="pobrano"
|
|
UPLOADED="wysłano"
|
|
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"
|
|
CPU_RAM="CPU ~ RAM ~ Swap | Usados/Tamaño"
|
|
NETWORK="Red"
|
|
DOWNLOADED="downloaded"
|
|
UPLOADED="uploaded"
|
|
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:"
|
|
DF_HEADER="Filesystem ~~ Type ~~ Total ~ Used ~ Free ~ % ~ Mount"
|
|
CPU_RAM="CPU ~ RAM ~ Swap | Used/Total "
|
|
NETWORK="Network"
|
|
DOWNLOADED="downloaded"
|
|
UPLOADED="uploaded"
|
|
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)
|
|
NetworkDevice1=$(ip route | grep default | sed -e "s/^.*dev.//" -e "s/.proto.*//")
|
|
|
|
#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}' )
|
|
|
|
MemTotal=$(echo "scale = 2; ("$(grep MemTotal: /proc/meminfo | awk '{print $2}' | sed 's/k//')" /1024)" | bc)
|
|
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)
|
|
|
|
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)
|
|
|
|
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)
|
|
|
|
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")
|
|
out2+=("$NetworkDevice1 ~ $DOWNLOADED: ${NetDev1down:1:-1}")
|
|
out2+=("$NetworkDevice1 ~ $UPLOADED: ${NetDev1up:1:-1}")
|
|
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
|
|
. /usr/bin/pipemenu-standalone.cfg
|
|
|
|
MENU_PADDING_TOP=0
|
|
MENU_HALIGN="center"
|
|
MENU_VALIGN="center"
|
|
jgmenu_icon_size=0
|
|
mkconfigfile
|
|
|
|
cat <<EOF > ${MENU_ITEMS}
|
|
$(printf '%s\n' "${out[@]}")
|
|
$(df -HlT | grep -E '^/'|awk '{print "\"\"\"<tt>"$0"</tt>\"\"\",pcmanfm "$7}')
|
|
$(printf '%s\n' "${out2[@]}")
|
|
EOF
|
|
|
|
jgmenu --config-file=${CONFIG_FILE} --csv-file=${MENU_ITEMS} 2>/dev/null
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
printf '%s\n' "${out[@]}"
|
|
df -HlT | grep -E '^/'|awk '{print "\"\"\"<tt>"$0"</tt>\"\"\",pcmanfm "$7}'
|
|
printf '%s\n' "${out2[@]}"
|
|
if [ $1 == "-r" ]; then
|
|
printf '%s\n' "^sep()"
|
|
printf '%s\n' "<i>$REMOVE</i>,mb-setvar places_sysinfopipe=false"
|
|
fi
|