Skip to content

Commit c13fcbb

Browse files
author
Andreas Poulsen
committed
Merge branch 'feature/57282_change_resolution_script' into 'master'
Add script to change screen resolution See merge request os2borgerpc/os2borgerpc-scripts!259
2 parents 502512c + d93e729 commit c13fcbb

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

common/system/change_resolution.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env sh
2+
3+
set -x
4+
5+
ACTIVATE=$1
6+
WIDTH=$2
7+
HEIGHT=$3
8+
9+
RESOLUTION_FILE="/etc/X11/xorg.conf.d/resolution.conf"
10+
11+
run_xrandr() {
12+
if get_os2borgerpc_config os2_product | grep --quiet kiosk; then
13+
USR="chrome"
14+
else
15+
USR="user"
16+
fi
17+
18+
export DISPLAY=:0
19+
export XAUTHORITY=/home/$USR/.Xauthority
20+
echo "The valid resolutions are shown on the left in the list below:"
21+
xrandr
22+
}
23+
24+
if [ "$2" != "" ] && [ "$ACTIVATE" = "True" ]; then
25+
# Make sure the folder exists
26+
mkdir --parents "$(dirname $RESOLUTION_FILE)"
27+
28+
# Write the .conf-file
29+
cat <<EOF > $RESOLUTION_FILE
30+
Section "Screen"
31+
Identifier "Screen0"
32+
Subsection "Display"
33+
Modes "${WIDTH}x${HEIGHT}"
34+
EndSubSection
35+
EndSection
36+
EOF
37+
elif [ "$ACTIVATE" = "False" ]; then
38+
rm --force $RESOLUTION_FILE
39+
fi
40+
run_xrandr

0 commit comments

Comments
 (0)