dotfiles

Configuration for the software I use.
git clone https://git.sr.ht/~jbauer/dotfiles
Log | Files | Refs | README | LICENSE

commit 9111d17c741932945e1a131b8ca32ba22d972b8a
parent f9841c2373fca024acb2d1f4978f34c38e6295b6
Author: Jake Bauer <jbauer@paritybit.ca>
Date:   Thu, 20 May 2021 18:45:15 -0400

Create statusbar script

Diffstat:
A.local/bin/status | 62++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 62 insertions(+), 0 deletions(-)

diff --git a/.local/bin/status b/.local/bin/status @@ -0,0 +1,62 @@ +#!/bin/sh + +while true; do + cpuTemp=$(sysctl hw.sensors.lm1.temp1 | cut -d= -f2 | cut -d. -f1) + + cpuIdle=$(top -1b | head -3 | tail -1 \ + | cut -d, -f6 | cut -d' ' -f2 | cut -d. -f1) + cpuUtil=$((100-cpuIdle)) + + memUtil=$(top -1b | head -4 | tail -1 \ + | cut -d' ' -f3 | cut -d'/' -f1) + + diskUtil=$(df -P | grep /home | awk '{print $5}') + + localTime=$(date +"%Y-%m-%d %H:%M") + europeTime=$(TZ=Europe/Berlin date +"%H:%M") + + # Begin NowPlaying Section + nowPlaying=$(cmus-remote -Q 2>/dev/null) + title=$(echo "$nowPlaying" | grep 'tag title' | cut -d' ' -f3-) + artist=$(echo "$nowPlaying" | grep 'tag artist' | cut -d' ' -f3-) + repeat=$(echo "$nowPlaying" | grep 'set repeat ' | cut -d' ' -f3-) + shuffle=$(echo "$nowPlaying" | grep 'set shuffle' | cut -d' ' -f3-) + duration=$(echo "$nowPlaying" | grep 'duration' | cut -d' ' -f2-) + position=$(echo "$nowPlaying" | grep 'position' | cut -d' ' -f2-) + curStatus=$(echo "$nowPlaying" | head -1 | cut -d' ' -f2) + + if [ "$curStatus" != "playing" ] && [ "$curStatus" != "paused" ]; then + printf "Nothing Playing" + exit 0 + fi + + # Truncate long title (e.g. "Burned Down Cigarettes" -> "Burned Down C...") + # if [ "$(echo "$title" | wc -m)" -gt 16 ]; then + # title=$( printf "%.16s" "$title" | sed 's/...$/.../') + # fi + + # Truncate long artist name (e.g. "Midnight Ambassador" -> "Midnight Am.") + # if [ "$(echo "$artist" | wc -m)" -gt 12 ]; then + # artist=$( printf "%.12s" "$artist" | sed 's/.$/./') + # fi + + durationMinutes=$((duration/60)) + durationSeconds=$((duration%60)) + positionMinutes=$((position/60)) + positionSeconds=$((position%60)) + + if [ "$shuffle" = "true" ]; then + icons="$icons " + fi + if [ "$repeat" = "true" ]; then + icons="$icons " + fi + + nowPlaying=$(printf "\"%s\" by %s — %02d:%02d/%02d:%02d%s" \ + "$title" "$artist" "$positionMinutes" "$positionSeconds" \ + "$durationMinutes" "$durationSeconds" "$icons") + # End NowPlaying Section + + xsetroot -name "$nowPlaying;$cpuTemp°C $cpuUtil% $memUtil $diskUtil $localTime/$europeTime" + sleep 1 +done