summaryrefslogtreecommitdiff
path: root/ar/.local/bin/statusbar/sb-memory
blob: 3c9dd037187d4c354c6e8022c4a1500e05b37634 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/sh

case $BLOCK_BUTTON in
1) notify-send "🐏 Memory hogs" "$(ps axch -o cmd,%mem | awk '{cmd[$1]+=$2} END {for (i in cmd) print i, cmd[i]}' | sort -nrk2 | head)" ;;
2) setsid -f "$TERMINAL" -e htop ;;
3) notify-send "🐏 Memory module" "\- Shows Memory used/total
- Left click to show memory hogs
- Middle click to open htop" ;;
6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;;
esac

width=$(xrandr | grep "\*" | awk '{print $1}' | sed 's/x[0-9]*//g' | head -n1)
nvme_temp=$(sensors 2>/dev/null |
  awk '/Composite:/ {gsub(/[+°C]/,"",$2); print $2; exit}')

if [ -n "$width" ] && [ "$width" -eq "$width" ] 2>/dev/null; then
  if [ "$width" -lt 1920 ]; then
    free --mebi | sed -n '2{p;q}' |
      awk -v t="$nvme_temp" '{printf "🌡%s° 🐏%d%%\n", t, ($3/$2)*100+0.5}'
  else
    free --mebi | sed -n '2{p;q}' |
      awk -v t="$nvme_temp" '{printf "🌡%s° 🐏%dGB/%dGB", t, $3/1000+0.5, $2/1000+0.5}'
  fi
fi