Skip to content

Commit 4383a36

Browse files
author
Sebastian Heiberg
committed
Merge branch '61225/update_scripts_to_choice' into 'master'
updated the scripts to use choices See merge request os2borgerpc/os2borgerpc-scripts!368
2 parents 40b57d2 + 41f2829 commit 4383a36

File tree

5 files changed

+46
-73
lines changed

5 files changed

+46
-73
lines changed

os2borgerpc/browser/browser_set_default.sh

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,18 @@ if get_os2borgerpc_config os2_product | grep --quiet kiosk; then
1212
exit 1
1313
fi
1414

15+
# Expected browsers are either firefox, google-chrome, microsoft-edge
16+
BROWSER=$1
17+
ALTERNATIVE_BROWSER=$2
18+
FILE="/etc/xdg/mimeapps.list"
19+
1520
lower() {
1621
echo "$@" | tr '[:upper:]' '[:lower:]'
1722
}
1823

19-
BROWSER="$(lower "$1")"
20-
21-
FILE="/etc/xdg/mimeapps.list"
22-
23-
# They can type in "chrome" but the desktop file is called google-chrome
24-
# They can type in "edge" but the desktop file is called microsoft-edge
25-
if [ "$BROWSER" = "chrome" ]; then
26-
BROWSER=google-chrome
27-
elif [ "$BROWSER" = "edge" ]; then
28-
BROWSER=microsoft-edge
24+
# If the alternative browser is set, use that instead
25+
if [ -n "$ALTERNATIVE_BROWSER" ]; then
26+
BROWSER=$(lower "$ALTERNATIVE_BROWSER")
2927
fi
3028

3129
# Handle snaps, which have names like firefox_firefox.desktop

os2borgerpc/browser/browser_update_launcher.sh

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,6 @@ TARGET_BROWSER=$1
99

1010
DCONF_POLICY="/etc/dconf/db/os2borgerpc.d/02-launcher-favorites"
1111

12-
# This check is here so they can't end up in a situation where the default browser is set to something invalid, and its
13-
# now impossible to fix it via this script because what's replaced is hardcoded
14-
if [ "$TARGET_BROWSER" != "firefox" ] \
15-
&& [ "$TARGET_BROWSER" != "google-chrome" ] \
16-
&& [ "$TARGET_BROWSER" != "microsoft-edge" ] \
17-
&& [ "$TARGET_BROWSER" != "chromium" ]; then
18-
echo "Requested browser - $TARGET_BROWSER - is not a valid option. See the script description for valid options."
19-
exit 1
20-
fi
2112

2213
# In 22.04 Firefox is a snap, in 20.04 it's an apt package.
2314
# Once everyone has upgraded, support for the latter can be removed

os2borgerpc/browser/chrome_chromium_incognito_enforce.sh

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,15 @@ INPUT_MODE=$2
1414
POLICY="/etc/opt/chrome/policies/managed/os2borgerpc-enforce-incognito.json"
1515

1616
case $INPUT_MODE in
17-
0)
17+
"Incognito mode available")
1818
INCOGNITO_MODE=0
1919
;;
20-
1)
20+
"Incognito mode disabled")
2121
INCOGNITO_MODE=1
2222
;;
23-
2)
23+
"Incognito mode forced")
2424
INCOGNITO_MODE=2
2525
;;
26-
*)
27-
echo "$INPUT_MODE IS NOT a valid option. Exiting ..."
28-
exit 1
29-
;;
3026
esac
3127

3228

os2borgerpc/browser/chrome_chromium_start_maximized_fullscreen_kiosk.sh

Lines changed: 20 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
#
88
# Arguments:
99
# 1:
10-
# 0: Disable all three (default)
11-
# 1: Maximized
12-
# 2: Full screen
13-
# 3: Kiosk
10+
# Disable
11+
# Maximized
12+
# Fullscreen
13+
# Kiosk
1414
#
1515
# Takes effect after logout / restart.
1616
#
@@ -98,44 +98,22 @@ if [ -f $OLD_DESKTOP_FILE ]; then
9898
exit 1
9999
fi
100100

