diff options
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | .lwarc | 2 | ||||
| -rwxr-xr-x | app-mem.sh | 29 | ||||
| -rwxr-xr-x | toggle-desktop.sh | 21 |
4 files changed, 53 insertions, 1 deletions
@@ -11,6 +11,8 @@ !.xsession !terminal.sh !toggle_repo.sh +!app-mem.sh +!toggle-desktop.sh !.local/ .local/* @@ -1,5 +1,5 @@ bottom_left_command=gnome-system-monitor -bottom_right_command=if xprop -root _NET_SHOWING_DESKTOP|egrep '= 1' ; then wmctrl -k off; else wmctrl -k on ;fi +bottom_right_command=/home/kamen/toggle-desktop.sh $PPID hold_duration=0 update_interval=100 disable_on_fullscreen=false diff --git a/app-mem.sh b/app-mem.sh new file mode 100755 index 0000000..96264a5 --- /dev/null +++ b/app-mem.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# Huge thanks to https://askubuntu.com/a/549534/1085672 and https://www.zyxware.com/articles/4446/show-total-memory-usage-by-each-application-in-your-ubuntu-or-any-gnu-linux-system + +ps -A --sort -rss -o comm,pmem,rss | awk ' + NR == 1 { print; next } + { a[$1] += $2; b[$1] += $3; } + END { + for (i in a) { + size_in_bytes = b[i] * 1024 + split("B KB MB GB TB PB", unit) + human_readable = 0 + if (size_in_bytes == 0) { + human_readable = 0 + j = 0 + } + else { + for (j = 5; human_readable < 1; j--) + human_readable = size_in_bytes / (2^(10*j)) + } + printf "%-20s\t%s\t%.2f%s\t%s\n", i, a[i], human_readable, unit[j+2], b[i] + } + } +' | awk 'NR>1' | sort -rnk4 | awk ' + BEGIN {printf "%-20s\t%%MEM\tSIZE\n", "COMMAND"} + { + printf "%-20s\t%s\t%s\n", $1, $2, $3 + } +' diff --git a/toggle-desktop.sh b/toggle-desktop.sh new file mode 100755 index 0000000..f6e8843 --- /dev/null +++ b/toggle-desktop.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +if [ -s /tmp/lwa.lock ]; then + # On my system, lwa-hot-corners sometimes creates many instances of itself + # This way, I kill the unnecessary processes + # WORKS ONLY when I give the script $PPID as first argument (refer to .lwarc) + kill -KILL $1 + exit +fi + +echo "Running" > /tmp/lwa.lock + +if xprop -root _NET_SHOWING_DESKTOP | egrep '= 1' > /dev/null; then + wmctrl -k off +else + wmctrl -k on +fi + +sleep 0.2 + +rm /tmp/lwa.lock |
