dotfiles

My dotfiles.
Log | Files | Refs | LICENSE

commit 4b4685673c1090d7729e21b756102c1397a8865f
parent 140de8bd15e00f95c79db97e8e0a15a408bfce3e
Author: rmj <pwishie@gmail.com>
Date:   Tue,  7 Apr 2020 00:06:41 -0700

dwm scripts

Diffstat:
Adwmbar.sh | 74++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aryansleep.sh | 5+++++
2 files changed, 79 insertions(+), 0 deletions(-)

diff --git a/dwmbar.sh b/dwmbar.sh @@ -0,0 +1,74 @@ +#!/usr/bin/env sh + +# Length of the song title mpd is playing +SONG_LEN=25 + +get_battery() { + cap=$(cat /sys/class/power_supply/BAT0/capacity) || return 1 + status=$(cat /sys/class/power_supply/BAT0/status) + emoji=πŸ”Œ + + [ "$status" = "Discharging" ] && [ "$cap" -le 25 ] && emoji=❗ + [ "$status" = "Discharging" ] && emoji=πŸ”‹ + + echo "$emoji $cap%" +} + +get_volume() { + volume=$(pamixer --get-volume) + emoji=πŸ”‰ # default is medium volume + + if [ "$volume" -eq 0 ]; then + emoji=πŸ”‡ + elif [ "$volume" -le 50 ]; then + emoji=πŸ”ˆ + elif [ "$volume" -ge 120 ]; then + emoji=πŸ”Š + fi + + echo "$emoji $volume%" + +} + +# Get the current song from mpd +get_song() { + song=$(mpc current) || return 1 + emoji=🎡 + + [ -z "$song" ] && emoji='' + + echo "$emoji $(echo $song | cut -c 1-$SONG_LEN)" +} + +get_cpu_usage() { + echo "πŸ’» $(top -bn1 | grep "Cpu(s)" | \ + sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | \ + awk '{print 100 - $1"%"}')" +} + +get_cpu_temp() { + temp=$(cat /sys/class/thermal/thermal_zone1/temp | cut -c 1-2) + emoji=🌑 + + [ temp -ge 60 ] && emoji=πŸ”₯ + + echo "$emoji $tempΒ°C" +} + +get_used_mem() { + total=$(cat /proc/meminfo | awk '{print $2}' | head -1) + free=$(cat /proc/meminfo | awk '{print $2}' | sed -n 2p) + emoji=🧠 + + used=$(expr $total / $free) + + [ used -ge 70 ] && emoji=🀯 + + echo "$emoji $used%" +} + +while true; do + xsetroot -name " $(get_song) | $(get_volume) | $(get_used_mem) | $(get_cpu_usage) | $(get_cpu_temp) | $(get_battery) | πŸ“… $(date +"%a, %b %d - %I:%M %p") | $(whoami)" + + /home/rmj/src/scripts/ryansleep.sh +done diff --git a/ryansleep.sh b/ryansleep.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env sh + +# This script exists so it can be killed from scripts. + +sleep 20