sysinfo + keys pipemenus

master
Daniel Napora 2020-09-17 01:27:02 +02:00
parent 8e092038bd
commit 5525a7e7b0
2 changed files with 280 additions and 0 deletions

127
usr/bin/jgkeys-pipe 100755
View File

@ -0,0 +1,127 @@
#!/bin/bash
# jgkeys-pipe - native jgmenu pipemenu with keyboard shortcuts
#
case $LANG in
pl*)
APPS="Aplikacje"
FILEMNGR="Menadżer plików"
BROWSER="Przeglądarka WWW"
TERMINAL="Terminal"
EDITOR="Edytor tekstu"
FSEARCH="Wyszukiwanie plików"
PANELS="Menu/Panele boczne"
M_MAIN="Główne menu"
M_SETTINGS="Menu ustawień"
PLACES="Lewy (miejsca)"
RIGHT="Prawy (ustawienia/pomoc)"
LOCK="Blokada ekranu"
EXIT="Wyloguj..."
REMOVE="Usuń to menu z panelu"
;;
es*)
APPS=""
FILEMNGR=""
BROWSER=""
TERMINAL=""
EDITOR=""
FSEARCH=""
PANELS=""
M_MAIN=""
M_SETTINGS=""
PLACES=""
RIGHT=""
LOCK=""
EXIT=""
REMOVE="Eliminar este menú del panel"
;;
*)
APPS="Applications"
FILEMNGR="File Manager"
BROWSER="WWW browser"
TERMINAL="Terminal"
EDITOR="Text Editor"
FSEARCH="FSearch"
PANELS="Menu/SidePanels"
M_MAIN="Main Menu"
M_SETTINGS="Settings Menu"
PLACES=""
RIGHT=""
LOCK="Lock screen"
EXIT="Exit Dialog"
REMOVE="Remove this menu from panel"
;;
esac
if [ $1 == "-s" ]; then
. $HOME/.config/mabox/mabox.conf
jgmenu_theme=${jgmenu_theme:-obtheme}
case $jgmenu_theme in
default)
export color_norm_fg="#FFFFFF "
;;
obtheme)
export color_title_fg="#FFFFFF "
ob_file=$HOME/.config/openbox/rc.xml
[[ -f $ob_file ]] && wm_theme=$(awk '/<theme>/ {while (getline n) {if (match(n, /<name>/)){l=n; exit}}} END {split(l, a, "[<>]"); print a[3]}' "$ob_file")
while read -r a b c
do
[[ -n "$a" && "$a" != [[:blank:]#]* ]] && export "$a$b$c"
done < $HOME/.config/mabox/jgobthemes/$wm_theme.colorrc
;;
*)
export color_norm_fg="#FFFFFF "
while read -r a b c
do
[[ -n "$a" && "$a" != [[:blank:]#]* ]] && export "$a$b$c"
done < $HOME/.config/mabox/jgobthemes/$jgmenu_theme.colorrc
;;
esac
menu_font_size=${menu_font_size:-9}
menu_font_family=${menu_font_family:-Noto Sans Medium}
jgmenu_font="${menu_font_family} ${menu_font_size}"
fi
out+=("^sep($APPS)")
out+=("$(printf "<tt>%-10s</tt> %s,%s" "W-f" "$FILEMNGR" "exo-open --launch FileManager")")
out+=("$(printf "<tt>%-10s</tt> %s,%s" "W-w" "$BROWSER" "exo-open --launch WebBrowser")")
out+=("$(printf "<tt>%-10s</tt> %s,%s" "W-t" "$TERMINAL" "exo-open --launch TerminalEmulator")")
out+=("$(printf "<tt>%-10s</tt> %s,%s" "W-e" "$EDITOR" geany)")
out+=("$(printf "<tt>%-10s</tt> %s,%s" "W-/" "$FSEARCH" fsearch)")
out+=("^sep($PANELS)")
out+=("$(printf "<tt>%-10s</tt> %s,%s" "W" "$M_MAIN" "mb-jgtools main")")
out+=("$(printf "<tt>%-10s</tt> %s,%s" "W-s" "$M_SETTINGS" "mb-jgtools settings")")
out+=("$(printf "<tt>%-10s</tt> %s,%s" "C-tab" "$PLACES" "mb-jgtools places")")
out+=("$(printf "<tt>%-10s</tt> %s,%s" "W-tab" "$RIGHT" "mb-jgtools right")")
out+=("$(printf "<tt>%-10s</tt> %s,%s" "W-l" "$LOCK" "betterlockscreen -l")")
out+=("$(printf "<tt>%-10s</tt> %s,%s" "W-x" "$EXIT" "mb-jgtools mblogout")")
### 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[@]}")
EOF
jgmenu --config-file=${CONFIG_FILE} --csv-file=${MENU_ITEMS} 2>/dev/null
exit 0
fi
printf '%s\n' "${out[@]}"

View File

@ -0,0 +1,153 @@
#!/bin/bash
# jgsysinfo-pipe - native jgmenu pipemenu with some system informations
#
#settings
MountPoint1=/dev/sda1
MountPoint2=/dev/sdb1
NetworkDevice1=enp0s19f2u6
#settings
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ć"
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"
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"
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)
SizeMountPoint1=$(df -HlT | grep "$MountPoint1")
SizeMountPoint2=$(df -HlT | grep "$MountPoint2")
NetDev1ip=$(ip address | grep '192.168' | awk '{ print $2}' | sed s:\/.*::g)
NetDev1down=$(/sbin/ifconfig "$NetworkDevice1" | grep "RX packets" |awk '{print $6}')
NetDev1up=$(/sbin/ifconfig "$NetworkDevice1" | grep "TX packets" |awk '{print $6}' )
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) + ("$(cat /proc/meminfo | grep grep -m 1 Cached: | awk '{print $2}' | sed 's/k//')" /1024)" | bc)
MemUsed=$(echo "scale = 2; ("$(grep MemTotal: /proc/meminfo | awk '{print $2}' | sed 's/k//')" /1024) - (("$(cat /proc/meminfo | grep MemFree: | awk '{print $2}' | sed 's/k//')" /1024) + ("$(cat /proc/meminfo | grep -m 1 Cached: | 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) - (("$(cat /proc/meminfo | grep MemFree: | awk '{print $2}' | sed 's/k//')" /1024) + ("$(cat /proc/meminfo | grep -m 1 Cached: | 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) - ("$(cat /proc/meminfo | grep SwapFree: | awk '{print $2}' | sed 's/k//')" /1024)) / ("$(cat /proc/meminfo | grep SwapTotal: | 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} MB")
out2+=("$NetworkDevice1 ~ uploaded: ${NetDev1up:1} MB")
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
. $HOME/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[@]}"