Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
m1k1o
GitHub Repository: m1k1o/neko
Path: blob/master/apps/remmina/run-remmina.sh
1300 views
1
#!/bin/bash
2
3
err() {
4
echo "ERROR: $*" >&2
5
exit 1
6
}
7
8
profile_dir="/home/neko/.local/share/remmina"
9
if [[ -n "$REMMINA_PROFILE" ]]; then
10
profile=${REMMINA_PROFILE%.remmina}.remmina
11
file=${profile##/*/}
12
[[ "$file" = "$profile" ]] && profile="$profile_dir"/"$file"
13
[[ -f "$profile" ]] || err "Connection profile $profile not found"
14
echo "Running remmina with connection profile $profile"
15
exec remmina -c "$profile"
16
fi
17
18
if [[ ! -z "$REMMINA_URL" ]]; then
19
readarray -t arr < <( echo -n "$REMMINA_URL" | perl -pe 's|^(\w+)\:\/\/(?:([^:]+)(?::([^@]+))?@)?(.*)$|\1\n\2\n\3\n\4|' )
20
proto="${arr[0]}"
21
user="${arr[1]}"
22
pw="${arr[2]}"
23
host="${arr[3]}"
24
echo "Parsed url in 'REMMINA_URL': proto:$proto username:$user host:$host"
25
26
[[ "$proto" != "vnc" && "$proto" != "rdp" && "$proto" != "spice" ]] && err "Unsupported protocol $proto in connection url 'REMMINA_URL'"
27
28
profile="$profile_dir"/"$proto".remmina
29
remmina --set-option username="$user" --update-profile "$profile"
30
remmina --set-option password="$pw" --update-profile "$profile"
31
remmina --set-option server="$host" --update-profile "$profile"
32
33
# remmina --set-option window_maximize=1 --update-profile "$profile"
34
# remmina --set-option scale=1 --update-profile "$profile"
35
36
echo "Running remmina with URL $REMMINA_URL"
37
exec remmina -c "$profile"
38
fi
39
40
41
echo "Running remmina without connection profile"
42
exec remmina
43
44