Guest User

Untitled

a guest
Sep 14th, 2020
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.81 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # simple screen information script
  4. # similar to archey and screenfetch without annoying ASCII graphics
  5.  
  6. # this script is provided with NO GUARANTEE and NO SUPPORT
  7. # if it breaks or does not do what you want, FIX IT YOURSELF
  8.  
  9. VERSION="3.4" # updated for changes to free -m
  10.  
  11. # read wm names from a file
  12. #WMLIST='/usr/bin/wmlist'
  13. #wms=($(cat $WMLIST)) # read wmlist from file
  14.  
  15. # or use wm array -- add any that need to be recognized
  16. wms=( 2bwm 2wm 9wm aewm afterstep ahwm alopex amiwm antiwm awesome blackbox bspwm catwm clfswm ctwm cwm dminiwm dragonflywm dwm echinus \
  17. euclid-wm evilpoison evilwm fluxbox flwm fvwm-crystal goomwwm hcwm herbstluftwm i3 icewm jwm karmen larswm lwm matwm2 mcwm monsterwm \
  18. musca notion nwm olwm openbox oroborus pekwm ratpoison sapphire sawfish sscrotwm sithwm smallwm snapwm spectrwm stumpwm subtle tfwm tinywm tritium twm \
  19. uwm vtwm w9wm weewm wind windowlab wm2 wmaker wmfs wmii wmx xfwm4 xmonad xoat yeahwm )
  20.  
  21. # define colors for color-echo
  22. red="\e[31m"
  23. grn="\e[32m"
  24. ylw="\e[33m"
  25. cyn="\e[36m"
  26. blu="\e[34m"
  27. prp="\e[35m"
  28. rst="\e[0m"
  29.  
  30. color-echo() { # print with colors
  31. echo -e " $ylw$1: $rst$2"
  32. }
  33.  
  34. #print-kernel() {
  35. #color-echo 'Kernel' "$(uname -smr)"
  36. #}
  37.  
  38. print-uptime() {
  39. up=$(</proc/uptime)
  40. up=${up//.*} # string before first . is seconds
  41. days=$((${up}/86400)) # seconds divided by 86400 is days
  42. hours=$((${up}/3600%24)) # seconds divided by 3600 mod 24 is hours
  43. mins=$((${up}/60%60)) # seconds divided by 60 mod 60 is mins
  44. color-echo "Uptime" $days'd '$hours'h '$mins'm'
  45. }
  46.  
  47. print-shell() {
  48. color-echo 'Shell' $SHELL
  49. }
  50.  
  51. print-cpu() {
  52. arm=$(grep ARM /proc/cpuinfo) # ARM procinfo uses different format
  53. if [[ "$arm" != "" ]]; then
  54. cpu=$(grep -m1 -i 'Processor' /proc/cpuinfo)
  55. else
  56. cpu=$(grep -m1 -i 'model name' /proc/cpuinfo)
  57. fi
  58. color-echo 'CPU' "${cpu#*: }" # everything after colon is processor name
  59. }
  60.  
  61. print-gpu() {
  62. gpu=$(lspci | grep VGA | awk -F ': ' '{print $2}' | sed 's/(rev ..)//g')
  63. color-echo 'GPU' "$gpu"
  64. }
  65.  
  66. print-packages() {
  67. packages=$(pacman -Qs | grep local | wc -l)
  68. color-echo 'Packages' "$packages"
  69. }
  70.  
  71. print-disk() {
  72. # field 2 on line 2 is total, field 3 on line 2 is used
  73. disk=$(df -h /home/ | awk 'NR==2 {total=$2; used=$3; print used" / "total}')
  74. color-echo 'Disk' "$disk"
  75. }
  76.  
  77. print-mem() {
  78. # field 2 on line 2 is total, field 3 on line 2 is used (in new format)
  79. # field 2 on line 2 is total, field 3 on line 3 is used (in old format)
  80.  
  81. if [[ $(free -h) =~ "buffers" ]]; then # using old format
  82. mem=$(free -h | awk 'NR==2 {total=$2} NR==3 {used=$3; print used" / "total}')
  83. else # using new format
  84. mem=$(free -h | awk 'NR==2 {total=$2} NR==2 {used=$3; print used" / "total}')
  85. fi
  86. color-echo 'Memory' "$mem"
  87. }
  88.  
  89. print-wm() {
  90. for wm in ${wms[@]}; do # pgrep through wmname array
  91. pid=$(pgrep -x -u $USER $wm) # if found, this wmname has running process
  92. if [[ "$pid" ]]; then
  93. color-echo 'WM' $wm
  94. break
  95. fi
  96. done
  97. }
  98.  
  99. print-de() {
  100. if [[ $(pgrep -x -u $USER lxsession) ]]; then # if lxsession is running, assume LXDE
  101. color-echo 'DE' 'LXDE'
  102. elif [ $(pgrep -x -u $USER xfce4-session) ]; then # if xfce4-session is running, assume Xfce
  103. color-echo 'DE' 'Xfce'
  104. fi
  105. }
  106.  
  107. print-distro() {
  108. [[ -e /etc/os-release ]] && source /etc/os-release
  109. if [[ -n "$PRETTY_NAME" ]]; then
  110. color-echo 'OS' "$PRETTY_NAME"
  111. else
  112. color-echo 'OS' "not found"
  113. fi
  114. }
  115.  
  116. print-colors() {
  117. NAMES=('█ black' '█ red' '█ green' '█ yellow' '█ blue' '█ magenta' '█ cyan' '█ white')
  118. for f in {0..7}; do
  119. echo -en "\033[m\033[$(($f+30))m ${NAMES[$f]}" # normal colors
  120. done
  121. echo
  122. for f in {0..7}; do
  123. echo -en "\033[m\033[1;$(($f+30))m ${NAMES[$f]}" # bold colors
  124. done
  125. echo -e "$rst\n"
  126. }
  127.  
  128. if [[ $1 = '-v' ]]; then # print version information and exit
  129. echo $(basename "$0") / version: $VERSION / wm count: ${#wms[*]}
  130. exit
  131. fi
  132.  
  133. #echo -e "\n $prp$USER@$HOSTNAME$rst\n"
  134. echo
  135. echo -en "\033[35;1m ,. ,. |\033[0m" && print-distro
  136. echo -en "\033[35;1m || || |\033[0m" && print-uptime
  137. echo -en "\033[35;1m ,''--''. |\033[0m" && print-shell
  138. echo -en "\033[35;1m : (.)(.) : |\033[0m" && print-wm
  139. echo -en "\033[35;1m ,' \`. |\033[0m" && print-packages
  140. #echo -en "\033[35;1m : : |\033[0m" && print-kernel
  141. echo -en "\033[35;1m : : |\033[0m" && print-cpu
  142. echo -en "\033[35;1m -boo- \`._m____m_,' |\033[0m" && print-gpu
  143. echo
  144. print-colors
  145. #
  146. #${redf} ▄██████▄${reset}
  147. #${redf}▄${whitef}█▀█${redf}██${whitef}█▀█${redf}██▄${reset}
  148. #${redf}█${whitef}▄▄█${redf}██${whitef}▄▄█${redf}███${reset}
  149. #${redf}████████████${reset}
  150. #${redf}██▀██▀▀██▀██${reset}
  151. #${redf}▀ ▀ ▀ ▀${reset}
  152.  
Add Comment
Please, Sign In to add comment