blob: 5a502afaeb844d0af07f4eacf442ccb641ea8733 (
plain)
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
|
#!/bin/sh
# Function to show informational dialog
show_dialog() {
if command -v zenity >/dev/null 2>&1; then
zenity --info --title="Android Screencast" --text="$1"
elif command -v kdialog >/dev/null 2>&1; then
kdialog --title "Android Screencast" --msgbox "$1"
else
echo "$1"
fi
}
# Function to show error dialog
show_error() {
if command -v zenity >/dev/null 2>&1; then
zenity --error --title="Android Screencast Error" --text="$1"
elif command -v kdialog >/dev/null 2>&1; then
kdialog --title "Android Screencast Error" --error "$1"
else
echo "Error: $1" >&2
fi
}
# Prompt user to connect the phone
show_dialog "Please connect your phone with USB debugging enabled before proceeding."
# Restart ADB server
adb kill-server
adb wait-for-device
# Check if the device is connected
if ! adb get-state 1>/dev/null 2>/dev/null; then
show_error "No device detected. Please check your USB connection and ensure USB debugging is enabled."
exit 1
fi
# Launch the application
if [ "$XDG_SESSION_TYPE" = "wayland" ]; then
# Wayland
exec /usr/bin/java -jar \
"/usr/share/java/androidscreencast/androidscreencast.jar" \
"$@" \
2>&1 | grep --color=always "GDK_BACKEND=x11"
else
# X11
exec /usr/bin/java -jar \
"/usr/share/java/androidscreencast/androidscreencast.jar" \
"$@"
fi
|