dotfiles

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit e97b180540a8e133faf11ca00b4f36485be8b24c
parent 236794dd9003e248529358884b2f9da696491fb6
Author: Janis Pagel <janis.pagel@ims.uni-stuttgart.de>
Date:   Tue, 21 Apr 2020 19:30:37 +0200

Rename statusbar script

Also make statusbar toggle-able

Diffstat:
Dbin/dmenu_statusbar | 23-----------------------
Abin/statusbar | 38++++++++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 23 deletions(-)

diff --git a/bin/dmenu_statusbar b/bin/dmenu_statusbar @@ -1,23 +0,0 @@ -#!/bin/dash - -if [ $(amixer get Master | tail -1 | awk '{ print $6 " " }' | tr -d '[' | tr -d ']') = 'on' ] -then - VOL="$(amixer get Master | tail -1 | sed 's/.*\[\([0-9]*%\)\].*/\1/')" -elif [ $(amixer get Master | tail -1 | awk '{ print $6 " " }' | tr -d '[' | tr -d ']') = 'off' ] -then - VOL="muted" -fi -LOCALTIME=$(date -Iseconds) -UTC=$(TZ=UTC date -Iseconds) -IP="$(for i in `ip r`; do echo $i; done | grep -A 1 src | tail -n1)" -if [ -d "/proc/sys/net/ipv4/conf/tun0" ] -then - VPN="yes" -else - VPN="no" -fi -TEMP="$(($(cat /sys/class/thermal/thermal_zone0/temp) / 1000))Ā°C" -BAT="$(acpi -b | awk '{ print $4 " " }' | tr -d ',' | tr -d ' ')" -CURRENT_SONG="$(mpc --format "[[%composer%|%artist%][ - %album%][ - %title%] | [%file%]]" current)" - -echo "šŸ•“ $LOCALTIME\nšŸ”Š $VOL\nļ›æ $IP\nšŸš† $VPN\nļ© $TEMP\nļ‰€ $BAT\nšŸŽ¼ $CURRENT_SONG" | dmenu -p System\ Info: -fn "Sans:size=11" diff --git a/bin/statusbar b/bin/statusbar @@ -0,0 +1,38 @@ +#!/bin/dash + +update_statusbar() { + + if [ $(amixer get Master | tail -1 | awk '{ print $6 " " }' | tr -d '[' | tr -d ']') = 'on' ] + then + VOL="$(amixer get Master | tail -1 | sed 's/.*\[\([0-9]*%\)\].*/\1/')" + elif [ $(amixer get Master | tail -1 | awk '{ print $6 " " }' | tr -d '[' | tr -d ']') = 'off' ] + then + VOL="muted" + fi + LOCALTIME=$(date -Iseconds) + UTC=$(TZ=UTC date -Iseconds) + IP="$(for i in `ip r`; do echo $i; done | grep -A 1 src | tail -n1)" + if [ -d "/proc/sys/net/ipv4/conf/tun0" ]; then VPN="yes"; else VPN="no"; fi + TEMP="$(($(cat /sys/class/thermal/thermal_zone0/temp) / 1000))Ā°C" + BAT="$(acpi -b | awk '{ print $4 " " }' | tr -d ',' | tr -d ' ')" + CURRENT_SONG="$(mpc --format "[[%composer%|%artist%][ - %album%][ - %title%] | [%file%]]" current)" + VERSION="dwm-6.2" + + xsetroot -name " šŸ•“ $LOCALTIME | šŸ”Š $VOL | ļ›æ $IP | šŸš† $VPN | ļ© $TEMP | ļ‰€ $BAT | šŸŽ¼ $CURRENT_SONG | $VERSION" +} + + +CURRENTSTATUS=$(pgrep -x statusbar | wc -l) +if [ "$CURRENTSTATUS" -ge "3" ] +then + xsetroot -name "$VERSION" + killall statusbar +else + trap update_statusbar USR1 + while true + do + update_statusbar + sleep 1 & + wait + done +fi