Commit | Line | Data |
---|---|---|
af3a72cf LMM |
1 | #!/usr/bin/env bash |
2 | # This file is part of Libre-Streamer. | |
3 | # | |
4 | # Libre-Streamer is free software: you can redistribute it and/or modify | |
5 | # it under the terms of the GNU General Public License as published by | |
6 | # the Free Software Foundation, either version 3 of the License, or | |
7 | # (at your option) any later version. | |
8 | # | |
9 | # Libre-Streamer is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. | |
13 | # | |
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with Libre-Streamer. If not, see <http://www.gnu.org/licenses/>. | |
16 | # | |
17 | # Copyright (c) 2014 Lisa Marie Maginnis | |
18 | # Copyright (c) 2014 Nico Cesar | |
19 | ||
20 | ||
21 | # Some fancy texts | |
22 | high=`tput smso` highoff=`tput rmso` | |
23 | ul=`tput smul` rul=`tput rmul` | |
24 | ||
25 | . params.sh | |
26 | ||
27 | function kill_screencasts { | |
28 | killall -9 sshd | |
29 | } | |
30 | ||
31 | function getinfo { | |
32 | interface=$(/sbin/ifconfig -a | egrep 'eth[0-9] ' | cut -f1 -d\ ) | |
33 | ipaddress=$(/sbin/ifconfig $interface | sed -n 's/ *inet addr:\([0-9.]*\) .*/\1/p') | |
34 | clients=$(ps -ef | grep sshd:\ libreplanet@pts | grep -v grep | wc -l) | |
35 | screentarget=$(xauth list | tail -n 1 | sed 's/.*unix:\([0-9]*\) .*/localhost:\1/') | |
36 | ||
37 | ||
38 | ||
39 | if [ $clients -gt 0 ] && [ "$screentarget" != 'localhost:0.0' ] ; then | |
40 | client_status=CONNECTED | |
41 | endx='endx='$(DISPLAY=$screentarget xrandr | awk '/Screen 0/{sub(",", "", $10);x=$8; y=$10;} / connected/{sub(/x.*/, "", $3);secondhead=$3} END{print x-secondhead;}') | |
42 | ||
43 | else | |
44 | client_status=NOT\ CONNECTED | |
45 | screentarget=:0.0 | |
46 | endx='' | |
47 | fi | |
48 | export screentarget endx | |
49 | } | |
50 | ||
51 | function view_camera { | |
52 | echo osd_show_text 'Press\ [ENTER]\ to\ quit' 100000 | \ | |
53 | mplayer -lavdopts threads=2 -slave -fs -zoom rtsp://$IP &>/dev/null & | |
54 | } | |
55 | ||
56 | function start_stream { | |
57 | ./stream_2014.sh | |
58 | } | |
59 | ||
60 | while [[ "$reply" != "q" ]] && [[ "$reply" != "Q" ]]; do | |
61 | getinfo | |
62 | clear | |
63 | echo -n <<EOF " | |
64 | _ _ _ ____ _ | |
65 | | | (_) |__ _ __ ___ / ___|| |_ _ __ ___ __ _ _ __ ___ ___ _ __ | |
66 | | | | | '_ \| '__/ _ \____\___ \| __| '__/ _ \/ _\` | '_ \` _ \ / _ \ '__| | |
67 | | |___| | |_) | | | __/_____|__) | |_| | | __/ (_| | | | | | | __/ | | |
68 | |_____|_|_.__/|_| \___| |____/ \__|_| \___|\__,_|_| |_| |_|\___|_| | |
69 | ||
70 | Streaming Point Info: | |
71 | General: | |
72 | IP Address: "$high$ipaddress$highoff" | |
73 | ||
74 | ScreenCast: | |
75 | Remote Client: "$high$client_status$highoff" Target: "$high$screentarget$highoff" | |
76 | ||
77 | Main Menu: | |
78 | (S)tart Stream | |
79 | (R)efresh Streaming Point Info | |
80 | (V)iew Camera Output | |
81 | (K)ill screencast clients | |
82 | ||
83 | (Q)uit | |
84 | ||
85 | Selection: " | |
86 | EOF | |
87 | ||
88 | ||
89 | read reply | |
90 | ||
91 | case $reply in | |
92 | s|S) | |
93 | start_stream | |
94 | ;; | |
95 | k|K) | |
96 | kill_screencasts | |
97 | ;; | |
98 | r|R) | |
99 | ;; | |
100 | v|V) | |
101 | view_camera | |
102 | esac | |
103 | ||
104 | done |