From 1ff834e2b06761b083df9959d6c3d6bd2a94d2de Mon Sep 17 00:00:00 2001 From: Shubham Saini Date: Tue, 1 Dec 2020 20:21:04 +0000 Subject: mah thinkpad --- bin/.bin/lemonconf | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100755 bin/.bin/lemonconf (limited to 'bin/.bin/lemonconf') diff --git a/bin/.bin/lemonconf b/bin/.bin/lemonconf new file mode 100755 index 0000000..cb5e505 --- /dev/null +++ b/bin/.bin/lemonconf @@ -0,0 +1,74 @@ +#!/bin/bash +# Outputs a configuration for lemonbar + +vol(){ + vol=$(pulsemixer --get-volume | awk '{print $1}') + mute=$(pulsemixer --get-mute) + if [ "$mute" == 1 ]; then + echo -e "%{F#787878}vol%{F-} muted " + elif [ "$mute" == 0 ]; then + echo -e "%{F#787878}vol%{F-} $vol% " + fi +} + +bat() { + power=$(cat /sys/class/power_supply/BAT0/capacity) + status=$(cat /sys/class/power_supply/BAT0/status) + if [ "$status" == "Charging" ]; then + echo -e "%{F#787878}bat%{F-} +$power% " + elif [ "$status" == "Discharging" ]; then + echo -e "%{F#787878}bat%{F-} $power% " + fi +} + +dte() { + dte=$(date +"%a, %b %d") + echo -e "%{F#787878}date%{F-} $dte " +} + +tie() { + tme=$(date +"%I:%M %P") + echo -e "%{F#787878}time%{F-} $tme " +} + +groups() { + cur=`xprop -root _NET_CURRENT_DESKTOP | awk '{print $3}'` + tot=`xprop -root _NET_NUMBER_OF_DESKTOPS | awk '{print $3}'` + + for w in `seq 0 $((cur - 1))`; do line="${line}  "; done + line="${line}  " + for w in `seq $((cur + 2)) $tot`; do line="${line}  "; done + echo $line +} + +workspaces() { + all=$(bspc query -D) + occupied=$(bspc query -D -d .occupied) + current=$(bspc query -D -d .focused) + result="" + padding=" " + while IFS= read -r line; do + # Get the name of the current desktop + name="" + if [[ "$occupied" == *"$line"* ]]; + then + name="" + fi + + if [[ "$current" == *"$line"* ]]; + then + name="" + fi + + result="$result$padding" + result="$result$name" + result="$result$padding" + done <<< "$all" + echo -e "$result" +} + +while true; do + echo " $(vol) $(bat) $(tie) $(dte) %{F#787878}%{r}$(workspaces)%{F-} " + xdo above -t $(xdo id -n root) $(xdo id -n lemonbar) + sleep 3 +done -- cgit v1.2.3