statusbar scripts to master
This commit is contained in:
parent
a5e66ac4f4
commit
606946d890
16 changed files with 266 additions and 0 deletions
32
.local/bin/statusbar/battery
Executable file
32
.local/bin/statusbar/battery
Executable file
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/env sh
|
||||
# Give a battery name (e.g. BAT0) as an argument.
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
3) pgrep -x dunst >/dev/null && notify-send "🔋 Battery module" "🔋: discharging
|
||||
🛑: not charging
|
||||
♻: stagnant charge
|
||||
🔌: charging
|
||||
⚡: charged
|
||||
❗: battery very low!
|
||||
- Text color reflects charge left" ;;
|
||||
esac
|
||||
|
||||
capacity=$(cat /sys/class/power_supply/"$1"/capacity) || exit
|
||||
status=$(cat /sys/class/power_supply/"$1"/status)
|
||||
|
||||
if [ "$capacity" -ge 75 ]; then
|
||||
color="#00ff00"
|
||||
elif [ "$capacity" -ge 50 ]; then
|
||||
color="#ffffff"
|
||||
elif [ "$capacity" -ge 25 ]; then
|
||||
color="#ffff00"
|
||||
else
|
||||
color="#ff0000"
|
||||
warn="❗"
|
||||
fi
|
||||
|
||||
[ -z $warn ] && warn=" "
|
||||
|
||||
[ "$status" = "Charging" ] && color="#ffffff"
|
||||
|
||||
printf "<span color='%s'>%s%s%s</span>\n" "$color" "$(echo "$status" | sed -e "s/,//;s/Discharging/🔋/;s/Not Charging/🛑/;s/Charging/🔌/;s/Unknown/♻️/;s/Full/⚡/;s/ 0*/ /g;s/ :/ /g")" "$warn" "$(echo "$capacity" | sed -e 's/$/%/')"
|
10
.local/bin/statusbar/clock
Executable file
10
.local/bin/statusbar/clock
Executable file
|
@ -0,0 +1,10 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
date '+%Y %b %d (%a) %I:%M%p'
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) pgrep -x dunst >/dev/null && notify-send "This Month" "$(cal --color=always | sed "s/..7m/<b><span color=\"red\">/;s/..27m/<\/span><\/b>/")" && notify-send "Appointments" "$(calcurse -D ~/.config/calcurse -d3)" ;;
|
||||
2) $TERMINAL -e calcurse -D ~/.config/calcurse ;;
|
||||
3) pgrep -x dunst >/dev/null && 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" ;;
|
||||
esac
|
10
.local/bin/statusbar/cpu
Executable file
10
.local/bin/statusbar/cpu
Executable file
|
@ -0,0 +1,10 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) notify-send "🖥 CPU hogs" "$(ps axch -o cmd:15,%cpu --sort=-%cpu | head)" ;;
|
||||
3) notify-send "🖥 CPU module " "\- Shows CPU temperature.
|
||||
- Click to show intensive processes.
|
||||
- % is of single core." ;;
|
||||
esac
|
||||
|
||||
sensors | awk '/Core 0/ {print $3}'
|
18
.local/bin/statusbar/disk
Executable file
18
.local/bin/statusbar/disk
Executable file
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
# Status bar module for disk space
|
||||
# $1 should be drive mountpoint
|
||||
# $2 is optional icon, otherwise mountpoint will displayed
|
||||
|
||||
[ -z "$1" ] && exit
|
||||
|
||||
icon="$2"
|
||||
[ -z "$2" ] && icon="$1"
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) pgrep -x dunst >/dev/null && notify-send "💽 Disk space" "$(df -h --output=target,used,size)" ;;
|
||||
3) pgrep -x dunst >/dev/null && notify-send "💽 Disk module" "\- Shows used hard drive space.
|
||||
- Click to show all disk info." ;;
|
||||
esac
|
||||
|
||||
printf "%s: %s\n" "$icon" "$(df -h "$1" | awk ' /[0-9]/ {print $3 "/" $2}')"
|
7
.local/bin/statusbar/help
Executable file
7
.local/bin/statusbar/help
Executable file
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/env sh
|
||||
case $BLOCK_BUTTON in
|
||||
1) groff -mom ~/.local/share/larbs/readme.mom -Tpdf | zathura - ;;
|
||||
2) i3 restart ;;
|
||||
3) pgrep -x dunst >/dev/null && notify-send "❓ Help module" "\- Left click to open LARBS guide.
|
||||
- Middle click to refresh i3.";;
|
||||
esac; echo "❓"
|
17
.local/bin/statusbar/internet
Executable file
17
.local/bin/statusbar/internet
Executable file
|
@ -0,0 +1,17 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) $TERMINAL -e nmtui ;;
|
||||
3) pgrep -x dunst >/dev/null && notify-send "🌐 Internet module" "\- Click to connect
|
||||
📡: no wifi connection
|
||||
📶: wifi connection with quality
|
||||
❎: no ethernet
|
||||
🌐: ethernet working
|
||||
" ;;
|
||||
esac
|
||||
|
||||
[ "$(cat /sys/class/net/w*/operstate)" = 'down' ] && wifiicon="📡"
|
||||
|
||||
[ ! -n "${wifiicon+var}" ] && wifiicon=$(grep "^\s*w" /proc/net/wireless | awk '{ print "📶", int($3 * 100 / 70) "%" }')
|
||||
|
||||
printf "%s %s\n" "$wifiicon" "$(cat /sys/class/net/e*/operstate | sed "s/down/❎/;s/up/🌐/")"
|
9
.local/bin/statusbar/iplocate
Executable file
9
.local/bin/statusbar/iplocate
Executable file
|
@ -0,0 +1,9 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
# Gets your public ip address checks which country you are in and
|
||||
# displays that information in the statusbar
|
||||
#
|
||||
# https://www.maketecheasier.com/ip-address-geolocation-lookups-linux/
|
||||
ifinstalled "geoiplookup" || exit
|
||||
addr="$(curl ifconfig.me 2>/dev/null)" || exit
|
||||
grep "flag: " ~/.config/emoji | grep "$(geoiplookup $addr | sed 's/.*, //')" | sed "s/flag: //;s/;.*//"
|
16
.local/bin/statusbar/mailbox
Executable file
16
.local/bin/statusbar/mailbox
Executable file
|
@ -0,0 +1,16 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
# i3blocks mail module.
|
||||
# Displays number of unread mail and an loading icon if updating.
|
||||
# When clicked, brings up `neomutt`.
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) "$TERMINAL" -e neomutt ;;
|
||||
2) setsid mailsync >/dev/null & ;;
|
||||
3) pgrep -x dunst >/dev/null && notify-send "📬 Mail module" "\- Shows unread mail
|
||||
- Shows 🔃 if syncing mail
|
||||
- Left click opens neomutt
|
||||
- Middle click syncs mail" ;;
|
||||
esac
|
||||
|
||||
echo "$(du -a ~/.local/share/mail/*/INBOX/new/* 2>/dev/null | sed -n '$=')$(cat /tmp/imapsyncicon_$USER 2>/dev/null)"
|
9
.local/bin/statusbar/memory
Executable file
9
.local/bin/statusbar/memory
Executable file
|
@ -0,0 +1,9 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) notify-send "🧠 Memory hogs" "$(ps axch -o cmd:15,%mem --sort=-%mem | head)" ;;
|
||||
3) notify-send "🧠 Memory module" "\- Shows Memory Used/Total.
|
||||
- Click to show memory hogs." ;;
|
||||
esac
|
||||
|
||||
free -h | awk '/^Mem:/ {print $3 "/" $2}'
|
18
.local/bin/statusbar/music
Executable file
18
.local/bin/statusbar/music
Executable file
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
filter() {
|
||||
sed "/^volume:/d" | tac | sed -e "s/\\&/&/g;s/\\[paused\\].*/<span color=\"gray\" font_style=\"italic\">/g;s/\\[playing\\].*/<span>/g" | tr -d '\n' | sed -e "s/$/<\\/span>\n/g"
|
||||
}
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) mpc status | filter && setsid "$TERMINAL" -e ncmpcpp & ;; # right click, pause/unpause
|
||||
2) mpc toggle | filter ;; # right click, pause/unpause
|
||||
3) mpc status | filter && pgrep -x dunst >/dev/null && notify-send "🎵 Music module" "\- Shows mpd song playing.
|
||||
- Italic when paused.
|
||||
- Left click opens ncmpcpp.
|
||||
- Middle click pauses.
|
||||
- Scroll changes track.";; # right click, pause/unpause
|
||||
4) mpc prev | filter ;; # scroll up, previous
|
||||
5) mpc next | filter ;; # scroll down, next
|
||||
*) mpc status | filter ;;
|
||||
esac; exit
|
17
.local/bin/statusbar/news
Executable file
17
.local/bin/statusbar/news
Executable file
|
@ -0,0 +1,17 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
# i3blocks newsboat module.
|
||||
# Displays number of unread news items and an loading icon if updating.
|
||||
# When clicked, brings up `newsboat`.
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) setsid "$TERMINAL" -e newsboat ;;
|
||||
2) setsid newsup >/dev/null & exit ;;
|
||||
3) pgrep -x dunst >/dev/null && notify-send "📰 News module" "\- Shows unread news items
|
||||
- Shows 🔃 if updating with \`newsup\`
|
||||
- Left click opens newsboat
|
||||
- Middle click syncs RSS feeds
|
||||
<b>Note:</b> Only one instance of newsboat (including updates) may be running at a time." ;;
|
||||
esac
|
||||
|
||||
cat /tmp/newsupdate 2>/dev/null || echo "$(newsboat -x print-unread | awk '{ print $1}' | sed s/^0$//g)$(cat ~/.config/newsboat/.update 2>/dev/null)"
|
18
.local/bin/statusbar/pacpackages
Executable file
18
.local/bin/statusbar/pacpackages
Executable file
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
# i3blocks module for pacman upgrades.
|
||||
# Displays number of upgradeable packages.
|
||||
# For this to work, have a `pacman -Sy` command run in the background as a
|
||||
# cronjob every so often as root. This script will then read those packages.
|
||||
# When clicked, it will run an upgrade via pacman.
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) $TERMINAL -e popupgrade ;;
|
||||
2) notify-send "$(/usr/bin/pacman -Qu)" ;;
|
||||
3) pgrep -x dunst >/dev/null && notify-send "Upgrade module" "📦: number of upgradable packages
|
||||
- Left click to upgrade packages
|
||||
- Middle click to show upgradable packages" ;;
|
||||
esac
|
||||
|
||||
|
||||
pacman -Qu | grep -v "\[ignored\]" | wc -l | sed -e "s/^0$//g"
|
9
.local/bin/statusbar/popupgrade
Executable file
9
.local/bin/statusbar/popupgrade
Executable file
|
@ -0,0 +1,9 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
printf "Beginning upgrade.\\n"
|
||||
|
||||
yay -Syu
|
||||
pkill -RTMIN+8 i3blocks
|
||||
|
||||
printf "\\nUpgrade complete.\\nPress <Enter> to exit window.\\n\\n"
|
||||
read -r
|
28
.local/bin/statusbar/torrent
Executable file
28
.local/bin/statusbar/torrent
Executable file
|
@ -0,0 +1,28 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
transmission-remote -l | grep % |
|
||||
sed " # This first sed command is to ensure a desirable order with sort
|
||||
s/.*Stopped.*/A/g;
|
||||
s/.*Seeding.*/Z/g;
|
||||
s/.*100%.*/N/g;
|
||||
s/.*Idle.*/B/g;
|
||||
s/.*Uploading.*/L/g;
|
||||
s/.*%.*/M/g" |
|
||||
sort -h | uniq -c | sed " # Now we replace the standin letters with icons.
|
||||
s/A/🛑/g;
|
||||
s/B/⌛️/g;
|
||||
s/L/🔼/g;
|
||||
s/M/🔽/g;
|
||||
s/N/✅/g;
|
||||
s/Z/🌱/g" | awk '{print $2, $1}' | sed -e "s/ $//g"
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) $TERMINAL -e transmission-remote-cli ;;
|
||||
3) pgrep -x dunst >/dev/null && notify-send "Torrent module" "🛑: paused
|
||||
⏳: idle (seeds needed)
|
||||
🔼: uploading (unfinished)
|
||||
🔽: downloading
|
||||
✅: done
|
||||
🌱: done and seeding" ;;
|
||||
esac
|
||||
|
25
.local/bin/statusbar/volume
Executable file
25
.local/bin/statusbar/volume
Executable file
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) setsid "$TERMINAL" -e pulsemixer & ;;
|
||||
2) pulsemixer --toggle-mute ;;
|
||||
4) pulsemixer --change-volume +5 ;;
|
||||
5) pulsemixer --change-volume -5 ;;
|
||||
3) pgrep -x dunst >/dev/null && notify-send "📢 Volume module" "\- Shows volume 🔊, 🔇 if muted.
|
||||
- Middle click to mute.
|
||||
- Scroll to change."
|
||||
esac
|
||||
|
||||
[ "$(pulsemixer --get-mute)" = "1" ] && printf "🔇\\n" && exit
|
||||
|
||||
vol=$(pulsemixer --get-volume | awk '{print $1}')
|
||||
|
||||
if [ "$vol" -gt "70" ]; then
|
||||
icon="🔊"
|
||||
elif [ "$vol" -lt "30" ]; then
|
||||
icon="🔈"
|
||||
else
|
||||
icon="🔉"
|
||||
fi
|
||||
|
||||
printf "%s %s%%\\n" "$icon" "$vol"
|
23
.local/bin/statusbar/weather
Executable file
23
.local/bin/statusbar/weather
Executable file
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/env sh
|
||||
location="$1"; [ -z "$location" ] || { location="$location+" && rm -f "$HOME/.local/share/weatherreport" ;}
|
||||
|
||||
getforecast() { ping -q -c 1 1.1.1.1 >/dev/null || exit 1
|
||||
curl -s "wttr.in/$location" > "$HOME/.local/share/weatherreport" || exit 1 ;}
|
||||
|
||||
showweather() { printf "%s" "$(sed '16q;d' "$HOME/.local/share/weatherreport" | grep -wo "[0-9]*%" | sort -n | sed -e '$!d' | sed -e "s/^/☔ /g" | tr -d '\n')"
|
||||
sed '13q;d' "$HOME/.local/share/weatherreport" | grep -o "m\\(-\\)*[0-9]\\+" | sort -n -t 'm' -k 2n | sed -e 1b -e '$!d' | tr '\n|m' ' ' | awk '{print " ❄️",$1 "°","🌞",$2 "°"}' ;}
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) $TERMINAL -e less -S "$HOME/.local/share/weatherreport" ;;
|
||||
2) getforecast && showweather ;;
|
||||
3) pgrep -x dunst >/dev/null && notify-send "🌈 Weather module" "\- Left click for full forecast.
|
||||
- Middle click to update forecast.
|
||||
☔: Chance of rain/snow
|
||||
❄: Daily low
|
||||
🌞: Daily high" ;;
|
||||
esac
|
||||
|
||||
if [ "$(stat -c %y "$HOME/.local/share/weatherreport" >/dev/null 2>&1 | awk '{print $1}')" != "$(date '+%Y-%m-%d')" ]
|
||||
then getforecast && showweather
|
||||
else showweather
|
||||
fi
|
Loading…
Reference in a new issue