-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgeforce-now-linux
executable file
·123 lines (108 loc) · 4.59 KB
/
geforce-now-linux
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
#!/bin/bash
#
# A launcher for NVIDIA GeForce NOW on Linux.
#
# Copyright (c) 2020-2021 Toni Corvera <outlyer@gmail.com>
#
# MIT License at the bottom of this file
# References:
# 1. https://www.gamingonlinux.com/2020/08/nvidia-geforce-now-adds-chromebook-support-so-you-can-run-it-on-linux-too
# 2. https://www.gamingonlinux.com/2020/09/nvidia-geforce-now-on-linux-can-run-without-user-agent-spoofing-in-a-browser
# 3. https://peter.sh/experiments/chromium-command-line-switches/
# 4. https://www.whatismybrowser.com/guides/the-latest-user-agent/chrome-os
# 5. https://developers.whatismybrowser.com/useragents/explore/operating_system_name/chrome-os/
# Configuration, tweak as you see fit. 1=On, anything else means Off
# NOTE: There's actually no need to edit the script directly, can invoke setting the
# variable first, e.g.:
# > START_MAXIMIZED=0 START_IN_INCOGNITO=1 geforce-now-linux
# > CHROMIUM_VARIANTS='chromium microsoft-edge' geforce-now-linux
START_MAXIMIZED=${START_MAXIMIZED:-1} # Starts maximized but not completely full screen
START_IN_INCOGNITO=${START_IN_INCOGNITO:-0} # This doesn't seem to have any effect on my system
START_FULLSCREEN=${START_FULLSCREEN:-1} # Starts full screen, toggle with F11
OVERRIDE_USER_AGENT=${OVERRIDE_USER_AGENT:-0} # Pretend to be running under ChromeOS
# The first available known chromium browser will be used
# Reorder if you have a different preference, or set the CHROMIUM_VARIANTS environment variable
# as noted above
# Opera doesn't appear to take the --app option so I'm not including it
# NOTE: In my tests Chromium gives an error when trying to start a game
declare -ra DEFAULT_CHROMIUM_VARIANTS=( \
google-chrome \
microsoft-edge \
vivaldi \
microsoft-edge-dev \
chromium \
)
CHROMIUM_VARIANTS=${CHROMIUM_VARIANTS:-${DEFAULT_CHROMIUM_VARIANTS[@]}}
# TODO: Match the user agent to the installed version. Probably overkill
# The corresponding chrome version is easy (--version) but the CrOS
# version probably not so much without a table
USER_AGENT="Mozilla/5.0 (X11; CrOS x86_64 13020.87.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.119 Safari/537.36"
# --- You probably shouldn't change anything below here ---
# Pretty-print 1 (on) and 0 (off) values
on_off() {
local val='off'
[[ $1 -eq 0 ]] || val='on'
echo $val
}
ua=$USER_AGENT
if [[ $OVERRIDE_USER_AGENT -ne 1 ]]; then
ua="(Browser's user agent)"
fi
cat >&2 <<EOF
Configuration variables:
START_MAXIMIZED: $(on_off $START_MAXIMIZED)
START_IN_INCOGNITO: $(on_off $START_IN_INCOGNITO)
START_FULLSCREEN: $(on_off $START_FULLSCREEN)
OVERRIDE_USER_AGENT: $(on_off $OVERRIDE_USER_AGENT)
USER_AGENT: $ua
CHROMIUM_VARIANTS: ${CHROMIUM_VARIANTS[@]}
EOF
unset ua
# Pick the first variant available
for variant in ${CHROMIUM_VARIANTS[@]}; do
if type -p $variant ; then
CHROMIUM=$variant
break
fi >/dev/null
done
if [[ -z "$CHROMIUM" ]]; then
echo "No known variant of Chromium detected, aborting..." >&2
exit 1
fi
echo Selected chromium variant: $CHROMIUM >&2
OPTIONS=
if [[ $START_IN_INCOGNITO = 1 ]]; then
OPTIONS+=( "--start-in-incognito" )
fi
if [[ $START_MAXIMIZED = 1 ]]; then
OPTIONS+=( "--start-maximized" )
fi
if [[ $START_FULLSCREEN = 1 ]]; then
OPTIONS+=( "--start-fullscreen" )
fi
if [[ $OVERRIDE_USER_AGENT -eq 1 ]]; then
OPTIONS+=( "--user-agent=$USER_AGENT" )
fi
echo Running with options: "${OPTIONS[@]}" >&2
# NOTE: Can test effective User Agent e.g. directly via Google:
# https://google.com/search?q=what+is+my+user+agent
exec $CHROMIUM "${OPTIONS[@]}" \
--app=https://play.geforcenow.com
# MIT LICENSE TEXT:
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.