Compare commits

...

5 Commits

Author SHA1 Message Date
2b60aeb15c Shortened clock, added setup automation 2025-05-31 18:02:50 +03:00
9c8b87bcc6 Fixed batteries script 2025-05-31 17:41:56 +03:00
d66332ed2a Single script for all batteries 2025-05-31 17:34:00 +03:00
6454e76140 edited 2025-05-31 16:55:38 +03:00
fb7f0a7401 added bashrc modification 2025-05-31 16:48:28 +03:00
4 changed files with 88 additions and 10 deletions

66
bin/batteries Executable file
View File

@ -0,0 +1,66 @@
#!/bin/bash
geticon() {
local icon=󰂎
state=$2
if [ "$state" = "Charging" ]; then
icon=󰂄
else
[ "$1" -gt 0 ] && icon=󰂃
[ "$1" -gt 10 ] && icon=󰁻
[ "$1" -gt 20 ] && icon=󰁼
[ "$1" -gt 30 ] && icon=󰁽
[ "$1" -gt 40 ] && icon=󰁾
[ "$1" -gt 50 ] && icon=󰁿
[ "$1" -gt 60 ] && icon=󰂀
[ "$1" -gt 70 ] && icon=󰂁
[ "$1" -gt 80 ] && icon=󰂂
[ "$1" -gt 90 ] && icon=󰁹
fi
echo "$icon"
}
getcolor() {
local color='#80ff80'
if [ "$2" = "Charging" ]; then
color='#0080ff'
else
[ "$1" -lt 60 ] && color='#ffff00'
[ "$1" -lt 30 ] && color='#ff8000'
[ "$1" -lt 15 ] && color='#ff0000'
fi
echo "$color"
}
batteries=$(acpi | rg 'Battery (\d)' -or '$1')
# echo "BATTERIES: $batteries"
text=""
for battery in $batteries; do
# echo "BATTERY $battery"
bt=$(acpi -b | grep "Battery $battery")
BAT=$(echo "$bt" | rg "(\d?\d?\d)%" -or '$1')
STAT=$(echo "$bt" | rg ": ([\w\s]+)," -or '$1')
ICON=$(geticon "$BAT" "$STAT")
COLOR=$(getcolor "$BAT" "$STAT")
BATTEXT="$ICON $BAT%%"
text+="<span foreground=\"${COLOR}\">${BATTEXT}</span> "
done
printf "${text:0:-1}\n\n"
# bt=$(acpi -b | grep "Battery $1")
# BAT=$(echo "$bt" | rg "(\d?\d?\d)%" -or '$1')
# STAT=$(echo "$bt" | rg ": ([\w\s]+)," -or '$1')
# ICON=$(geticon "$BAT" "$STAT")
# COLOR=$(getcolor "$BAT" "$STAT")
#echo "$ICON" $(($1 + 1)): "$BAT"%
# echo "$ICON" "$BAT"%
# echo "$ICON" "$BAT"%
echo "$COLOR"
exit 0

View File

@ -40,7 +40,8 @@ STAT=$(echo "$bt" | rg ": ([\w\s]+)," -or '$1')
ICON=$(geticon "$BAT" "$STAT")
COLOR=$(getcolor "$BAT" "$STAT")
echo "$ICON" $(($1 + 1)): "$BAT"%
#echo "$ICON" $(($1 + 1)): "$BAT"%
echo "$ICON" "$BAT"%
echo "$ICON" "$BAT"%
echo "$COLOR"

View File

@ -10,13 +10,17 @@
separator=true
separator_block_width=15
[battery1]
command=~/.dotfiles/bin/battery 0
interval=30
# [battery1]
# command=~/.dotfiles/bin/battery 0
# interval=30
[battery2]
command=~/.dotfiles/bin/battery 1
interval=30
# [battery2]
# command=~/.dotfiles/bin/battery 1
# interval=30
[batteries]
command=~/.dotfiles/bin/batteries
interval=10
markup=pango
#[volume]
#command=~/.config/i3blocks/volume-pipewire
@ -37,5 +41,5 @@ label=lang:
interval=1
[time]
command=date '+%d.%m.%Y %H:%M'
command=date '+%d.%m %H:%M'
interval=10

11
prepare.sh Normal file → Executable file
View File

@ -1,5 +1,12 @@
#!/bin/bash
sudo pacman -S fzf zoxide fd nvim stow
cat ~/.bashrc | grep nfrc || echo "source ~/.dotfiles/nfrc.sh" >> ~/.bashrc
sudo pacman -S --needed fzf zoxide fd nvim stow ripgrep acpi jq
dirs=$(find ./ -maxdepth 1 -mindepth 1 -not -path "./.git" -not -path "./bin" -type d | sed 's:./::')
for dir in $dirs; do
stow $dir --adopt
done
git checkout
dirs=$(find ./ -maxdepth 1 -mindepth 1 -not -path "./.git" -type d | sed 's:./::')