dotfiles

Mahdi's dotfiles
git clone git://mahdi.pw/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

metch (3621B)


      1 #!/bin/sh
      2 
      3 # Import info
      4 . /etc/os-release
      5 
      6 # Get info functions
      7 Name() {
      8     read -r host < /etc/hostname
      9     printf "%s@%s" "$USER" "$host"
     10 }
     11 Os() {
     12     printf "%s" "$NAME"
     13 }
     14 Kernel() {
     15     read -r _ _ kern _ < /proc/version
     16     kern="$(printf '%s' "$kern" | sed 's|-.*||')"
     17     printf "%s" "$kern"
     18 }
     19 Uptime() {
     20     IFS=. read -r up _ < /proc/uptime
     21     DAYS="$((up/60/60/24))"
     22     HOURS="$((up/60/60%24))"
     23     MINS="$((up/60%60))"
     24     SECS="$((up%60))"
     25     if [ "$DAYS" -gt 0 ]; then
     26         printf "%dD %dH %dM" "$DAYS" "$HOURS" "$MINS"
     27     elif [ "$HOURS" -gt 0 ]; then
     28         printf "%dH %dM" "$HOURS" "$MINS"
     29     elif [ "$MINS" -gt 0 ]; then
     30         printf "%dM" "$MINS"
     31     else
     32         printf "%dS" "$SECS"
     33     fi
     34 }
     35 Shell() {
     36     printf "%s" "${SHELL##*/}"
     37 }
     38 Desktop() {
     39     if [ "$DESKTOP_SESSION" != "" ]; then
     40         printf "%s\n" "$DESKTOP_SESSION"
     41     elif [ "$XDG_CURRENT_DESKTOP" != "" ]; then
     42         printf "%s\n" "$XDG_CURRENT_DESKTOP"
     43     elif [ "$DISPLAY" != "" ]; then
     44         id="$(xprop -root -notype | awk '$1=="_NET_SUPPORTING_WM_CHECK:"{print $5}')"
     45         xprop -id "${id}" -notype -f _NET_WM_NAME 8t | grep "_NET_WM_NAME = " | \
     46         cut -d ' ' -f3 | cut -d '"' -f 2
     47     else
     48         printf "%s\n" "Unknown"
     49     fi
     50 }
     51 Memory() {
     52     mem_total="$(awk '/MemTotal/ {print $2}' /proc/meminfo)"
     53     mem_used="$(awk '/MemFree/{free=$2} /Buffers/{buff=$2} /^Cached/{cached=$2} /SReclaimable/{rec=$2} /MemTotal/{total=$2} END{print (total-free-buff-cached-rec)}' /proc/meminfo)"
     54     printf "%dMiB / %dMiB" "$((mem_used/1024))" "$((mem_total/1024))"
     55 }
     56 
     57 printf '\033[1;35m%s\033[0m' "     _____              "
     58 printf '\033[34m     OS\033[0m \033[35m~\033[0m %s\n' "$(Os)"
     59 printf '\033[1;35m%s\033[0m' "   .'     \`.            "
     60 printf '\033[34m  Shell\033[0m \033[35m~\033[0m %s\n' "$(Shell)"
     61 printf '\033[1;35m%s\033[0m' "  /  .-=-.  \   \ __    "
     62 printf '\033[34m  DE/WM\033[0m \033[35m~\033[0m %s\n' "$(Desktop)"
     63 printf '\033[1;35m%s\033[0m' "  | (  C\ \  \_.'')     "
     64 printf '\033[34m Kernel\033[0m \033[35m~\033[0m %s\n' "$(Kernel)"
     65 printf '\033[1;35m%s\033[0m' " _\  \`--' |,'   _/      "
     66 printf '\033[34m Uptime\033[0m \033[35m~\033[0m %s\n' "$(Uptime)"
     67 printf '\033[1;35m%s\033[0m' "/__\`.____.'__.-'        "
     68 printf '\033[34m Memory\033[0m \033[35m~\033[0m %s\n' "$(Memory)"
     69 printf '\t\t\t'
     70 for i in 0 1 2 3 4 5 6 7; do
     71     printf '\033[3%sm%s\033[0m' "$i" "  "
     72 done
     73 printf '\n\t\t\t'
     74 for i in 0 1 2 3 4 5 6 7; do
     75     printf '\033[1;9%sm%s\033[0m' "$i" "  "
     76 done
     77 printf '\n'
     78 
     79 #printf "%s     _____              %sOs:%s\t%s\n"      "$(c 1 97)" "$(c 0 31)" "$(c 1 91)" "$(Os)$(c 0 0)"
     80 #printf "%s   .'     \`.            %sKernel:%s\t%s\n" "$(c 1 97)" "$(c 0 32)" "$(c 1 92)" "$(Kernel)$(c 0 0)"
     81 #printf "%s  /  .-=-.  \   \ __    %sUptime:%s\t%s\n"  "$(c 1 97)" "$(c 0 33)" "$(c 1 93)" "$(Uptime)$(c 0 0)"
     82 #printf "%s  | (  C\ \  \_.'')     %sShell:%s\t%s\n"   "$(c 1 97)" "$(c 0 34)" "$(c 1 94)" "$(Shell)$(c 0 0)"
     83 #printf "%s _\  \`--' |,'   _/      %sDE/WM:%s\t%s\n"  "$(c 1 97)" "$(c 0 35)" "$(c 1 95)" "$(Desktop)$(c 0 0)"
     84 #printf "%s/__\`.____.'__.-'        %sMemory:%s\t%s\n" "$(c 1 97)" "$(c 0 36)" "$(c 1 96)" "$(Memory)$(c 0 0)"
     85 #printf "\n"
     86 #printf "\t\t\t$(c 0 30)● $(c 0 0) $(c 0 31)● $(c 0 0) $(c 0 32)● $(c 0 0) $(c 0 33)● $(c 0 0) $(c 0 34)● $(c 0 0) $(c 0 35)● $(c 0 0) $(c 0 36)● $(c 0 0) $(c 0 37)● $(c 0 0)"
     87 #printf "\n"
     88 #printf "\t\t\t$(c 1 90)● $(c 0 0) $(c 1 91)● $(c 0 0) $(c 1 92)● $(c 0 0) $(c 1 93)● $(c 0 0) $(c 1 94)● $(c 0 0) $(c 1 95)● $(c 0 0) $(c 1 96)● $(c 0 0) $(c 1 97)● $(c 0 0)"
     89 #[ "$1" = "eof" ] || printf "\n"