dwmblocks scripts.

This commit is contained in:
Bartek Stalewski 2021-06-19 15:50:04 +02:00
parent d25a6431fb
commit 24dd7f46c9
6 changed files with 97 additions and 0 deletions

40
_suckless/_scripts/rofi_display Executable file
View file

@ -0,0 +1,40 @@
#!/bin/sh
both() { # If both is selected and there are two screens.
primary=$(echo "$screens" | rofi -dmenu -i -p "Select primary display:")
secondary=$(echo "$screens" | grep -v "$primary")
direction=$(printf "left\\nright" | rofi -dmenu -i -p "What side of $primary should $secondary be on?")
xrandr --output "$primary" --mode 1920x1080 --scale 1.0x1.0 --output "$secondary" --"$direction"-of "$primary" --mode 2560x1440 --scale 1.0x1.0
}
onescreen() {
case "$1" in
eDP) xrandr --output "$1" --mode 1920x1080 $(echo "$allposs" | grep -v "\b$1" | awk '{print "--output", $1, "--off"}' | paste -sd ' ' -) ;;
DisplayPort*) xrandr --output "$1" --mode 2560x1440 $(echo "$allposs" | grep -v "\b$1" | awk '{print "--output", $1, "--off"}' | paste -sd ' ' -) ;;
*) xrandr --output "$1" --auto $(echo "$allposs" | grep -v "\b$1" | awk '{print "--output", $1, "--off"}' | paste -sd ' ' -) ;;
esac
}
postrun() {
feh --no-fehbg --bg-scale ~/.local/share/wallpaper
{ killall dunst ; setsid -f dunst ;} >/dev/null 2>&1 # Restart dunst to ensure proper location on screen
}
# Get all possible displays
allposs=$(xrandr -q | grep "connected")
# Get all connected screens.
screens=$(echo "$allposs" | awk '/ connected/ {print $1}')
# If there's only one screen
[ "$(echo "$screens" | wc -l)" -lt 2 ] &&
{ onescreen "$screens"; postrun; exit ;}
# Get user choice including both and manual selection:
chosen=$(printf "%s\\nboth" "$screens" | rofi -dmenu -i -p "Select display arangement:") &&
case "$chosen" in
"both") both ;;
*) onescreen "$chosen" ;;
esac
postrun

19
_suckless/_scripts/sb-battery Executable file
View file

@ -0,0 +1,19 @@
#!/bin/sh
for battery in /sys/class/power_supply/BAT?*; do
# If non-first battery, print a space separator.
[ -n "${capacity+x}" ] && printf " "
# Sets up the status and capacity
case "$(cat "$battery/status")" in
"Full") status="⚡" ;;
"Discharging") status="🔋" ;;
"Charging") status="🔌" ;;
"Not charging") status="🛑" ;;
"Unknown") status="♻️" ;;
esac
capacity=$(cat "$battery/capacity")
# Will make a warn variable if discharging and low
[ "$status" = "🔋" ] && [ "$capacity" -le 25 ] && warn="❗"
# Prints the info
printf "%s %s%d%%" "$status" "$warn" "$capacity"; unset warn
done && exit 0

16
_suckless/_scripts/sb-mail Executable file
View file

@ -0,0 +1,16 @@
#!/bin/sh
[ ! -e ~/.local/share/passwords ] && echo "no accounts configured" && exit 1
unread=0
cat ~/.local/share/passwords | while read line; do
user=$(echo "$line" | awk '{print $1}')
pass=$(echo "$line" | awk '{print $1}')
count=$(curl -s --user "${uers}:${pass}" https://mail.google.com/mail/feed/atom/ | grep -oPm1 "(?<=<title>)[^<]+" | sed '1d' | wc -l 2>/dev/null)
[ $count -ne 0 ] && unread=$((unread + count))
if [ $user = 'ftpd@insomniac.pl' ]; then
count=$(curl -s --user "${i}:${pass}" https://mail.google.com/mail/feed/atom/sites | grep -oPm1 "(?<=<title>)[^<]+" | sed '1d' | wc -l 2>/dev/null)
[ $count -ne 0 ] && unread=$((unread + count))
fi
done
[ "$unread" = "0" ] && echo "no new mail" || echo "^c#161616^^b#fd4285^new mail: ${unread}^d^"

10
_suckless/_scripts/sb-network Executable file
View file

@ -0,0 +1,10 @@
#!/bin/sh
# Show wifi 📶 and percent strength or 📡 if none.
# Show 🌐 if connected to ethernet or ❎ if none.
# Show 🔒 if a vpn connection is active
case "$(cat /sys/class/net/w*/operstate 2>/dev/null)" in
down) echo "^c#161616^^b#fd4285^NO WIFI^d^" ;;
up) echo `iw dev wlp3s0 info | awk '/ssid/ {print $2}'` ;;
esac

5
_suckless/_scripts/sb-volume Executable file
View file

@ -0,0 +1,5 @@
#!/bin/sh
[ $(pamixer --get-mute) = true ] && echo "^c#161616^^b#fd4285^mute^d^" && exit
vol="$(pamixer --get-volume)"
[ $(echo $vol | wc -c) -lt 4 ] && echo " ${vol}%" || echo "${vol}%"

View file

@ -0,0 +1,7 @@
#!/bin/sh
mkdir -p ~/.local/bin
for i in _scripts/*; do
ln -sf $(pwd)/$i ~/.local/bin
done