summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaumit Dinesan <justsaumit@protonmail.com>2022-10-01 00:56:51 +0530
committerSaumit Dinesan <justsaumit@protonmail.com>2022-10-01 00:56:51 +0530
commitded37b8f6515772648527fe2a3e9d9d490066ca0 (patch)
tree9f2fe68e715f67bc6685b9e2e14a9947c479bfa8
parent7ce96f4805774b256b4d1f1f7be89ae182dbceca (diff)
minimizing scripts + replacing emojis for fonticons
-rwxr-xr-x.scripts/battery8
-rwxr-xr-x.scripts/clock34
-rwxr-xr-x.scripts/cpu_py2
-rwxr-xr-x.scripts/cputemp10
-rwxr-xr-x.scripts/memory11
-rwxr-xr-x.scripts/nettraf10
-rwxr-xr-x.scripts/setbg3
l---------[-rwxr-xr-x].scripts/st-copyout10
l---------[-rwxr-xr-x].scripts/st-urlhandler20
-rwxr-xr-x.scripts/volume22
10 files changed, 41 insertions, 89 deletions
diff --git a/.scripts/battery b/.scripts/battery
index ab01b9b..1f33383 100755
--- a/.scripts/battery
+++ b/.scripts/battery
@@ -13,10 +13,10 @@ for battery in /sys/class/power_supply/BAT?*; do
if [ "$capacity" -ge 75 ] && [ "$capacity" -le 100 ]
then
capacity_lvl=" "
- elif [ 51<="$capacity" && "$capacity"<=75 ]
+ elif [ "$capacity" -ge 51 ] && [ "$capacity" -le 75 ]
then
capacity_lvl=" "
- elif [ 25<="$capacity" && "$capacity"<=50 ]
+ elif [ "$capacity" -ge 25 ] && [ "$capacity" -le 50 ]
then
capacity_lvl=" "
else
@@ -25,10 +25,10 @@ for battery in /sys/class/power_supply/BAT?*; do
# Sets up the status and capacity
case "$(cat "$battery/status" 2>&1)" in
- "Full") status="⚡" ;;
+ "Full") status="" ;;
# "Discharging") status="$capacity-level" ;;
"Discharging") status="$capacity_lvl" ;;
- "Charging") status="🔌" ;;
+ "Charging") status=" " ;;
"Not charging") status="🛑" ;;
"Unknown") status="🟢" ;;
*) exit 1 ;;
diff --git a/.scripts/clock b/.scripts/clock
index d25e8d0..d6a91fb 100755
--- a/.scripts/clock
+++ b/.scripts/clock
@@ -3,27 +3,19 @@
clock=$(date '+%I')
case "$clock" in
- "00") icon="🕛" ;;
- "01") icon="🕐" ;;
- "02") icon="🕑" ;;
- "03") icon="🕒" ;;
- "04") icon="🕓" ;;
- "05") icon="🕔" ;;
- "06") icon="🕕" ;;
- "07") icon="🕖" ;;
- "08") icon="🕗" ;;
- "09") icon="🕘" ;;
- "10") icon="🕙" ;;
- "11") icon="🕚" ;;
- "12") icon="🕛" ;;
-esac
-
-case $BLOCK_BUTTON in
- 1) notify-send "This Month" "$(cal --color=always | sed "s/..7m/<b><span color=\"red\">/;s/..27m/<\/span><\/b>/")" && notify-send "Appointments" "$(calcurse -d3)" ;;
- 2) setsid -f "$TERMINAL" -e calcurse ;;
- 3) notify-send "📅 Time/date module" "\- Left click to show upcoming appointments for the next three days via \`calcurse -d3\` and show the month via \`cal\`
-- Middle click opens calcurse if installed" ;;
- 6) "$TERMINAL" -e "$EDITOR" "$0" ;;
+ "00") icon=" " ;;
+ "01") icon=" " ;;
+ "02") icon=" " ;;
+ "03") icon=" " ;;
+ "04") icon=" " ;;
+ "05") icon=" " ;;
+ "06") icon=" " ;;
+ "07") icon=" " ;;
+ "08") icon=" " ;;
+ "09") icon=" " ;;
+ "10") icon=" " ;;
+ "11") icon=" " ;;
+ "12") icon=" " ;;
esac
date "+%Y %b %d (%a) $icon%I:%M%p"
diff --git a/.scripts/cpu_py b/.scripts/cpu_py
new file mode 100755
index 0000000..64edafe
--- /dev/null
+++ b/.scripts/cpu_py
@@ -0,0 +1,2 @@
+#!/bin/sh
+printf "%b" "import psutil\nprint('{}%'.format(psutil.cpu_percent(interval=2)))" | python3 | awk '{printf (" %2.1f%",($1))}'
diff --git a/.scripts/cputemp b/.scripts/cputemp
new file mode 100755
index 0000000..02578a9
--- /dev/null
+++ b/.scripts/cputemp
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+sensors | awk '/Core 0/ {print " " $3}' | sed 's/+//g'
+##
+##
+##
+##
+##
+##
+##
diff --git a/.scripts/memory b/.scripts/memory
index 6a8fe0b..9913da8 100755
--- a/.scripts/memory
+++ b/.scripts/memory
@@ -1,12 +1,3 @@
#!/bin/sh
-case $BLOCK_BUTTON in
- 1) notify-send "🧠 Memory hogs" "$(ps axch -o cmd:15,%mem --sort=-%mem | head)" ;;
- 2) setsid -f "$TERMINAL" -e htop ;;
- 3) notify-send "🧠 Memory module" "\- Shows Memory Used/Total.
-- Click to show memory hogs.
-- Middle click to open htop." ;;
- 6) "$TERMINAL" -e "$EDITOR" "$0" ;;
-esac
-
-free --mebi | sed -n '2{p;q}' | awk '{printf ("🧠%2.1fGB/16GB\n", ( $3 / 1024))}'
+free --mebi | sed -n '2{p;q}' | awk '{printf ("ﳔ %2.1fGB/16GB\n", ( $3 / 1024))}'
diff --git a/.scripts/nettraf b/.scripts/nettraf
index eb7a73b..f68d4c1 100755
--- a/.scripts/nettraf
+++ b/.scripts/nettraf
@@ -4,13 +4,6 @@
# transmitted (TX) since the previous time this script ran. So if run every
# second, gives network traffic per second.
-case $BLOCK_BUTTON in
- 1) setsid -f "$TERMINAL" -e bmon ;;
- 3) notify-send "🌐 Network traffic module" "🔻: Traffic received
-🔺: Traffic transmitted" ;;
- 6) "$TERMINAL" -e "$EDITOR" "$0" ;;
-esac
-
update() {
sum=0
for arg; do
@@ -26,4 +19,5 @@ update() {
rx=$(update /sys/class/net/[ew]*/statistics/rx_bytes)
tx=$(update /sys/class/net/[ew]*/statistics/tx_bytes)
-printf "🔻%4sB 🔺%4sB\\n" $(numfmt --to=iec $rx) $(numfmt --to=iec $tx)
+printf " %4sB  %4sB\\n" $(numfmt --to=iec $rx) $(numfmt --to=iec $tx)
+
diff --git a/.scripts/setbg b/.scripts/setbg
index e01527c..6681c9f 100755
--- a/.scripts/setbg
+++ b/.scripts/setbg
@@ -15,7 +15,8 @@ echo "Generating pywal color schemes..."
wal -n -i $wall >/dev/null &&
echo "dwm reading Xresources color values at runtime"
xdotool key super+F5
-$HOME/.local/usr/wal-telegram/wal-telegram -r 2> /dev/null &
+ [[ $(ps -u $USER -o comm | grep "telegram") = "telegram-deskto" ]] && r="-r"
+ $HOME/.local/usr/wal-telegram/wal-telegram "$r" 2> /dev/null &
ln -sf ~/.cache/wal/dunstrc ~/.config/dunst/dunstrc
pkill dunst &&
dunst 2> /dev/null &
diff --git a/.scripts/st-copyout b/.scripts/st-copyout
index 220bff1..e822e4a 100755..120000
--- a/.scripts/st-copyout
+++ b/.scripts/st-copyout
@@ -1,9 +1 @@
-#!/bin/sh
-tmpfile=$(mktemp /tmp/st-cmd-output.XXXXXX)
-trap 'rm "$tmpfile"' 0 1 15
-sed -n "w $tmpfile"
-sed -i 's/\x0//g' "$tmpfile"
-ps1="$(grep "\S" "$tmpfile" | tail -n 1 | sed 's/^\s*//' | cut -d' ' -f1)"
-chosen="$(grep -F "$ps1" "$tmpfile" | sed '$ d' | tac | dmenu -p "Copy which command's output?" -i -l 10 | sed 's/[^^]/[&]/g; s/\^/\\^/g')"
-eps1="$(echo "$ps1" | sed 's/[^^]/[&]/g; s/\^/\\^/g')"
-awk "/^$chosen$/{p=1;print;next} p&&/$eps1/{p=0};p" "$tmpfile" | xclip -selection clipboard
+/home/saumit/.local/src/st/external-pipe_scripts/st-copyout \ No newline at end of file
diff --git a/.scripts/st-urlhandler b/.scripts/st-urlhandler
index 0eb4586..0d8625f 100755..120000
--- a/.scripts/st-urlhandler
+++ b/.scripts/st-urlhandler
@@ -1,19 +1 @@
-#!/bin/sh
-
-urlregex="(((http|https|gopher|gemini|ftp|ftps|git)://|www\\.)[a-zA-Z0-9.]*[:;a-zA-Z0-9./+@$&%?$\#=_~-]*)|((magnet:\\?xt=urn:btih:)[a-zA-Z0-9]*)"
-
-urls="$(sed 's/.*│//g' | tr -d '\n' | # First remove linebreaks and mutt sidebars:
- grep -aEo "$urlregex" | # grep only urls as defined above.
- uniq | # Ignore neighboring duplicates.
- sed "s/\(\.\|,\|;\|\!\\|\?\)$//;
- s/^www./http:\/\/www\./")" # xdg-open will not detect url without http
-
-[ -z "$urls" ] && exit 1
-
-while getopts "hoc" o; do case "${o}" in
- h) printf "Optional arguments for custom use:\\n -c: copy\\n -o: xdg-open\\n -h: Show this message\\n" && exit 1 ;;
- o) chosen="$(echo "$urls" | dmenu -i -p 'Follow which url?' -l 10)"
- setsid xdg-open "$chosen" >/dev/null 2>&1 & ;;
- c) echo "$urls" | dmenu -i -p 'Copy which url?' -l 10 | tr -d '\n' | xclip -selection clipboard ;;
- *) printf "Invalid option: -%s\\n" "$OPTARG" && exit 1 ;;
-esac done
+/home/saumit/.local/src/st/external-pipe_scripts/st-urlhandler \ No newline at end of file
diff --git a/.scripts/volume b/.scripts/volume
index 3cfdc45..370f318 100755
--- a/.scripts/volume
+++ b/.scripts/volume
@@ -2,29 +2,17 @@
# Prints the current volume or 🔇 if muted.
-case $BLOCK_BUTTON in
- 1) setsid -f "$TERMINAL" -e pulsemixer ;;
- 2) pamixer -t ;;
- 4) pamixer --allow-boost -i 1 ;;
- 5) pamixer --allow-boost -d 1 ;;
- 3) notify-send "📢 Volume module" "\- Shows volume 🔊, 🔇 if muted.
-- Middle click to mute.
-- Scroll to change." ;;
- 6) "$TERMINAL" -e "$EDITOR" "$0" ;;
-esac
-
-[ $(pamixer --get-mute) = true ] && echo 🔇 && exit
-
+[ $(pamixer --get-mute) = true ] && echo && exit
vol="$(pamixer --get-volume)"
if [ "$vol" -gt "70" ]; then
- icon="🔊"
+ icon=" "
elif [ "$vol" -gt "30" ]; then
- icon="🔉"
+ icon=" "
elif [ "$vol" -gt "0" ]; then
- icon="🔈"
+ icon=" "
else
- echo 🔇 && exit
+ echo  && exit
fi
echo "$icon$vol%"