Compare commits
5 Commits
26facc6f47
...
master
Author | SHA1 | Date | |
---|---|---|---|
2b60aeb15c | |||
9c8b87bcc6 | |||
d66332ed2a | |||
6454e76140 | |||
fb7f0a7401 |
66
bin/batteries
Executable file
66
bin/batteries
Executable 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
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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
11
prepare.sh
Normal file → Executable 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:./::')
|
||||
|
Reference in New Issue
Block a user