From ded37b8f6515772648527fe2a3e9d9d490066ca0 Mon Sep 17 00:00:00 2001 From: Saumit Dinesan Date: Sat, 1 Oct 2022 00:56:51 +0530 Subject: minimizing scripts + replacing emojis for fonticons --- .scripts/battery | 8 ++++---- .scripts/clock | 34 +++++++++++++--------------------- .scripts/cpu_py | 2 ++ .scripts/cputemp | 10 ++++++++++ .scripts/memory | 11 +---------- .scripts/nettraf | 10 ++-------- .scripts/setbg | 3 ++- .scripts/st-copyout | 10 +--------- .scripts/st-urlhandler | 20 +------------------- .scripts/volume | 22 +++++----------------- 10 files changed, 41 insertions(+), 89 deletions(-) create mode 100755 .scripts/cpu_py create mode 100755 .scripts/cputemp mode change 100755 => 120000 .scripts/st-copyout mode change 100755 => 120000 .scripts/st-urlhandler 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//;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 deleted file mode 100755 index 220bff1..0000000 --- a/.scripts/st-copyout +++ /dev/null @@ -1,9 +0,0 @@ -#!/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 diff --git a/.scripts/st-copyout b/.scripts/st-copyout new file mode 120000 index 0000000..e822e4a --- /dev/null +++ b/.scripts/st-copyout @@ -0,0 +1 @@ +/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 deleted file mode 100755 index 0eb4586..0000000 --- a/.scripts/st-urlhandler +++ /dev/null @@ -1,19 +0,0 @@ -#!/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 diff --git a/.scripts/st-urlhandler b/.scripts/st-urlhandler new file mode 120000 index 0000000..0d8625f --- /dev/null +++ b/.scripts/st-urlhandler @@ -0,0 +1 @@ +/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%" -- cgit v1.2.3