101-
case "$SETTING" in
102-
0) # Disable all three
103-
# shellcheck disable=SC2086 # We want to split the files back into separate arguments
104-
remove_from_desktop_files "--start-maximized" $FILES
105-
# shellcheck disable=SC2086
106-
remove_from_desktop_files "--start-fullscreen" $FILES
107-
# shellcheck disable=SC2086
108-
remove_from_desktop_files "--kiosk" $FILES
109-
;;
110-
1) # MAXIMIZE
111-
# shellcheck disable=SC2086
112-
add_to_desktop_files "--start-maximized" $FILES
113-
# shellcheck disable=SC2086
114-
remove_from_desktop_files "--start-fullscreen" $FILES
115-
# shellcheck disable=SC2086
116-
remove_from_desktop_files "--kiosk" $FILES
117-
;;
118-
2) # FULLSCREEN
119-
# shellcheck disable=SC2086
120-
remove_from_desktop_files "--start-maximized" $FILES
121-
# shellcheck disable=SC2086
122-
add_to_desktop_files "--start-fullscreen" $FILES
123-
# shellcheck disable=SC2086
124-
remove_from_desktop_files "--kiosk" $FILES
125-
;;
126-
3) # KIOSK
127-
# shellcheck disable=SC2086
128-
remove_from_desktop_files "--start-maximized" $FILES
129-
# shellcheck disable=SC2086
130-
remove_from_desktop_files "--start-fullscreen" $FILES
131-
# shellcheck disable=SC2086
132-
add_to_desktop_files "--kiosk" $FILES
133-
;;
134-
*)
135-
printf "%s" "Invalid parameter: It needs to be either 0 (all disabled), 1 (maximized), 2 (full screen) or 3 (kiosk)."
136-
exit 1
137-
;;
138-
esac
101+
# Removes the old settings
102+
# shellcheck disable=SC2086
103+
remove_from_desktop_files "--start-maximized" $FILES
104+
# shellcheck disable=SC2086
105+
remove_from_desktop_files "--start-fullscreen" $FILES
106+
# shellcheck disable=SC2086
107+
remove_from_desktop_files "--kiosk" $FILES
108+
109+
# Setting the new setting, disable is handled above
110+
if [ "$SETTING" = "maximized" ] || [ "$SETTING" = "fullscreen" ]; then
111+
# shellcheck disable=SC2086
112+
add_to_desktop_files "--start-$SETTING" $FILES
113+
elif [ "$SETTING" = "kiosk" ]; then
114+
# shellcheck disable=SC2086
115+
add_to_desktop_files "--$SETTING" $FILES
116+
fi
139117

140118
echo "For the changes to Chromium to take effect waiting a few seconds should be enough."
141119
echo "For the changes to Chrome to take effect, you must logout and login again."

os2borgerpc/printer/printer_options_set.sh

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,21 @@ fi
4343
if [ -n "$ORIENTATION" ]; then
4444
# Mapping the requested orientation to the number CUPS expect, which for some reason is 3-indexed.
4545
# Available orientations: https://www.cups.org/doc/options.html#ORIENTATION
46-
ORIENTATION=$((ORIENTATION + 3))
47-
if ! echo $ORIENTATION | grep --quiet "[3-6]"; then
48-
echo "Invalid orientation. Exiting."
49-
exit 1
50-
fi
46+
47+
case $ORIENTATION in
48+
"Portrait")
49+
ORIENTATION="3"
50+
;;
51+
"Landscape")
52+
ORIENTATION="4"
53+
;;
54+
"Reverse landscape")
55+
ORIENTATION="5"
56+
;;
57+
"Reverse portrait")
58+
ORIENTATION="6"
59+
;;
60+
esac
5161

5262
# NOTE: This currently sets the orientation for ALL connected printers, which may not be ideal in all situations.
5363
# printers.conf says to not edit it while CUPS is running, so stop it first

0 commit comments

Comments
 (0)