-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathtest.sh
152 lines (120 loc) · 4.01 KB
/
test.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/bin/bash
clear
# Function to log messages
log_message() {
echo "[`date +"%Y-%m-%d %H:%M:%S"`] $1"
}
EXTENSION_NAME="[email protected]"
XEPHYR_DISPLAY=":2"
RESOLUTION=1867x1050 # this fits my 4th monitor perfectly, change it to your needs
EXTENSION_DIR=$(dirname "$0") # Assumes pack.sh is in the main directory
DIST_DIR="${EXTENSION_DIR}/dist"
# Check if schemas are compiled
if [ ! -f ./schemas/gschemas.compiled ]; then
command -v glib-compile-schemas >/dev/null 2>&1 || { echo >&2 "glib-compile-schemas is required but it's not installed. Aborting."; exit 1; }
log_message "Compiling schemas..."
glib-compile-schemas ./schemas
fi
# Check if tsc is installed
command -v tsc >/dev/null 2>&1 || { log_message "Error: tsc is required but it's not installed. Aborting."; exit 1; }
# Compile TypeScript
log_message "Building typescript files..."
tsc
# Check for errors
if [ $? -ne 0 ]; then
log_message "Failed to compile TypeScript"
exit 1
fi
# Create dist directory
rm -rf "$DIST_DIR"
mkdir -p "$DIST_DIR"
# Copy build directory content to dist directory
cp -r "${EXTENSION_DIR}/build/"* "${DIST_DIR}/"
# Files and directories to include
INCLUDE_FILES="metadata.json stylesheet.css README.md RELEASES.md LICENSE schemas icons po"
# Copy files to dist directory
for file in $INCLUDE_FILES; do
if [ -e "${EXTENSION_DIR}/${file}" ]; then
cp -r "${EXTENSION_DIR}/${file}" "${DIST_DIR}/"
else
log_message "File or directory ${file} not found. Aborting."
rm -rf "$DIST_DIR"
exit 1
fi
done
# enter dist directory
cd "$DIST_DIR"
# Pack the extension
gnome-extensions pack --force \
--podir=./po \
--extra-source=./src \
--extra-source=./icons \
--extra-source=./LICENSE \
--extra-source=./README.md \
--extra-source=./RELEASES.md \
--extra-source=./ROADMAP.md \
--extra-source=./COMPARISON.md \
.
# Check for errors
if [ $? -ne 0 ]; then
log_message "Failed to pack the extension"
exit 1
fi
# Install the extension
gnome-extensions install --force "./$EXTENSION_NAME.shell-extension.zip"
# Check for errors
if [ $? -ne 0 ]; then
log_message "Failed to install the extension"
exit 1
fi
# Return to the main directory
cd ..
# Clean up: remove the dist directory
rm -rf "${DIST_DIR}"
# Remove the packed extension
rm "./$EXTENSION_NAME.shell-extension.zip"
# Check if Xephyr on display :2 is already running
if ! ps ax | grep -v grep | grep "Xephyr.*$XEPHYR_DISPLAY" > /dev/null; then
log_message "Starting Xephyr on display $XEPHYR_DISPLAY"
screen -dmS xephyr_session Xephyr -ac -br -noreset -screen $RESOLUTION $XEPHYR_DISPLAY
sleep 1 # Give Xephyr time to start
else
log_message "Xephyr on display $XEPHYR_DISPLAY is already running"
fi
# Enable the extension
log_message "Enabling the extension..."
extension_status=$(gnome-extensions info "$EXTENSION_NAME" | grep -i "state:")
if [[ $extension_status == *"DISABLED"* ]]; then
gnome-extensions enable "$EXTENSION_NAME"
fi
#export G_MESSAGES_DEBUG=all
export SHELL_DEBUG=all
export MUTTER_DEBUG_DUMMY_MODE_SPECS=$RESOLUTION
#export MUTTER_DEBUG_DUMMY_MONITOR_SCALES=2
export XDG_SESSION_TYPE=wayland
export XDG_CURRENT_DESKTOP=GNOME-Shell
export XDG_SESSION_DESKTOP=GNOME-Shell
export XDG_SESSION_CLASS=user
export DISPLAY=$XEPHYR_DISPLAY
export WAYLAND_DISPLAY=wayland-1
# Start DBus session and capture its PID
export DBUS_SESSION_BUS_ADDRESS=$(dbus-daemon --session --fork --print-address)
export DBUS_SESSION_BUS_PID=$!
export ASTRA_MONITOR_NESTED_SESSION=1
dbus-run-session -- gnome-shell --nested --wayland --mode=minimal &
sleep 1
cleanup() {
log_message "Terminating gnome-shell..."
pkill -f "gnome-shell --nested --wayland --mode=minimal"
sleep 0.5
wait $(pgrep -f "gnome-shell --nested --wayland --mode=minimal")
sleep 0.5
# Kill the DBus session
if [ -n "$DBUS_SESSION_BUS_PID" ]; then
kill $DBUS_SESSION_BUS_PID
fi
}
trap cleanup EXIT INT TERM
wait $(pgrep -f "gnome-shell --nested --wayland --mode=minimal")
sleep 0.5
exit 0