-
Notifications
You must be signed in to change notification settings - Fork 42
/
session.sh
executable file
·109 lines (85 loc) · 3.37 KB
/
session.sh
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
#!/usr/bin/env bash
# ........................................................................... #
SIZE="900x1000"
# ........................................................................... #
# store current display port
OLD_DISPLAY=$DISPLAY
# ........................................................................... #
# store positional parameters
TYPE=${1:-$XDG_SESSION_TYPE};
ROOT=$2;
UUID=$3;
# ........................................................................... #
# find next X11 display free socket number
d=0
while [ -e /tmp/.X11-unix/X${d} ]; do
d=$((d + 1))
done
NEW_DISPLAY=:$d
# ........................................................................... #
XDG_RUNTIME_DIR=$(mktemp -d)
CACHE=${XDG_CACHE_HOME:-$HOME/.cache}/${UUID}${SUFFIX}
mkdir -p $CACHE
export XDG_CONFIG_HOME=${CACHE}/config
export XDG_DATA_HOME=${CACHE}/local
mkdir -p $XDG_DATA_HOME/gnome-shell/extensions
ln -fsn $ROOT $XDG_DATA_HOME/gnome-shell/extensions/${UUID}
export XDG_CACHE_HOME=${CACHE}/cache
# ........................................................................... #
# export the DISPLAY variable so we can create a new dbus session
DISPLAY=$NEW_DISPLAY
# create new dbus socket and export it's address
eval $(dbus-launch --exit-with-session --sh-syntax)
echo $DBUS_SESSION_BUS_ADDRESS
DISPLAY=$OLD_DISPLAY
# ........................................................................... #
# prepare for gnome-shell launch
args=()
case "$TYPE" in
wayland)
args=(--nested --wayland)
;;
x11)
# launch Xephyr without access control and screen size of 1280x960
Xephyr -ac -screen "${SIZE}" $NEW_DISPLAY &
DISPLAY=$NEW_DISPLAY
args=--x11
;;
esac
# ........................................................................... #
# dconf reset -f / # Reset settings
dconf write /org/gnome/shell/enabled-extensions "['${UUID}']"
# ........................................................................... #
# preconfigure the environment for development
# set static workspaces[org/gnome/mutter]
#dconf write /org/gnome/shell/overrides/dynamic-workspaces false
# ........................................................................... #
# do not need FPS messages
#export CLUTTER_SHOW_FPS=1
export SHELL_DEBUG=all
export MUTTER_DEBUG=1
export MUTTER_DEBUG_NUM_DUMMY_MONITORS=1
export MUTTER_DEBUG_DUMMY_MONITOR_SCALES=1
export MUTTER_DEBUG_TILED_DUMMY_MONITORS=1
# ........................................................................... #
# hack to work around gnome resizing Xephyr screen
# gnome-shell claims monitors.xml has an invalid mode, could not use it
# even thought it was generated inside the Xephyr window
# ----
# enable job control so we can background gnome-shell to launch additional
# commands
set -m
# ........................................................................... #
# launch and background it
gnome-shell ${args[*]} 2>&1 | sed 's/\x1b\[[0-9;]*m//g' &
# wait for 5 seconds for gnome to start up
sleep 5;
# ........................................................................... #
# resize the Xephyr screen post gnome start up
xrandr --size "${SIZE}" &
# ........................................................................... #
# launch gnome-tweak
gnome-tweaks &
# ........................................................................... #
# go back to waiting on the gnome-shell process
wait %1