-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStreamerLauncherScript.sh
More file actions
executable file
·117 lines (89 loc) · 2.89 KB
/
StreamerLauncherScript.sh
File metadata and controls
executable file
·117 lines (89 loc) · 2.89 KB
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
#!/bin/bash
FILE="/tmp/screen.mp4"
PORT=8080
APP_NAME="Streamer"
DESKTOP_FILE="$HOME/.local/share/applications/streamer.desktop"
SCRIPT_PATH="$(realpath "$0")"
echo "🖥️ Lancement du partage d'écran avec OBS + VLC"
echo "📁 Fichier d'enregistrement attendu : $FILE"
# ✅ Vérification si VLC est installé
if ! command -v cvlc >/dev/null; then
echo "❌ VLC (cvlc) n'est pas installé. Installe-le avec :"
echo "sudo dnf install vlc"
exit 1
fi
# ✅ Vérification si OBS est installé
if ! command -v obs >/dev/null; then
echo "❌ OBS n'est pas installé. Installe-le avec :"
echo "sudo dnf install obs-studio"
exit 1
fi
# ✅ Trouve l'adresse IP locale
IP=$(ip -4 addr show | grep -oP '(?<=inet\s)192\.168\.\d+\.\d+' | head -n 1)
if [ -z "$IP" ]; then
echo "❌ Impossible de trouver une IP locale (192.168.x.x)"
echo "Assure-toi que tu es connecté à un réseau local."
exit 1
fi
# ✅ Lance OBS s'il n'est pas déjà en cours d'exécution
if ! pgrep -x "obs" > /dev/null; then
echo "🚀 Lancement d'OBS..."
nohup obs > /dev/null 2>&1 &
# Vérification si OBS a bien démarré
if ! pgrep -x "obs" > /dev/null; then
echo "❌ Échec du lancement d'OBS."
exit 1
else
echo "✅ OBS lancé avec succès."
fi
else
echo "✅ OBS est déjà en cours d'exécution."
fi
# ✅ Attend que le fichier soit créé
echo "⏳ En attente de l'enregistrement dans OBS..."
while [ ! -f "$FILE" ]; do
sleep 5
done
echo "✅ Fichier détecté : $FILE !"
# ✅ Vérifie si le port est déjà utilisé et trouve un port libre
while netstat -tuln | grep ":$PORT" > /dev/null; do
echo "❌ Port $PORT occupé. Recherche d’un port libre..."
PORT=$((PORT + 2))
done
echo "✅ Port libre trouvé : $PORT"
echo ""
# ✅ Lance VLC pour diffuser en HTTP
cvlc "$FILE" --sout "#standard{access=http,mux=ts,dst=:$PORT}" --loop &
sleep 7
# Vérification si VLC a bien démarré
if ! pgrep -x "cvlc" > /dev/null; then
echo "❌ Échec du lancement de VLC."
exit 1
else
echo "✅ VLC lancé avec succès pour diffuser sur http://$IP:$PORT"
fi
echo ""
echo "📺 Ouvre ce lien sur ta TV ou ton navigateur :"
echo "➡️ http://$IP:$PORT"
# ✅ Propose d’ajouter au menu GNOME
echo ""
read -p "📋 Souhaitez-vous ajouter l’application au menu GNOME ? (o/N) : " ADD_TO_GNOME
ADD_TO_GNOME=${ADD_TO_GNOME,,} # mettre en minuscules
if [[ "$ADD_TO_GNOME" == "o" || "$ADD_TO_GNOME" == "oui" ]]; then
echo "📎 Création du raccourci GNOME..."
mkdir -p "$(dirname "$DESKTOP_FILE")"
cat > "$DESKTOP_FILE" <<EOF
[Desktop Entry]
Name=$APP_NAME
Comment=Partage d'écran OBS + VLC sur le réseau local
Exec=$SCRIPT_PATH
Icon=video-display
Terminal=true
Type=Application
Categories=Utility;
EOF
chmod +x "$DESKTOP_FILE"
echo "✅ Raccourci ajouté dans GNOME : $DESKTOP_FILE"
else
echo "⏩ Ajout au menu GNOME ignoré."
fi