doas, pinentry-dmenu y scripts en vez de blueman, autorandr y gammastep
- doas en vez de sudo (sistema/etc/doas.conf; xbps.d permite quitar sudo). - pinentry-dmenu en X y pinentry-curses en una tty (pinentry-menu); fuera GTK 2 (.gtkrc-2.0 y el arreglo de colores del tema). - bluetooth: menú de dmenu con bluetoothctl en vez de blueman. - pantallas: xrandr a pelo en vez de autorandr, también desde udev. - luz: sct cada minuto en vez de gammastep. - xwallpaper para el fondo y nsxiv para las imágenes de st, en vez de feh. - volumen salida en vez de pavucontrol; menu reúne los colores de dmenu. - mpv en vez de vlc; fuera btop. - install.sh: paso quitar para desinstalar lo sustituido. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01C5v1qWDwgkaVM5kjVHGGh8
This commit is contained in:
parent
5fee14ab7f
commit
a83294ace4
23 changed files with 362 additions and 430 deletions
|
|
@ -1,15 +1,10 @@
|
|||
#!/bin/sh
|
||||
# Menú de apagado con dmenu (Mod+Shift+Escape en dwm). Apagar, reiniciar y
|
||||
# salir de dwm piden confirmación. Suspender, apagar y reiniciar usan sudo
|
||||
# sin contraseña (sistema/etc/sudoers.d/energia).
|
||||
|
||||
menu() {
|
||||
dmenu -i -p "$1" -fn "Fira Code:size=11" \
|
||||
-nb "#2d353b" -nf "#d3c6aa" -sb "#a7c080" -sf "#2d353b"
|
||||
}
|
||||
# salir de dwm piden confirmación. Suspender, apagar y reiniciar usan doas
|
||||
# sin contraseña (sistema/etc/doas.conf).
|
||||
|
||||
confirmar() {
|
||||
[ "$(printf 'No\nSí\n' | menu "¿$1?")" = "Sí" ]
|
||||
[ "$(printf 'No\nSí\n' | menu -p "¿$1?")" = "Sí" ]
|
||||
}
|
||||
|
||||
opcion=$(printf '%s\n' \
|
||||
|
|
@ -17,12 +12,12 @@ opcion=$(printf '%s\n' \
|
|||
" Suspender" \
|
||||
" Salir de dwm" \
|
||||
" Reiniciar" \
|
||||
" Apagar" | menu "Sesión:")
|
||||
" Apagar" | menu -p "Sesión:")
|
||||
|
||||
case $opcion in
|
||||
*Bloquear) slock ;;
|
||||
*Suspender) sudo -n zzz ;;
|
||||
*Suspender) doas -n zzz ;;
|
||||
*Salir*) confirmar "Salir de dwm" && pkill -TERM -x dwm ;;
|
||||
*Reiniciar) confirmar "Reiniciar" && sudo -n reboot ;;
|
||||
*Apagar) confirmar "Apagar" && sudo -n poweroff ;;
|
||||
*Reiniciar) confirmar "Reiniciar" && doas -n reboot ;;
|
||||
*Apagar) confirmar "Apagar" && doas -n poweroff ;;
|
||||
esac
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
# mientras se descarga, y al 3 % suspende (con slock, como al cerrar la
|
||||
# tapa) en vez de dejar que se apague de golpe. Cada umbral actúa una vez;
|
||||
# al enchufar el cargador se reinicia. Se lanza desde .xinitrc y comprueba
|
||||
# cada minuto. Suspender usa "sudo -n zzz" (regla en sistema/etc/sudoers.d).
|
||||
# cada minuto. Suspender usa "doas -n zzz" (regla en sistema/etc/doas.conf).
|
||||
|
||||
BAJA=15
|
||||
CRITICA=5
|
||||
|
|
@ -26,7 +26,7 @@ while :; do
|
|||
-i battery-empty "Batería agotada" "Queda un $nivel %: suspendiendo en 10 s"
|
||||
avisado=$SUSPENDER
|
||||
sleep 10
|
||||
[ "$(cat "$bat/status")" = Discharging ] && sudo -n zzz
|
||||
[ "$(cat "$bat/status")" = Discharging ] && doas -n zzz
|
||||
elif [ "$nivel" -le "$CRITICA" ] && [ "$avisado" -gt "$CRITICA" ]; then
|
||||
notify-send -u critical -h string:x-dunst-stack-tag:bateria \
|
||||
-i battery-empty "Batería crítica" "Queda un $nivel %: enchufa el cargador ya"
|
||||
|
|
|
|||
70
home/.local/bin/bluetooth
Executable file
70
home/.local/bin/bluetooth
Executable file
|
|
@ -0,0 +1,70 @@
|
|||
#!/bin/sh
|
||||
# Menú de bluetooth con dmenu (clic izquierdo en BT de la barra): conectar o
|
||||
# desconectar los dispositivos emparejados ( = conectado), buscar y
|
||||
# emparejar uno nuevo y apagar el adaptador. Si está apagado, ofrece
|
||||
# encenderlo.
|
||||
|
||||
avisar() {
|
||||
notify-send -h string:x-dunst-stack-tag:bluetooth -i bluetooth "Bluetooth" "$1"
|
||||
}
|
||||
|
||||
# "Device AA:BB:CC:DD:EE:FF Nombre" -> "Nombre (AA:BB:CC:DD:EE:FF)"
|
||||
lista() { sed -n 's/^Device \([^ ]*\) \(.*\)/\2 (\1)/p'; }
|
||||
mac() { printf '%s\n' "$1" | sed 's/.*(\([^)]*\))$/\1/'; }
|
||||
|
||||
if ! bluetoothctl show | grep -q 'Powered: yes'; then
|
||||
[ "$(echo Encender | menu -p Bluetooth:)" = Encender ] || exit 0
|
||||
bluetoothctl power on >/dev/null
|
||||
pkill -USR1 -x slstatus
|
||||
fi
|
||||
|
||||
conectados=$(bluetoothctl devices Connected | lista)
|
||||
emparejados=$(bluetoothctl devices Paired | lista)
|
||||
|
||||
opcion=$(
|
||||
printf '%s\n' "$emparejados" | while IFS= read -r d; do
|
||||
[ -n "$d" ] || continue
|
||||
if printf '%s\n' "$conectados" | grep -qxF "$d"; then
|
||||
echo " $d"
|
||||
else
|
||||
echo " $d"
|
||||
fi
|
||||
done
|
||||
echo " Buscar dispositivos"
|
||||
echo " Apagar"
|
||||
)
|
||||
opcion=$(printf '%s\n' "$opcion" | menu -p Bluetooth:)
|
||||
|
||||
case $opcion in
|
||||
'') exit 0 ;;
|
||||
*" Apagar")
|
||||
bluetoothctl power off >/dev/null
|
||||
;;
|
||||
*" Buscar dispositivos")
|
||||
avisar "Buscando dispositivos durante 10 s..."
|
||||
bluetoothctl --timeout 10 scan on >/dev/null
|
||||
nuevo=$(bluetoothctl devices | lista | awk -v e="$emparejados" '
|
||||
BEGIN { n = split(e, a, "\n"); for (i = 1; i <= n; i++) visto[a[i]] }
|
||||
!($0 in visto)' | menu -p Emparejar:)
|
||||
[ -n "$nuevo" ] || exit 0
|
||||
m=$(mac "$nuevo")
|
||||
if bluetoothctl pair "$m" >/dev/null && bluetoothctl trust "$m" >/dev/null &&
|
||||
bluetoothctl connect "$m" >/dev/null; then
|
||||
avisar "Conectado: $nuevo"
|
||||
else
|
||||
avisar "No se pudo emparejar: $nuevo"
|
||||
fi
|
||||
;;
|
||||
" "*)
|
||||
bluetoothctl disconnect "$(mac "$opcion")" >/dev/null &&
|
||||
avisar "Desconectado: ${opcion#" "}"
|
||||
;;
|
||||
*)
|
||||
if bluetoothctl connect "$(mac "$opcion")" >/dev/null; then
|
||||
avisar "Conectado: ${opcion#" "}"
|
||||
else
|
||||
avisar "No se pudo conectar: ${opcion#" "}"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
pkill -USR1 -x slstatus
|
||||
22
home/.local/bin/luz
Executable file
22
home/.local/bin/luz
Executable file
|
|
@ -0,0 +1,22 @@
|
|||
#!/bin/sh
|
||||
# Luz nocturna con sct: de 20:00 a 21:00 pasa poco a poco a luz cálida y de
|
||||
# 7:00 a 8:00 vuelve a la normal. Se lanza desde .xinitrc y la ajusta cada
|
||||
# minuto, así que también vuelve sola si xrandr la reinicia.
|
||||
|
||||
DIA=6500
|
||||
NOCHE=4000
|
||||
|
||||
while :; do
|
||||
m=$(($(date +%-H) * 60 + $(date +%-M)))
|
||||
if [ "$m" -lt 420 ] || [ "$m" -ge 1260 ]; then
|
||||
t=$NOCHE
|
||||
elif [ "$m" -lt 480 ]; then
|
||||
t=$((NOCHE + (DIA - NOCHE) * (m - 420) / 60))
|
||||
elif [ "$m" -lt 1200 ]; then
|
||||
t=$DIA
|
||||
else
|
||||
t=$((DIA - (DIA - NOCHE) * (m - 1200) / 60))
|
||||
fi
|
||||
sct "$t"
|
||||
sleep 60
|
||||
done
|
||||
5
home/.local/bin/menu
Executable file
5
home/.local/bin/menu
Executable file
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/sh
|
||||
# dmenu con la fuente y los colores de dwm, para los scripts de ~/.local/bin.
|
||||
# Uso: menu [opciones de dmenu] (las que se pasen mandan sobre estas)
|
||||
exec dmenu -i -fn "Fira Code:size=11" \
|
||||
-nb "#2d353b" -nf "#d3c6aa" -sb "#a7c080" -sf "#2d353b" "$@"
|
||||
8
home/.local/bin/pinentry-menu
Executable file
8
home/.local/bin/pinentry-menu
Executable file
|
|
@ -0,0 +1,8 @@
|
|||
#!/bin/sh
|
||||
# pinentry de gpg-agent: pinentry-dmenu en X y pinentry-curses en una tty.
|
||||
# Los colores de pinentry-dmenu están en ~/.gnupg/pinentry-dmenu.conf
|
||||
# (lo escribe install.sh, paso gnupg).
|
||||
if [ -n "$DISPLAY" ]; then
|
||||
exec pinentry-dmenu "$@"
|
||||
fi
|
||||
exec pinentry-curses "$@"
|
||||
|
|
@ -1,14 +1,31 @@
|
|||
#!/bin/sh
|
||||
# Cambia el volumen o silencia la salida o el micro (PipeWire), refresca
|
||||
# slstatus y lo muestra en una notificación que se sustituye a sí misma.
|
||||
# Uso: volumen subir|bajar|silenciar|micro
|
||||
# "salida" elige con dmenu por dónde suena (altavoces, cascos...).
|
||||
# Uso: volumen subir|bajar|silenciar|micro|salida
|
||||
|
||||
case $1 in
|
||||
subir) wpctl set-volume -l 1.0 @DEFAULT_AUDIO_SINK@ 5%+ ;;
|
||||
bajar) wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%- ;;
|
||||
silenciar) wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle ;;
|
||||
micro) wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle ;;
|
||||
*) echo "uso: volumen subir|bajar|silenciar|micro" >&2; exit 1 ;;
|
||||
salida)
|
||||
# Las salidas de "wpctl status" (sección Sinks de Audio), con * la actual:
|
||||
# " │ * 86. Nombre [vol: 0.50]" -> "* 86. Nombre"
|
||||
s=$(wpctl status | awk '
|
||||
/Sinks:/ { dentro = 1; next }
|
||||
dentro && !/[0-9]\./ { exit }
|
||||
dentro {
|
||||
sub(/^[^*0-9]*/, ""); actual = sub(/^\* */, "")
|
||||
sub(/ *\[vol:.*/, ""); print (actual ? "* " : " ") $0
|
||||
}' | menu -p Salida:)
|
||||
[ -n "$s" ] || exit 0
|
||||
s=${s#??}
|
||||
wpctl set-default "${s%%.*}"
|
||||
exec notify-send -t 2000 -h string:x-dunst-stack-tag:volumen \
|
||||
-i audio-speakers "Salida de audio" "${s#*. }"
|
||||
;;
|
||||
*) echo "uso: volumen subir|bajar|silenciar|micro|salida" >&2; exit 1 ;;
|
||||
esac
|
||||
|
||||
pkill -USR1 -x slstatus
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue