Minimal i3 setup

This commit is contained in:
Fabio Scotto di Santolo
2026-03-15 22:00:35 +01:00
parent f8b6d4c502
commit 31c17c95c1
33 changed files with 1034 additions and 52 deletions

View File

@@ -0,0 +1,94 @@
#!/usr/bin/env bash
battery_json() {
local total_now=0
local total_full=0
local overall_status=""
local now full status bat capacity icon color
shopt -s nullglob
for bat in /sys/class/power_supply/BAT*; do
[[ -d "$bat" ]] || continue
if [[ -r "$bat/energy_now" && -r "$bat/energy_full" ]]; then
now=$(<"$bat/energy_now")
full=$(<"$bat/energy_full")
elif [[ -r "$bat/charge_now" && -r "$bat/charge_full" ]]; then
now=$(<"$bat/charge_now")
full=$(<"$bat/charge_full")
else
continue
fi
status=$(<"$bat/status")
(( total_now += now ))
(( total_full += full ))
case "$status" in
Charging)
overall_status="Charging"
;;
Discharging)
[[ "$overall_status" != "Charging" ]] && overall_status="Discharging"
;;
Full)
[[ -z "$overall_status" ]] && overall_status="Full"
;;
*)
[[ -z "$overall_status" ]] && overall_status="$status"
;;
esac
done
(( total_full > 0 )) || return 1
capacity=$(( 100 * total_now / total_full ))
case "$overall_status" in
Charging) icon="⚡" ;;
Discharging) icon="🔋" ;;
Full) icon="✔" ;;
*) icon="?" ;;
esac
if (( capacity <= 15 )); then
color="#ff5555"
elif (( capacity <= 30 )); then
color="#f1fa8c"
else
color="#ffffff"
fi
printf '{"full_text":"%s %s%%","name":"battery","color":"%s"}' \
"$icon" "$capacity" "$color"
}
i3status | while IFS= read -r line; do
case "$line" in
'{"version":'* | '[')
printf '%s\n' "$line"
;;
,*)
batt="$(battery_json)"
if [[ -n "$batt" ]]; then
line="${line#,}"
printf ',[%s,%s\n' "$batt" "${line#\[}"
else
printf '%s\n' "$line"
fi
;;
\[*)
batt="$(battery_json)"
if [[ -n "$batt" ]]; then
printf '[%s,%s\n' "$batt" "${line#\[}"
else
printf '%s\n' "$line"
fi
;;
*)
printf '%s\n' "$line"
;;
esac
done

View File

@@ -0,0 +1,33 @@
#!/bin/sh
img=/tmp/lockscreen.png
# screenshot
scrot "$img"
# blur
convert "$img" -blur 0x8 "$img"
# lock
i3lock \
--image "$img" \
--clock \
--indicator \
--radius 100 \
--ring-width 8 \
--color=000000ff \
--ring-color=2f4058ff \
--inside-color=1f1f28ff \
--line-color=00000000 \
--separator-color=3a3a46ff \
--keyhl-color=6daeeaff \
--bshl-color=c7162bff \
--ringver-color=4a90d9ff \
--insidever-color=1f1f28ff \
--ringwrong-color=c7162bff \
--insidewrong-color=1f1f28ff \
--time-color=d0d0d0ff \
--date-color=9a9a9aff \
--layout-color=d0d0d0ff \
--verif-color=d0d0d0ff \
--wrong-color=d0d0d0ff

View File

@@ -0,0 +1,29 @@
#!/bin/sh
choice="$(printf "⏻ Shutdown\n Reboot\n Logout\n Lock\n⏾ Suspend" \
| rofi -dmenu \
-i \
-p "Power" \
-theme ~/.config/rofi/config.rasi \
-theme-str 'window { width: 20%; location: center; anchor: center; } listview { columns: 1; spacing: 6px; }')"
[ -z "$choice" ] && exit 0
case "$choice" in
*Lock)
~/.config/i3/scripts/lockscreen
;;
*Logout)
i3-msg exit
;;
*Suspend)
~/.config/i3/scripts/lockscreen
loginctl suspend
;;
*Reboot)
loginctl reboot
;;
*Shutdown)
loginctl poweroff
;;
esac

View File

@@ -0,0 +1,37 @@
#!/bin/sh
THEME="Yaru-blue-dark"
ICONS="Yaru-blue-dark"
CURSOR="Yaru"
FONT_UI="Liberation Sans 10"
mkdir -p "$HOME/.config/gtk-3.0"
mkdir -p "$HOME/.config/gtk-4.0"
cat > "$HOME/.config/gtk-3.0/settings.ini" <<EOF
[Settings]
gtk-theme-name=$THEME
gtk-icon-theme-name=$ICONS
gtk-cursor-theme-name=$CURSOR
gtk-font-name=$FONT_UI
gtk-application-prefer-dark-theme=1
gtk-xft-antialias=1
gtk-xft-hinting=1
gtk-xft-hintstyle=hintslight
gtk-xft-rgba=rgb
EOF
cat > "$HOME/.config/gtk-4.0/settings.ini" <<EOF
[Settings]
gtk-theme-name=$THEME
gtk-icon-theme-name=$ICONS
gtk-cursor-theme-name=$CURSOR
gtk-font-name=$FONT_UI
gtk-application-prefer-dark-theme=1
EOF
# esporta variabili utili
export GTK_THEME=$THEME
export XCURSOR_THEME=$CURSOR
export XCURSOR_SIZE=24