mirror of
https://github.com/fscotto/infra.git
synced 2026-05-30 23:49:56 +00:00
Minimal i3 setup
This commit is contained in:
14
dotfiles/desktop/.config/i3blocks/scripts/backlight
Executable file
14
dotfiles/desktop/.config/i3blocks/scripts/backlight
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
cur="$(brightnessctl g 2>/dev/null)"
|
||||
max="$(brightnessctl m 2>/dev/null)"
|
||||
|
||||
[ -n "$cur" ] || exit 0
|
||||
[ -n "$max" ] || exit 0
|
||||
[ "$max" -gt 0 ] || exit 0
|
||||
|
||||
pct=$((100 * cur / max))
|
||||
|
||||
echo "BL ${pct}%"
|
||||
echo "BL ${pct}%"
|
||||
echo "#6daeea"
|
||||
47
dotfiles/desktop/.config/i3blocks/scripts/battery
Executable file
47
dotfiles/desktop/.config/i3blocks/scripts/battery
Executable file
@@ -0,0 +1,47 @@
|
||||
#!/bin/sh
|
||||
|
||||
total_now=0
|
||||
total_full=0
|
||||
status=""
|
||||
|
||||
for bat in /sys/class/power_supply/BAT*; do
|
||||
[ -d "$bat" ] || continue
|
||||
|
||||
if [ -r "$bat/energy_now" ] && [ -r "$bat/energy_full" ]; then
|
||||
now=$(cat "$bat/energy_now")
|
||||
full=$(cat "$bat/energy_full")
|
||||
elif [ -r "$bat/charge_now" ] && [ -r "$bat/charge_full" ]; then
|
||||
now=$(cat "$bat/charge_now")
|
||||
full=$(cat "$bat/charge_full")
|
||||
else
|
||||
continue
|
||||
fi
|
||||
|
||||
st=$(cat "$bat/status" 2>/dev/null)
|
||||
|
||||
total_now=$((total_now + now))
|
||||
total_full=$((total_full + full))
|
||||
|
||||
case "$st" in
|
||||
Charging) status="⚡" ;;
|
||||
Discharging) [ -z "$status" ] && status="🔋" ;;
|
||||
Full) [ -z "$status" ] && status="✔" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
[ "$total_full" -gt 0 ] || exit 0
|
||||
|
||||
pct=$((100 * total_now / total_full))
|
||||
[ -n "$status" ] || status="BAT"
|
||||
|
||||
text="$status $pct%"
|
||||
|
||||
if [ "$pct" -le 15 ]; then
|
||||
color="#ff5555"
|
||||
elif [ "$pct" -le 30 ]; then
|
||||
color="#f1fa8c"
|
||||
else
|
||||
color="#9ece6a"
|
||||
fi
|
||||
|
||||
printf '%s\n%s\n%s\n' "$text" "$text" "$color"
|
||||
17
dotfiles/desktop/.config/i3blocks/scripts/keyindicator
Executable file
17
dotfiles/desktop/.config/i3blocks/scripts/keyindicator
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
|
||||
state="$(xset q 2>/dev/null)"
|
||||
|
||||
caps="$(printf '%s\n' "$state" | grep 'Caps Lock:' | awk '{print $4}')"
|
||||
num="$(printf '%s\n' "$state" | grep 'Num Lock:' | awk '{print $8}')"
|
||||
|
||||
out=""
|
||||
|
||||
[ "$caps" = "on" ] && out="${out} CAPS"
|
||||
[ "$num" = "on" ] && out="${out} NUM"
|
||||
|
||||
[ -n "$out" ] || exit 0
|
||||
|
||||
echo "$out"
|
||||
echo "$out"
|
||||
echo "#9a9a9a"
|
||||
19
dotfiles/desktop/.config/i3blocks/scripts/memory
Executable file
19
dotfiles/desktop/.config/i3blocks/scripts/memory
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
|
||||
mem=$(free | awk '/^Mem:/ {print $3/$2 * 100.0}')
|
||||
mem=${mem%.*}
|
||||
|
||||
if [ "$mem" -ge 90 ]; then
|
||||
color="#c7162b"
|
||||
elif [ "$mem" -ge 70 ]; then
|
||||
color="#e95420"
|
||||
else
|
||||
color="#d0d0d0"
|
||||
fi
|
||||
|
||||
used=$(free -h | awk '/^Mem:/ {print $3}')
|
||||
total=$(free -h | awk '/^Mem:/ {print $2}')
|
||||
|
||||
echo "RAM $used/$total"
|
||||
echo "RAM $used/$total"
|
||||
echo "$color"
|
||||
18
dotfiles/desktop/.config/i3blocks/scripts/temperature
Executable file
18
dotfiles/desktop/.config/i3blocks/scripts/temperature
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
|
||||
t=$(cat /sys/class/thermal/thermal_zone0/temp 2>/dev/null)
|
||||
[ -n "$t" ] || exit 0
|
||||
|
||||
temp=$((t / 1000))
|
||||
|
||||
if [ "$temp" -ge 85 ]; then
|
||||
color="#c7162b"
|
||||
elif [ "$temp" -ge 70 ]; then
|
||||
color="#e95420"
|
||||
else
|
||||
color="#d0d0d0"
|
||||
fi
|
||||
|
||||
echo "CPU ${temp}°C"
|
||||
echo "CPU ${temp}°C"
|
||||
echo "$color"
|
||||
16
dotfiles/desktop/.config/i3blocks/scripts/volume
Executable file
16
dotfiles/desktop/.config/i3blocks/scripts/volume
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
|
||||
mute=$(pactl get-sink-mute @DEFAULT_SINK@ 2>/dev/null | awk '{print $2}')
|
||||
vol=$(pactl get-sink-volume @DEFAULT_SINK@ 2>/dev/null | awk '/Volume:/ {print $5; exit}')
|
||||
|
||||
[ -n "$vol" ] || exit 0
|
||||
|
||||
if [ "$mute" = "yes" ]; then
|
||||
text="VOL mute"
|
||||
color="#7aa2f7"
|
||||
else
|
||||
text="VOL $vol"
|
||||
color="#c0caf5"
|
||||
fi
|
||||
|
||||
printf '%s\n%s\n%s\n' "$text" "$text" "$color"
|
||||
9
dotfiles/desktop/.config/i3blocks/scripts/wifi
Executable file
9
dotfiles/desktop/.config/i3blocks/scripts/wifi
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
ssid=$(nmcli -t -f active,ssid dev wifi | awk -F: '$1=="yes"{print $2}')
|
||||
|
||||
[ -n "$ssid" ] || exit 0
|
||||
|
||||
echo "WIFI $ssid"
|
||||
echo "WIFI $ssid"
|
||||
echo "#4a90d9"
|
||||
Reference in New Issue
Block a user