33# Aylur's GTK Shell v 1.9.0 #
44# for desktop overview
55
6+ set -euo pipefail
67
78ags=(
89 typescript
1617 NetworkManager
1718 libdbusmenu-gtk3-4
1819 libpulse-devel
20+ gobject-introspection
21+ gobject-introspection-devel
22+ )
23+
24+ # Packages to force re-install (if needed)
25+ f_ags=(
26+ npm
1927)
2028
2129# specific tags to download
3846LOG=" Install-Logs/install-$( date +%d-%H%M%S) _ags.log"
3947MLOG=" install-$( date +%d-%H%M%S) _ags2.log"
4048
41- # Check if AGS is installed
42- if command -v ags & > /dev/null; then
43- AGS_VERSION=$( ags -v | awk ' {print $NF}' )
49+ # Check if AGS is installed (only if main ESM exists to avoid wrapper error)
50+ AGS_ESM=" "
51+ if [ -f " /usr/local/share/com.github.Aylur.ags/com.github.Aylur.ags" ]; then
52+ AGS_ESM=" /usr/local/share/com.github.Aylur.ags/com.github.Aylur.ags"
53+ elif [ -f " /usr/share/com.github.Aylur.ags/com.github.Aylur.ags" ]; then
54+ AGS_ESM=" /usr/share/com.github.Aylur.ags/com.github.Aylur.ags"
55+ fi
56+
57+ if command -v ags & > /dev/null && [ -n " $AGS_ESM " ]; then
58+ AGS_VERSION=$( ags -v | awk ' {print $NF}' )
4459 if [[ " $AGS_VERSION " == " 1.9.0" ]]; then
45- printf " ${INFO} ${MAGENTA} Aylur's GTK Shell v1.9.0${RESET} is already installed. Skipping installation."
46- printf " \n%.0s" {1..2}
47- exit 0
60+ printf " ${INFO} ${MAGENTA} Aylur's GTK Shell v1.9.0${RESET} is already installed.\n"
61+ read -r -p " Reinstall v1.9.0 anyway? [y/N]: " REPLY
62+ case " $REPLY " in
63+ [yY]|[yY][eE][sS])
64+ printf " ${NOTE} Reinstalling Aylur's GTK Shell v1.9.0...\n"
65+ ;;
66+ * )
67+ printf " Skipping reinstallation.\n"
68+ printf " \n%.0s" {1..2}
69+ exit 0
70+ ;;
71+ esac
4872 fi
4973fi
5074
5175# Installation of main components
52- printf " \n%s - Installing ${SKY_BLUE} Aylur's GTK shell $ags_tag ${RESET} Dependencies \n" " ${NOTE } "
76+ printf " \n%s - Installing ${SKY_BLUE} Aylur's GTK shell $ags_tag ${RESET} Dependencies \n" " ${INFO } "
5377
5478# Installing ags Dependencies
5579for PKG1 in " ${ags[@]} " ; do
5680 install_package " $PKG1 " " $LOG "
5781done
5882
83+ # Force reinstall select packages if requested
84+ for force_ags in " ${f_ags[@]} " ; do
85+ install_package_force " $force_ags " 2>&1 | tee -a " $LOG "
86+ done
87+
5988printf " \n%.0s" {1..1}
6089
6190# ags v1
6291printf " ${NOTE} Install and Compiling ${SKY_BLUE} Aylur's GTK shell $ags_tag ${RESET} ..\n"
6392
64- # Check if directory exists and remove it
65- if [ -d " ags" ]; then
66- printf " ${NOTE} Removing existing ags directory...\n"
67- rm -rf " ags"
68- fi
93+ # Remove previous sources (both legacy "ags" and tagged "ags_v1.9.0")
94+ for SRC_DIR in " ags" " ags_v1.9.0" ; do
95+ if [ -d " $SRC_DIR " ]; then
96+ printf " ${NOTE} Removing existing %s directory...\n" " $SRC_DIR "
97+ rm -rf " $SRC_DIR "
98+ fi
99+ done
69100
70101printf " \n%.0s" {1..1}
71102printf " ${INFO} Kindly Standby...cloning and compiling ${SKY_BLUE} Aylur's GTK shell $ags_tag ${RESET} ...\n"
@@ -76,7 +107,94 @@ if git clone --depth=1 https://github.com/JaKooLit/ags_v1.9.0.git; then
76107 npm install
77108 meson setup build
78109 if sudo meson install -C build 2>&1 | tee -a " $MLOG " ; then
110+ : # with pipefail set, this reflects meson install status
79111 printf " \n${OK} ${YELLOW} Aylur's GTK shell $ags_tag ${RESET} installed successfully.\n" 2>&1 | tee -a " $MLOG "
112+
113+ # Patch installed AGS launchers to ensure GI typelibs in /usr/local/lib are discoverable in GJS ESM
114+ printf " ${NOTE} Applying AGS launcher patch for GI typelibs search path...\n"
115+
116+ patch_ags_launcher () {
117+ local target=" $1 "
118+ if ! sudo test -f " $target " ; then
119+ return 1
120+ fi
121+
122+ # 1) Remove deprecated GIR Repository path tweaks and GIRepository import (harmless if absent)
123+ sudo sed -i \
124+ -e ' /Repository\.prepend_search_path/d' \
125+ -e ' /Repository\.prepend_library_path/d' \
126+ -e ' /gi:\/\/GIRepository/d' \
127+ " $target "
128+
129+ # 2) Ensure GLib import exists (insert after first import line, or at top if none)
130+ if ! sudo grep -q ' ^import GLib from "gi://GLib";' " $target " ; then
131+ TMPF=$( sudo mktemp)
132+ sudo awk ' BEGIN{added=0} {
133+ if (!added && $0 ~ /^import /) { print; print "import GLib from \"gi://GLib\";"; added=1; next }
134+ print
135+ } END { if (!added) print "import GLib from \"gi://GLib\";" }' " $target " | sudo tee " $TMPF " > /dev/null
136+ sudo mv " $TMPF " " $target "
137+ fi
138+
139+ # 3) Inject GI_TYPELIB_PATH export right after the GLib import (once)
140+ if ! sudo grep -q ' GLib.setenv("GI_TYPELIB_PATH"' " $target " ; then
141+ TMPF=$( sudo mktemp)
142+ sudo awk ' {print} $0 ~ /^import GLib from "gi:\/\/GLib";$/ {print "const __old = GLib.getenv(\"GI_TYPELIB_PATH\");"; print "GLib.setenv(\"GI_TYPELIB_PATH\", \"/usr/local/lib64:/usr/local/lib:/usr/local/lib64/girepository-1.0:/usr/local/lib/girepository-1.0:/usr/lib64/girepository-1.0:/usr/lib/girepository-1.0:/usr/lib64/ags:/usr/local/lib/ags\" + (__old ? \":\" + __old : \"\"), true);"; print "const __oldld = GLib.getenv(\"LD_LIBRARY_PATH\");"; print "GLib.setenv(\"LD_LIBRARY_PATH\", \"/usr/local/lib64:/usr/local/lib\" + (__oldld ? \":\" + __oldld : \"\"), true);"}' " $target " | sudo tee " $TMPF " > /dev/null
143+ sudo mv " $TMPF " " $target "
144+ fi
145+
146+ # 4) Ensure LD_LIBRARY_PATH export exists even if GI_TYPELIB_PATH was already present
147+ if ! sudo grep -q ' GLib.setenv("LD_LIBRARY_PATH"' " $target " ; then
148+ TMPF=$( sudo mktemp)
149+ sudo awk ' {print} $0 ~ /^import GLib from "gi:\/\/GLib";$/ {print "const __oldld = GLib.getenv(\"LD_LIBRARY_PATH\");"; print "GLib.setenv(\"LD_LIBRARY_PATH\", \"/usr/local/lib64:/usr/local/lib\" + (__oldld ? \":\" + __oldld : \"\"), true);"}' " $target " | sudo tee " $TMPF " > /dev/null
150+ sudo mv " $TMPF " " $target "
151+ fi
152+
153+ # Restore executable bit for bin wrappers (mv from mktemp resets mode to 0600)
154+ case " $target " in
155+ * /bin/ags)
156+ sudo chmod 0755 " $target " || true
157+ ;;
158+ esac
159+
160+ printf " ${OK} Patched: %s\n" " $target "
161+ return 0
162+ }
163+
164+ # Try common locations
165+ for CAND in \
166+ " /usr/local/share/com.github.Aylur.ags/com.github.Aylur.ags" \
167+ " /usr/share/com.github.Aylur.ags/com.github.Aylur.ags" \
168+ " /usr/local/bin/ags" \
169+ " /usr/bin/ags" ; do
170+ patch_ags_launcher " $CAND " || true
171+ done
172+
173+ # Create an env-setting wrapper for AGS to ensure GI typelibs/libs are discoverable
174+ printf " ${NOTE} Creating env wrapper /usr/local/bin/ags...\n"
175+ sudo tee /usr/local/bin/ags > /dev/null << 'WRAP '
176+ #!/usr/bin/env bash
177+ set -euo pipefail
178+ cd "$HOME" 2>/dev/null || true
179+ # Locate AGS ESM entry
180+ MAIN_JS="/usr/local/share/com.github.Aylur.ags/com.github.Aylur.ags"
181+ if [ ! -f "$MAIN_JS" ]; then
182+ MAIN_JS="/usr/share/com.github.Aylur.ags/com.github.Aylur.ags"
183+ fi
184+ if [ ! -f "$MAIN_JS" ]; then
185+ echo "Unable to find AGS entry script (com.github.Aylur.ags) in /usr/local/share or /usr/share" >&2
186+ exit 1
187+ fi
188+ # Ensure GI typelibs and native libs are discoverable before gjs ESM loads
189+ export GI_TYPELIB_PATH="/usr/local/lib64:/usr/local/lib:/usr/local/lib64/girepository-1.0:/usr/local/lib/girepository-1.0:/usr/lib64/girepository-1.0:/usr/lib/girepository-1.0:/usr/lib64/ags:/usr/local/lib/ags:${GI_TYPELIB_PATH-}"
190+ export LD_LIBRARY_PATH="/usr/local/lib64:/usr/local/lib:${LD_LIBRARY_PATH-}"
191+ exec /usr/bin/gjs -m "$MAIN_JS" "$@"
192+ WRAP
193+ sudo chmod 0755 /usr/local/bin/ags
194+ # Ensure ESM entry is readable by gjs
195+ sudo chmod 0644 /usr/local/share/com.github.Aylur.ags/com.github.Aylur.ags 2> /dev/null || true
196+ sudo chmod 0644 /usr/share/com.github.Aylur.ags/com.github.Aylur.ags 2> /dev/null || true
197+ printf " ${OK} AGS wrapper installed at /usr/local/bin/ags\n"
80198 else
81199 echo -e " \n${ERROR} ${YELLOW} Aylur's GTK shell $ags_tag ${RESET} Installation failed\n " 2>&1 | tee -a " $MLOG "
82200 fi
89207 exit 1
90208fi
91209
92- printf " \n%.0s" {1..2}
210+ printf " \n%.0s" {1..2}
0 commit comments