setup-kapelu 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +120 -0
- package/config/.bashrc +148 -0
- package/config/protect-main.json +47 -0
- package/index.js +78 -0
- package/install.sh +164 -0
- package/package.json +33 -0
- package/script/btn-log.sh +98 -0
- package/script/btn-shd.sh +170 -0
- package/script/btn-sus.sh +176 -0
- package/script/node-clean.sh +326 -0
- package/script/setup.sh +463 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# ╔════════════════════════════════════════════════════╗
|
|
3
|
+
# │ cerrar-sesion - Script para cerrar la sesión │
|
|
4
|
+
# │ Versión: 2.0 │
|
|
5
|
+
# │ Autor: Daniel Calderon - Kapelu │
|
|
6
|
+
# │ Fecha: 04/03/2026 │
|
|
7
|
+
# │ WebSite: https://danielcalderon.vercel.app/ │
|
|
8
|
+
# │ Github: https://github.com/Kapelu │
|
|
9
|
+
# ╚════════════════════════════════════════════════════╝
|
|
10
|
+
set -Eeuo pipefail
|
|
11
|
+
|
|
12
|
+
DELAY=15
|
|
13
|
+
BAR_LENGTH=15
|
|
14
|
+
MARGIN=5
|
|
15
|
+
|
|
16
|
+
yellow="\e[0;33m"
|
|
17
|
+
green="\e[0;32m"
|
|
18
|
+
red="\e[0;31m"
|
|
19
|
+
reset="\033[0m"
|
|
20
|
+
|
|
21
|
+
# Funciones de utilidad
|
|
22
|
+
# ─────────────────────────────────────────────
|
|
23
|
+
|
|
24
|
+
command_exists() {
|
|
25
|
+
command -v "$1" >/dev/null 2>&1
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
cleanup() {
|
|
29
|
+
echo -ne "\e[?25h"
|
|
30
|
+
}
|
|
31
|
+
trap cleanup EXIT
|
|
32
|
+
|
|
33
|
+
cancel() {
|
|
34
|
+
clear
|
|
35
|
+
echo -e "\n${red}❌ Operación cancelada${reset}"
|
|
36
|
+
sleep 1
|
|
37
|
+
exit 0
|
|
38
|
+
}
|
|
39
|
+
trap cancel SIGINT
|
|
40
|
+
|
|
41
|
+
# UI Principal
|
|
42
|
+
# ─────────────────────────────────────────────
|
|
43
|
+
|
|
44
|
+
echo -ne "\e[?25l"
|
|
45
|
+
clear
|
|
46
|
+
echo -e "💤 ${yellow}La sesión se cerrará en ${green}$DELAY${reset}${yellow} segundos...${reset}"
|
|
47
|
+
echo ""
|
|
48
|
+
printf "\r%*s%s\n\n" "$MARGIN" "" "Presiona Ctrl+C para cancelar..."
|
|
49
|
+
|
|
50
|
+
# Barra de progreso
|
|
51
|
+
# ─────────────────────────────────────────────
|
|
52
|
+
|
|
53
|
+
for ((i=1; i<=DELAY; i++)); do
|
|
54
|
+
filled=$i
|
|
55
|
+
empty=$((BAR_LENGTH - filled))
|
|
56
|
+
|
|
57
|
+
progress=$(printf '🟩%.0s' $(seq 1 $filled))
|
|
58
|
+
spaces=$(printf '⬜%.0s' $(seq 1 $empty))
|
|
59
|
+
|
|
60
|
+
printf "\r%*s%s " "$MARGIN" "" "$progress$spaces" # inicio =%d/%d fin="$i" "$DELAY"
|
|
61
|
+
sleep 1
|
|
62
|
+
done
|
|
63
|
+
|
|
64
|
+
echo -e "\n\n${green}✔ Cerrando sesión...${reset}"
|
|
65
|
+
|
|
66
|
+
# Detección de entorno y cierre de sesión
|
|
67
|
+
# ─────────────────────────────────────────────
|
|
68
|
+
|
|
69
|
+
SESSION_TYPE="${XDG_SESSION_TYPE:-unknown}"
|
|
70
|
+
DESKTOP="${XDG_CURRENT_DESKTOP:-unknown}"
|
|
71
|
+
|
|
72
|
+
echo -e "${yellow}→ Entorno detectado:${reset} $DESKTOP ($SESSION_TYPE)"
|
|
73
|
+
|
|
74
|
+
# 1- GNOME (método preferido)
|
|
75
|
+
if command_exists gnome-session-quit; then
|
|
76
|
+
echo -e "${green}→ Usando gnome-session-quit${reset}"
|
|
77
|
+
gnome-session-quit --logout --no-prompt
|
|
78
|
+
exit 0
|
|
79
|
+
fi
|
|
80
|
+
|
|
81
|
+
# 2- loginctl con sesión activa
|
|
82
|
+
if command_exists loginctl; then
|
|
83
|
+
SESSION_ID=$(loginctl list-sessions --no-legend 2>/dev/null | awk -v user="$USER" '$2==user {print $1; exit}')
|
|
84
|
+
|
|
85
|
+
if [[ -n "${SESSION_ID:-}" ]]; then
|
|
86
|
+
echo -e "${green}→ Usando loginctl terminate-session${reset}"
|
|
87
|
+
loginctl terminate-session "$SESSION_ID"
|
|
88
|
+
exit 0
|
|
89
|
+
fi
|
|
90
|
+
|
|
91
|
+
echo -e "${green}→ Usando loginctl terminate-user${reset}"
|
|
92
|
+
loginctl terminate-user "$USER"
|
|
93
|
+
exit 0
|
|
94
|
+
fi
|
|
95
|
+
|
|
96
|
+
# 3- Fallback agresivo
|
|
97
|
+
echo -e "${red}→ Fallback: matando procesos del usuario${reset}"
|
|
98
|
+
pkill -KILL -u "$USER"
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# ╔════════════════════════════════════════════════════╗
|
|
3
|
+
# │ cerrar-sesion - Script para cerrar la sesión │
|
|
4
|
+
# │ Versión: 2.0 │
|
|
5
|
+
# │ Autor: Daniel Calderon - Kapelu │
|
|
6
|
+
# │ Fecha: 04/03/2026 │
|
|
7
|
+
# │ WebSite: https://danielcalderon.vercel.app/ │
|
|
8
|
+
# │ Github: https://github.com/Kapelu │
|
|
9
|
+
# ╚════════════════════════════════════════════════════╝
|
|
10
|
+
set -Eeuo pipefail
|
|
11
|
+
|
|
12
|
+
DELAY=15
|
|
13
|
+
BAR_LENGTH=15
|
|
14
|
+
MARGIN=5
|
|
15
|
+
|
|
16
|
+
yellow="\e[0;33m"
|
|
17
|
+
green="\e[0;32m"
|
|
18
|
+
red="\e[0;31m"
|
|
19
|
+
blue="\e[0;34m"
|
|
20
|
+
reset="\033[0m"
|
|
21
|
+
|
|
22
|
+
# utilidades
|
|
23
|
+
# ─────────────────────────────────────────────
|
|
24
|
+
command_exists() { command -v "$1" >/dev/null 2>&1;}
|
|
25
|
+
|
|
26
|
+
cleanup() { echo -ne "\e[?25h"; }
|
|
27
|
+
trap cleanup EXIT
|
|
28
|
+
|
|
29
|
+
cancel() {
|
|
30
|
+
clear
|
|
31
|
+
echo -e "\n${red}❌ Apagado cancelado${reset}"
|
|
32
|
+
sleep 1
|
|
33
|
+
exit 0
|
|
34
|
+
}
|
|
35
|
+
trap cancel SIGINT
|
|
36
|
+
|
|
37
|
+
hide_cursor() { echo -ne "\e[?25l"; }
|
|
38
|
+
show_cursor() { echo -ne "\e[?25h"; }
|
|
39
|
+
|
|
40
|
+
# Barra de progreso
|
|
41
|
+
# ─────────────────────────────────────────────
|
|
42
|
+
progress_bar() {
|
|
43
|
+
|
|
44
|
+
for ((i=1;i<=DELAY;i++)); do
|
|
45
|
+
filled=$i
|
|
46
|
+
empty=$((BAR_LENGTH - filled))
|
|
47
|
+
|
|
48
|
+
progress=$(printf '🟩%.0s' $(seq 1 $filled))
|
|
49
|
+
spaces=$(printf '⬜%.0s' $(seq 1 $empty))
|
|
50
|
+
|
|
51
|
+
printf "\r%*s%s " "$MARGIN" "" "$progress$spaces"
|
|
52
|
+
|
|
53
|
+
sleep 1
|
|
54
|
+
done
|
|
55
|
+
|
|
56
|
+
echo ""
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
# detección de entorno
|
|
60
|
+
# ─────────────────────────────────────────────
|
|
61
|
+
detect_session_type() {
|
|
62
|
+
echo "${XDG_SESSION_TYPE:-unknown}"
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
detect_desktop() {
|
|
66
|
+
echo "${XDG_CURRENT_DESKTOP:-unknown}" | tr '[:upper:]' '[:lower:]'
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
# sistema de apagado
|
|
70
|
+
# ─────────────────────────────────────────────
|
|
71
|
+
shutdown_system() {
|
|
72
|
+
|
|
73
|
+
echo -e "${blue}→ Detectando entorno...${reset}"
|
|
74
|
+
|
|
75
|
+
DESKTOP=$(detect_desktop)
|
|
76
|
+
SESSION=$(detect_session_type)
|
|
77
|
+
|
|
78
|
+
echo -e "${yellow}Desktop:${reset} $DESKTOP"
|
|
79
|
+
echo -e "${yellow}Session:${reset} $SESSION"
|
|
80
|
+
|
|
81
|
+
# GNOME (DBus)
|
|
82
|
+
if [[ "$DESKTOP" == *gnome* ]] && command_exists gdbus; then
|
|
83
|
+
|
|
84
|
+
echo -e "${green}→ Método GNOME (gdbus)${reset}"
|
|
85
|
+
|
|
86
|
+
gdbus call --system \
|
|
87
|
+
--dest org.freedesktop.login1 \
|
|
88
|
+
--object-path /org/freedesktop/login1 \
|
|
89
|
+
--method org.freedesktop.login1.Manager.PowerOff true
|
|
90
|
+
|
|
91
|
+
return
|
|
92
|
+
fi
|
|
93
|
+
|
|
94
|
+
# KDE
|
|
95
|
+
if [[ "$DESKTOP" == *kde* || "$DESKTOP" == *plasma* ]] && command_exists qdbus; then
|
|
96
|
+
|
|
97
|
+
echo -e "${green}→ Método KDE (qdbus)${reset}"
|
|
98
|
+
|
|
99
|
+
qdbus org.freedesktop.login1 \
|
|
100
|
+
/org/freedesktop/login1 \
|
|
101
|
+
org.freedesktop.login1.Manager.PowerOff true
|
|
102
|
+
|
|
103
|
+
return
|
|
104
|
+
fi
|
|
105
|
+
|
|
106
|
+
# systemd estándar
|
|
107
|
+
if command_exists systemctl; then
|
|
108
|
+
echo -e "${green}→ Método systemctl${reset}"
|
|
109
|
+
systemctl poweroff
|
|
110
|
+
return
|
|
111
|
+
fi
|
|
112
|
+
|
|
113
|
+
# loginctl
|
|
114
|
+
if command_exists loginctl; then
|
|
115
|
+
echo -e "${green}→ Método loginctl${reset}"
|
|
116
|
+
loginctl poweroff
|
|
117
|
+
return
|
|
118
|
+
fi
|
|
119
|
+
|
|
120
|
+
# shutdown clásico
|
|
121
|
+
if command_exists shutdown; then
|
|
122
|
+
echo -e "${green}→ Método shutdown${reset}"
|
|
123
|
+
shutdown -h now
|
|
124
|
+
return
|
|
125
|
+
fi
|
|
126
|
+
|
|
127
|
+
echo -e "${red}❌ No se encontró método compatible.${reset}"
|
|
128
|
+
exit 1
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
# cierre inteligente de terminal
|
|
132
|
+
# ─────────────────────────────────────────────
|
|
133
|
+
close_terminal_if_independent() {
|
|
134
|
+
|
|
135
|
+
if [[ -t 0 && -n "${DISPLAY:-}" ]]; then
|
|
136
|
+
|
|
137
|
+
PARENT=$(ps -o comm= -p "$PPID" 2>/dev/null || echo "unknown")
|
|
138
|
+
|
|
139
|
+
case "$PARENT" in
|
|
140
|
+
gnome-terminal*|konsole*|xfce4-terminal*|tilix*|alacritty*)
|
|
141
|
+
echo -e "${blue}→ Cerrando ventana de terminal${reset}"
|
|
142
|
+
sleep 1
|
|
143
|
+
kill -TERM "$PPID" 2>/dev/null || true
|
|
144
|
+
;;
|
|
145
|
+
esac
|
|
146
|
+
fi
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
# UI principal
|
|
150
|
+
# ─────────────────────────────────────────────
|
|
151
|
+
main() {
|
|
152
|
+
|
|
153
|
+
hide_cursor
|
|
154
|
+
clear
|
|
155
|
+
|
|
156
|
+
echo -e "⏻ ${yellow}El sistema se apagará en ${green}$DELAY${reset}${yellow} segundos...${reset}"
|
|
157
|
+
echo ""
|
|
158
|
+
|
|
159
|
+
printf "\r%*s%s\n\n" "$MARGIN" "" "Presiona Ctrl+C para cancelar..."
|
|
160
|
+
|
|
161
|
+
progress_bar
|
|
162
|
+
|
|
163
|
+
echo -e "\n${green}✔ Iniciando apagado...${reset}"
|
|
164
|
+
|
|
165
|
+
shutdown_system
|
|
166
|
+
|
|
167
|
+
close_terminal_if_independent
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
main "$@"
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# ╔════════════════════════════════════════════════════╗
|
|
3
|
+
# │ cerrar-sesion - Script para cerrar la sesión │
|
|
4
|
+
# │ Versión: 2.0 │
|
|
5
|
+
# │ Autor: Daniel Calderon - Kapelu │
|
|
6
|
+
# │ Fecha: 02/02/2026 │
|
|
7
|
+
# │ WebSite: https://danielcalderon.vercel.app/ │
|
|
8
|
+
# │ Github: https://github.com/Kapelu │
|
|
9
|
+
# ╚════════════════════════════════════════════════════╝
|
|
10
|
+
set -Eeuo pipefail
|
|
11
|
+
|
|
12
|
+
VERSION="2.0.0"
|
|
13
|
+
DELAY=15
|
|
14
|
+
BAR_LENGTH=15
|
|
15
|
+
MARGIN=5
|
|
16
|
+
|
|
17
|
+
yellow="\e[0;33m"
|
|
18
|
+
green="\e[0;32m"
|
|
19
|
+
red="\e[0;31m"
|
|
20
|
+
blue="\e[0;34m"
|
|
21
|
+
reset="\033[0m"
|
|
22
|
+
|
|
23
|
+
# funciones de utilidad
|
|
24
|
+
# ─────────────────────────────────────────────
|
|
25
|
+
|
|
26
|
+
command_exists() { command -v "$1" >/dev/null 2>&1; }
|
|
27
|
+
|
|
28
|
+
cleanup() { echo -ne "\e[?25h"; }
|
|
29
|
+
trap cleanup EXIT
|
|
30
|
+
|
|
31
|
+
cancel() {
|
|
32
|
+
clear
|
|
33
|
+
echo -e "\n${red}❌ Suspensión cancelada${reset}"
|
|
34
|
+
sleep 1
|
|
35
|
+
exit 0
|
|
36
|
+
}
|
|
37
|
+
trap cancel SIGINT
|
|
38
|
+
|
|
39
|
+
hide_cursor() { echo -ne "\e[?25l"; }
|
|
40
|
+
show_cursor() { echo -ne "\e[?25h"; }
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
# detección de entorno
|
|
44
|
+
# ─────────────────────────────────────────────
|
|
45
|
+
|
|
46
|
+
detect_session_type() {
|
|
47
|
+
echo "${XDG_SESSION_TYPE:-unknown}"
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
detect_desktop() {
|
|
51
|
+
echo "${XDG_CURRENT_DESKTOP:-unknown}" | tr '[:upper:]' '[:lower:]'
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
detect_terminal() {
|
|
55
|
+
echo "${TERM_PROGRAM:-${COLORTERM:-unknown}}"
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
is_wayland() {
|
|
59
|
+
[[ "$(detect_session_type)" == "wayland" ]]
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
is_x11() {
|
|
63
|
+
[[ "$(detect_session_type)" == "x11" ]]
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
# Barra de progreso
|
|
67
|
+
# ─────────────────────────────────────────────
|
|
68
|
+
|
|
69
|
+
progress_bar() {
|
|
70
|
+
for ((i=1; i<=DELAY; i++)); do
|
|
71
|
+
filled=$i
|
|
72
|
+
empty=$((BAR_LENGTH - filled))
|
|
73
|
+
|
|
74
|
+
progress=$(printf '🟩%.0s' $(seq 1 $filled))
|
|
75
|
+
spaces=$(printf '⬜%.0s' $(seq 1 $empty))
|
|
76
|
+
|
|
77
|
+
printf "\r%*s%s " "$MARGIN" "" "$progress$spaces"
|
|
78
|
+
sleep 1
|
|
79
|
+
done
|
|
80
|
+
echo ""
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
# Sistema de suspensión
|
|
84
|
+
# ─────────────────────────────────────────────
|
|
85
|
+
|
|
86
|
+
suspend_system() {
|
|
87
|
+
|
|
88
|
+
echo -e "${blue}→ Detectando entorno...${reset}"
|
|
89
|
+
DESKTOP=$(detect_desktop)
|
|
90
|
+
SESSION=$(detect_session_type)
|
|
91
|
+
|
|
92
|
+
echo -e "${yellow}Desktop:${reset} $DESKTOP"
|
|
93
|
+
echo -e "${yellow}Session:${reset} $SESSION"
|
|
94
|
+
|
|
95
|
+
# GNOME (usa DBus si disponible)
|
|
96
|
+
if [[ "$DESKTOP" == *gnome* ]] && command_exists gdbus; then
|
|
97
|
+
echo -e "${green}→ Método GNOME (gdbus)${reset}"
|
|
98
|
+
gdbus call --system \
|
|
99
|
+
--dest org.freedesktop.login1 \
|
|
100
|
+
--object-path /org/freedesktop/login1 \
|
|
101
|
+
--method org.freedesktop.login1.Manager.Suspend true
|
|
102
|
+
return
|
|
103
|
+
fi
|
|
104
|
+
|
|
105
|
+
# KDE Plasma
|
|
106
|
+
if [[ "$DESKTOP" == *kde* || "$DESKTOP" == *plasma* ]] && command_exists qdbus; then
|
|
107
|
+
echo -e "${green}→ Método KDE (qdbus)${reset}"
|
|
108
|
+
qdbus org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager.Suspend true
|
|
109
|
+
return
|
|
110
|
+
fi
|
|
111
|
+
|
|
112
|
+
# systemd estándar
|
|
113
|
+
if command_exists systemctl; then
|
|
114
|
+
echo -e "${green}→ Método systemctl${reset}"
|
|
115
|
+
systemctl suspend
|
|
116
|
+
return
|
|
117
|
+
fi
|
|
118
|
+
|
|
119
|
+
# loginctl fallback
|
|
120
|
+
if command_exists loginctl; then
|
|
121
|
+
echo -e "${green}→ Método loginctl${reset}"
|
|
122
|
+
loginctl suspend
|
|
123
|
+
return
|
|
124
|
+
fi
|
|
125
|
+
|
|
126
|
+
# pm-utils legacy
|
|
127
|
+
if command_exists pm-suspend; then
|
|
128
|
+
echo -e "${green}→ Método pm-suspend${reset}"
|
|
129
|
+
pm-suspend
|
|
130
|
+
return
|
|
131
|
+
fi
|
|
132
|
+
|
|
133
|
+
echo -e "${red}❌ No se encontró método compatible.${reset}"
|
|
134
|
+
exit 1
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
# Sistema de cierre de terminal inteligente
|
|
138
|
+
# ─────────────────────────────────────────────
|
|
139
|
+
|
|
140
|
+
close_terminal_if_independent() {
|
|
141
|
+
|
|
142
|
+
# Solo si NO estamos en TTY pura
|
|
143
|
+
if [[ -t 0 && -n "${DISPLAY:-}" ]]; then
|
|
144
|
+
# Detectar proceso padre
|
|
145
|
+
PARENT=$(ps -o comm= -p "$PPID" 2>/dev/null || echo "unknown")
|
|
146
|
+
|
|
147
|
+
case "$PARENT" in
|
|
148
|
+
gnome-terminal*|konsole*|xfce4-terminal*|tilix*|alacritty*)
|
|
149
|
+
echo -e "${blue}→ Cerrando ventana de terminal${reset}"
|
|
150
|
+
sleep 1
|
|
151
|
+
kill -TERM "$PPID" 2>/dev/null || true
|
|
152
|
+
;;
|
|
153
|
+
esac
|
|
154
|
+
fi
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
# UI Principal
|
|
158
|
+
# ─────────────────────────────────────────────
|
|
159
|
+
|
|
160
|
+
main() {
|
|
161
|
+
hide_cursor
|
|
162
|
+
clear
|
|
163
|
+
|
|
164
|
+
echo -e "💤 ${yellow}El sistema se suspenderá en ${green}$DELAY${reset}${yellow} segundos...${reset}"
|
|
165
|
+
echo ""
|
|
166
|
+
printf "\r%*s%s\n\n" "$MARGIN" "" "Presiona Ctrl+C para cancelar..."
|
|
167
|
+
|
|
168
|
+
progress_bar
|
|
169
|
+
|
|
170
|
+
echo -e "\n${green}✔ Iniciando suspensión...${reset}"
|
|
171
|
+
|
|
172
|
+
suspend_system
|
|
173
|
+
close_terminal_if_independent
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
main "$@"
|