forked from phoenixbyrd/Termux_XFCE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.sh
122 lines (104 loc) · 3.13 KB
/
utils.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/bash
#App Installer Utility .. For installing additional applications not available in Termux or Debian proot repositories.
cat <<'EOF' > "$PREFIX/bin/app-installer"
#!/bin/bash
# Define the directory paths
INSTALLER_DIR="$HOME/.App-Installer"
REPO_URL="https://github.com/phoenixbyrd/App-Installer.git"
DESKTOP_DIR="$HOME/Desktop"
APP_DESKTOP_FILE="$DESKTOP_DIR/app-installer.desktop"
# Check if the directory already exists
if [ ! -d "$INSTALLER_DIR" ]; then
# Directory doesn't exist, clone the repository
git clone "$REPO_URL" "$INSTALLER_DIR"
if [ $? -eq 0 ]; then
echo "Repository cloned successfully."
else
echo "Failed to clone repository. Exiting."
exit 1
fi
else
echo "Directory already exists. Skipping clone."
"$INSTALLER_DIR/app-installer"
fi
# Check if the .desktop file exists
if [ ! -f "$APP_DESKTOP_FILE" ]; then
# .desktop file doesn't exist, create it
echo "[Desktop Entry]
Version=1.0
Type=Application
Name=App Installer
Comment=
Exec=$PREFIX/bin/app-installer
Icon=package-install
Categories=System;
Path=
Terminal=false
StartupNotify=false
" > "$APP_DESKTOP_FILE"
chmod +x "$APP_DESKTOP_FILE"
fi
# Ensure the app-installer script is executable
chmod +x "$INSTALLER_DIR/app-installer"
EOF
chmod +x "$PREFIX/bin/app-installer"
bash $PREFIX/bin/app-installer
# Check if the .desktop file exists
if [ ! -f "$HOME/Desktop/app-installer.desktop" ]; then
# .desktop file doesn't exist, create it
echo "[Desktop Entry]
Version=1.0
Type=Application
Name=App Installer
Comment=
Exec=$PREFIX/bin/app-installer
Icon=package-install
Categories=System;
Path=
Terminal=false
StartupNotify=false
" > "$HOME/Desktop/app-installer.desktop"
chmod +x "$HOME/Desktop/app-installer.desktop"
fi
#Shutdown Utility
cat <<'EOF' > $PREFIX/bin/kill_termux_x11
#!/bin/bash
# Check if Apt, dpkg, is running in Termux or Proot
if pgrep -f 'apt|apt-get|dpkg'; then
zenity --info --text="Software is currently installing in Termux or Proot. Please wait for these processes to finish before continuing."
exit 1
fi
# Get the process IDs of Termux-X11 and XFCE sessions
termux_x11_pid=$(pgrep -f /system/bin/app_process.*com.termux.x11.Loader)
xfce_pid=$(pgrep -f "xfce4-session")
# Add debug output
echo "Termux-X11 PID: $termux_x11_pid"
echo "XFCE PID: $xfce_pid"
# Check if the process IDs exist
if [ -n "$termux_x11_pid" ] && [ -n "$xfce_pid" ]; then
# Kill the processes
kill -9 "$termux_x11_pid" "$xfce_pid"
zenity --info --text="Termux-X11 and XFCE sessions closed."
else
zenity --info --text="Termux-X11 or XFCE session not found."
fi
info_output=$(termux-info)
pid=$(echo "$info_output" | grep -o 'TERMUX_APP_PID=[0-9]\+' | awk -F= '{print $2}')
kill "$pid"
exit 0
EOF
chmod +x $PREFIX/bin/kill_termux_x11
#Create kill_termux_x11.desktop
echo "[Desktop Entry]
Version=1.0
Type=Application
Name=Kill Termux X11
Comment=
Exec=kill_termux_x11
Icon=system-shutdown
Categories=System;
Path=
StartupNotify=false
" > $HOME/Desktop/kill_termux_x11.desktop
chmod +x $HOME/Desktop/kill_termux_x11.desktop
mv $HOME/Desktop/kill_termux_x11.desktop $PREFIX/share/applications