summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSyndamia <kamen.d.mladenov@protonmail.com>2021-06-12 21:29:51 +0300
committerSyndamia <kamen.d.mladenov@protonmail.com>2021-06-12 21:29:51 +0300
commit8aa2ff1f9fd62514de8fad0ecd437bbea97a0f84 (patch)
treece153268bbb69ebdb036dc12066577833cee2879
parent400342d7cf8858100f3d19cfa6bc29b2c67bcd16 (diff)
downloaddotfiles-8aa2ff1f9fd62514de8fad0ecd437bbea97a0f84.tar
dotfiles-8aa2ff1f9fd62514de8fad0ecd437bbea97a0f84.tar.gz
dotfiles-8aa2ff1f9fd62514de8fad0ecd437bbea97a0f84.zip
Added a toggle desktop script for lwa-hot-corners and added an app memory statistic script
-rw-r--r--.gitignore2
-rw-r--r--.lwarc2
-rwxr-xr-xapp-mem.sh29
-rwxr-xr-xtoggle-desktop.sh21
4 files changed, 53 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index baaf998..31e0340 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,6 +11,8 @@
!.xsession
!terminal.sh
!toggle_repo.sh
+!app-mem.sh
+!toggle-desktop.sh
!.local/
.local/*
diff --git a/.lwarc b/.lwarc
index eae8f1a..38fadf5 100644
--- a/.lwarc
+++ b/.lwarc
@@ -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