Powered by CoCalc
1
#! /bin/sh
2
3
# Modified version of function from swsusp2 script "hibernate".
4
# by William Stein
5
# GPL, etc. 2004.
6
7
SWSUSP_LEAVE_X_BEFORE_SUSPEND="nvidia"
8
VERBOSE="/tmp/verbose"
9
10
SwitchToX() {
11
if [ "$SWSUSP_LEAVE_X_BEFORE_SUSPEND" = "nvidia" ]; then
12
export XAUTHORITY=/tmp/.Xauthority-swsusp-fake-x-server
13
export HOME=/dev/shm
14
xauth 2> $VERBOSE 1> $VERBOSE <<EOF
15
add :3 . 00
16
generate :3.0 .
17
EOF
18
if [ -x /usr/bin/X11/xmessage -a "$DISTRIB" != "Gentoo" ] ;then
19
xinit /usr/bin/X11/xmessage -font huge -display :3.0 -center -timeout 2 " Xserver for restoring video acceleration. " -- :3
20
else
21
xinit /bin/false -- :3 2> $VERBOSE 1> $VERBOSE
22
fi
23
xauth 2> $VERBOSE 1> $VERBOSE <<EOF
24
remove :3
25
remove :3.0
26
EOF
27
fi
28
29
test $SWSUSP_LEAVE_X_BEFORE_SUSPEND != "no" && echo -e "\033[1;32m * \033[0mSwitching back to X..." | $LOGCMD > $VERBOSE
30
31
# if fgconsole is available, the original VT will be stored in this var
32
if [ "$ORIGINAL_VT" != "" ]; then
33
chvt "$ORIGINAL_VT"
34
else
35
echo "Original virtual terminal not memorized (trying 7)"
36
chvt 7
37
fi
38
39
return $?
40
}
41
42
SwitchToX