Show battery status in sway bar
This commit is contained in:
@@ -7,21 +7,28 @@ print_status() {
|
||||
|
||||
brightness=$(brightnessctl -m 2>/dev/null | awk -F, '{print $4}')
|
||||
|
||||
voxtype_state=$(voxtype status 2>/dev/null)
|
||||
case "$voxtype_state" in
|
||||
recording) voxtype=' | VOX REC' ;;
|
||||
transcribing) voxtype=' | VOX ...' ;;
|
||||
*) voxtype='' ;;
|
||||
esac
|
||||
battery_device=$(upower -e 2>/dev/null | grep -m 1 battery)
|
||||
if [ -n "$battery_device" ]; then
|
||||
battery=$(upower -i "$battery_device" 2>/dev/null | awk '
|
||||
/state/ { state=$2 }
|
||||
/percentage/ { percentage=$2 }
|
||||
END {
|
||||
if (percentage != "") {
|
||||
printf "%s", percentage
|
||||
if (state != "") printf " %s", state
|
||||
}
|
||||
}
|
||||
')
|
||||
fi
|
||||
|
||||
printf 'VOL %s | BRI %s%s | %s\n' "${volume:-n/a}" "${brightness:-n/a}" "$voxtype" "$(date +'%Y-%m-%d %H:%M:%S')"
|
||||
printf 'VOL %s | BRI %s | BAT %s | %s\n' "${volume:-n/a}" "${brightness:-n/a}" "${battery:-n/a}" "$(date +'%Y-%m-%d %H:%M:%S')"
|
||||
}
|
||||
|
||||
trap print_status USR1
|
||||
|
||||
print_status
|
||||
while :; do
|
||||
sleep 1 &
|
||||
sleep 60 &
|
||||
wait $!
|
||||
print_status
|
||||
done
|
||||
|
||||
7
setup.sh
7
setup.sh
@@ -1,6 +1,9 @@
|
||||
SRC=$HOME/dotfiles
|
||||
rm $HOME/.bashrc
|
||||
rm $HOME/.bash_profile
|
||||
[ -e $HOME/.bashrc ] && echo "I won't install ~/.bashrc because there is already a file like that; skipping setup for this file."
|
||||
[ -e $HOME/.vimrc ] && echo "I won't install ~/.vimrc because there is already a file like that; skipping setup for this file."
|
||||
[ -e $HOME/.bash_profile ] && echo "I won't install ~/.bash_profile because there is already a file like that; skipping setup for this file."
|
||||
[ -d $HOME/.config ] && echo "I won't install ~/.config because there is already a directory like that; skipping setup for this directory."
|
||||
[ -d $HOME/bin ] && echo "I won't install ~/bin because there is already a directory like that; skipping setup for this directory."
|
||||
ln -sf $SRC/.bashrc $HOME/.bashrc
|
||||
ln -sf $SRC/.vimrc $HOME/.vimrc
|
||||
ln -sf $SRC/.bash_profile $HOME/.bash_profile
|
||||
|
||||
Reference in New Issue
Block a user