forked from wyllianbs/xfreerdp-gui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxfreerdp-gui.sh
More file actions
147 lines (131 loc) · 6.9 KB
/
xfreerdp-gui.sh
File metadata and controls
147 lines (131 loc) · 6.9 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/bin/bash
#####################################################################################
#### FEDERAL UNIVERSITY OF SANTA CATARINA -- UFSC
#### Prof. Wyllian Bezerra da Silva
#####################################################################################
#### Dependencies: freerdp-x11 gawk x11-utils yad zenity
string=""
if ! hash xfreerdp 2>/dev/null; then
string="\nfreerdp-x11"
fi
if ! hash awk 2>/dev/null; then
string="\ngawk"
fi
if ! hash xdpyinfo 2>/dev/null; then
string="${string}\nx11-utils"
fi
if ! hash yad 2>/dev/null; then
string="${string}\nyad"
fi
if [ -n "$string" ]; then
if hash amixer 2>/dev/null; then
amixer set Master 80% > /dev/null 2>&1;
else
pactl set-sink-volume 0 80%
fi
if hash speaker-test 2>/dev/null; then
((speaker-test -t sine -f 880 > /dev/null 2>&1)& pid=$!; sleep 0.2s; kill -9 $pid) > /dev/null 2>&1
else
if hash play 2>/dev/null; then
play -n synth 0.1 sin 880 > /dev/null 2>&1
else
cat /dev/urandom | tr -dc '0-9' | fold -w 32 | sed 60q | aplay -r 9000 > /dev/null 2>&1
fi
fi
(zenity --info --title="Requirements" --width=300 --text="You need to install this(ese) package(s):
<b>$string</b>
") > /dev/null 2>&1
exit
fi
#####################################################################################
#### Get informations
dim=$(xdpyinfo | grep dimensions | sed -r 's/^[^0-9]*([0-9]+x[0-9]+).*$/\1/')
wxh1=$(echo $dim | sed -r 's/x.*//')"x"$(echo $dim | sed -r 's/.*x//')
wxh2=$(($(echo $dim | sed -r 's/x.*//')-70))"x"$(($(echo $dim | sed -r 's/.*x//')-70))
while true
do
LOGIN=
PASSWORD=
DOMAIN=
SERVER=
PORT=
RESOLUTION=
GEOMETRY=
CERTIGNORE=
BPP=
NAMEDIR=
DIR=
OPTIONS=
varFull=
varLog=
[ -n "$USER" ] && until xdotool search "xfreerdp-gui" windowactivate key Right Tab 2>/dev/null ; do sleep 0.03; done &
FORMULARY=$(yad --center --width=380 \
--window-icon="gtk-execute" --image="debian-logo" --item-separator="," \
--title "xfreerdp-gui" \
--form \
--field="Server" $SERVER "academico.terminal.ufsc.br" \
--field="Port" $PORT "3389" \
--field="Domain" $DOMAIN "" \
--field="Username" $LOGIN "USER@ufsc.br" \
--field="Password ":H $PASSWORD "" \
--field="Resolution":CBE $RESOLUTION "$wxh1,$wxh2,640x480,720x480,800x600,1024x768,1280x1024,1600x1200,1920x1080," \
--field="BPP":CBE $BPP "24,16,32," \
--field="Name of Shared Directory" $NAMEDIR "Shared" \
--field="Shared Directory" $DIR $HOME/Downloads \
--field="Other Options" $OPTIONS "" \
--field="Full Screen":CHK $varFull \
--field="Show Log":CHK $varLog \
--button="Cancel":1 --button="Connect":0)
[ $? != 0 ] && exit
SERVER=$(echo $FORMULARY | awk -F '|' '{ print $1 }')
PORT=$(echo $FORMULARY | awk -F '|' '{ print $2 }')
DOMAIN=$(echo $FORMULARY | awk -F '|' '{ print $3 }')
LOGIN=$(echo $FORMULARY | awk -F '|' '{ print $4 }')
PASSWORD=$(echo $FORMULARY | awk -F '|' '{ print $5 }')
RESOLUTION=$(echo $FORMULARY | awk -F '|' '{ print $6 }')
BPP=$(echo $FORMULARY | awk -F '|' '{ print $7 }')
NAMEDIR=$(echo $FORMULARY | awk -F '|' '{ print $8 }')
DIR=$(echo $FORMULARY | awk -F '|' '{ print $9 }')
OPTIONS=$(echo $FORMULARY | awk -F '|' '{ print $10 }')
varFull=$(echo $FORMULARY | awk -F '|' '{ print $11 }')
if [ "$varFull" = "TRUE" ]; then
GEOMETRY="/f"
else
GEOMETRY=""
fi
varLog=$(echo $FORMULARY | awk -F '|' '{ print $12 }')
RES=$(xfreerdp \
/v:"$SERVER":$PORT \
/cert-tofu /cert-ignore \
/t:"$SERVER" \
/sec-tls $GEOMETRY \
/d:"$DOMAIN" \
/u:"$LOGIN" \
/p:"$PASSWORD" \
/bpp:$BPP \
/size:$RESOLUTION \
/sound \
/tsmf \
/from-stdin \
/decorations /window-drag \
/drive:$NAMEDIR,$DIR \
/compression /drive:$DIR \
$OPTIONS \
+compression +clipboard \
-menu-anims +fonts 2>&1)
echo $RES | grep -q "Authentication failure" && \
yad --center --image="error" --window-icon="error" --title "Authentication failure" \
--text="<b>Could not authenticate to server\!</b>\n\n<i>Please check your password.</i>" \
--text-align=center --width=320 --button=gtk-ok --buttons-layout=spread && continue
echo $RES | grep -q "connection failure" && \
yad --center --image="error" --window-icon="error" --title "Connection failure" \
--text="<b>Could not connect to the server\!</b>\n\n<i>Please check the network connection.</i>" \
--text-align=center --width=320 --button=gtk-ok --buttons-layout=spread && continue
if [ "$varLog" = "TRUE" ]; then
yad --text "$RES" --title "Log of Events" --width=600 --wrap --no-buttons
fi
break
done
#####################################################################################
#### Reference:
#### Adapted from: https://github.com/FreeRDP/FreeRDP/issues/1358#issuecomment-175075061