From 83c7b8f5192e5be3a79c0a2a598b5f5805531e22 Mon Sep 17 00:00:00 2001 From: Samuel <36420837+Samueru-sama@users.noreply.github.com> Date: Sun, 24 Aug 2025 07:49:19 -0400 Subject: [PATCH 1/5] Update and rename hack.patch to locale-fix.patch --- hack.patch | 51 ------------------------------------------------ locale-fix.patch | 22 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 51 deletions(-) delete mode 100644 hack.patch create mode 100644 locale-fix.patch diff --git a/hack.patch b/hack.patch deleted file mode 100644 index 767d095..0000000 --- a/hack.patch +++ /dev/null @@ -1,51 +0,0 @@ -diff --git a/source/rofi.c b/source/rofi.c -index 37ad16f0..4f72a408 100644 ---- a/source/rofi.c -+++ b/source/rofi.c -@@ -76,6 +76,19 @@ - - #endif - -+/** Terrible hack */ -+static void terrible_hack_for_appimage(void) -+{ -+ if ( g_getenv("APPDIR") ) { -+ g_unsetenv("APPDIR"); -+ g_unsetenv("GIO_MODULE_DIR"); -+ g_unsetenv("GSETTINGS_SCHEMA_DIR"); -+ g_unsetenv("GDK_PIXBUF_MODULEDIR"); -+ g_unsetenv("GDK_PIXBUF_MODULE_FILE"); -+ g_unsetenv("GTK_PATH"); -+ } -+} -+ - /** Location of pidfile for this instance. */ - char *pidfile = NULL; - /** Location of Cache directory. */ -@@ -1083,10 +1096,14 @@ int main(int argc, char *argv[]) { - - display_init(proxy); - -+ /** Fallback to C locale instead of outright failing */ - if (setlocale(LC_ALL, "") == NULL) { -- g_warning("Failed to set locale."); -- cleanup(); -- return EXIT_FAILURE; -+ g_warning("Failed to set locale, falling back to C locale."); -+ if (setlocale(LC_ALL, "C") == NULL) { -+ g_warning("Failed to set C locale – aborting."); -+ cleanup(); -+ return EXIT_FAILURE; -+ } - } - - TICK_N("Setup Locale"); -@@ -1299,6 +1316,8 @@ int main(int argc, char *argv[]) { - rofi_icon_fetcher_init(); - TICK_N("Icon fetcher initialize"); - -+ terrible_hack_for_appimage(); -+ - gboolean kill_running = FALSE; - if (find_arg("-replace") >= 0) { - kill_running = TRUE; diff --git a/locale-fix.patch b/locale-fix.patch new file mode 100644 index 0000000..9dec3af --- /dev/null +++ b/locale-fix.patch @@ -0,0 +1,22 @@ +diff --git a/source/rofi.c b/source/rofi.c +index 4355374..2937eda 100644 +--- a/source/rofi.c ++++ b/source/rofi.c +@@ -1083,10 +1083,14 @@ int main(int argc, char *argv[]) { + + display_init(proxy); + ++ /** Fallback to C locale instead of outright failing */ + if (setlocale(LC_ALL, "") == NULL) { +- g_warning("Failed to set locale."); +- cleanup(); +- return EXIT_FAILURE; ++ g_warning("Failed to set locale, falling back to C locale."); ++ if (setlocale(LC_ALL, "C") == NULL) { ++ g_warning("Failed to set C locale – aborting."); ++ cleanup(); ++ return EXIT_FAILURE; ++ } + } + + TICK_N("Setup Locale"); From 2ce97c167a1ecca73a31224e0e317d024b9658f8 Mon Sep 17 00:00:00 2001 From: Samuel <36420837+Samueru-sama@users.noreply.github.com> Date: Sun, 24 Aug 2025 08:01:43 -0400 Subject: [PATCH 2/5] build rofi here instead --- get-dependencies.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/get-dependencies.sh b/get-dependencies.sh index 37fb964..df3e2dc 100644 --- a/get-dependencies.sh +++ b/get-dependencies.sh @@ -2,6 +2,7 @@ set -ex EXTRA_PACKAGES="https://raw.githubusercontent.com/pkgforge-dev/Anylinux-AppImages/refs/heads/main/useful-tools/get-debloated-pkgs.sh" +PATCH="$PWD"/locale-fix.patch echo "Installing build dependencies..." echo "---------------------------------------------------------------" @@ -37,3 +38,14 @@ echo "---------------------------------------------------------------" wget --retry-connrefused --tries=30 "$EXTRA_PACKAGES" -O ./get-debloated-pkgs.sh chmod +x ./get-debloated-pkgs.sh ./get-debloated-pkgs.sh libxml2-mini gtk3-mini + +echo "Building rofi..." +echo "---------------------------------------------------------------" +git clone --depth 1 "https://github.com/davatorium/rofi.git" ./rofi && ( + cd ./rofi + patch -p1 -i "$PATCH" + meson --prefix /usr . build + meson compile -C build + meson install -C build +) +/usr/bin/rofi -v | awk -F'[- ]' '{print $2; exit}' > ~/version From 9b07a706d7def1e7f6b265d916c3bca15e4a8f27 Mon Sep 17 00:00:00 2001 From: Samuel <36420837+Samueru-sama@users.noreply.github.com> Date: Sun, 24 Aug 2025 08:08:57 -0400 Subject: [PATCH 3/5] simplify with quick-sharun --- rofi-appimage.sh | 114 ++++++++++------------------------------------- 1 file changed, 24 insertions(+), 90 deletions(-) diff --git a/rofi-appimage.sh b/rofi-appimage.sh index ef5e925..a5587c7 100644 --- a/rofi-appimage.sh +++ b/rofi-appimage.sh @@ -1,95 +1,30 @@ #!/bin/sh -set -ex +set -eux ARCH="$(uname -m)" -SHARUN="https://github.com/VHSgunzo/sharun/releases/latest/download/sharun-$ARCH-aio" -URUNTIME="https://github.com/VHSgunzo/uruntime/releases/latest/download/uruntime-appimage-dwarfs-$ARCH" -URUNTIME_LITE="https://github.com/VHSgunzo/uruntime/releases/latest/download/uruntime-appimage-dwarfs-lite-$ARCH" -UPINFO="gh-releases-zsync|$(echo "$GITHUB_REPOSITORY" | tr '/' '|')|latest|*$ARCH.AppImage.zsync" -PATCH="$PWD"/hack.patch - -# CREATE DIRECTORIES -mkdir ./AppDir && ( - cd ./AppDir - # DOWNLOAD AND BUILD ROFI - git clone --depth 1 "https://github.com/davatorium/rofi.git" ./rofi && ( - cd ./rofi - patch -p1 -i "$PATCH" - meson --prefix /usr . build - meson compile -C build - meson install -C build --destdir "$(realpath ../)" - ) - mv -v ./usr/* ./ - cp -v ./share/icons/hicolor/scalable/apps/rofi.svg ./ - cp -v ./share/icons/hicolor/scalable/apps/rofi.svg ./.DirIcon - cp -v ./share/applications/rofi.desktop ./ - echo "Categories=Utility;" >> ./rofi.desktop - - # ADD LIBRARIES - wget --retry-connrefused --tries=30 "$SHARUN" -O ./sharun-aio - chmod +x ./sharun-aio - ./sharun-aio l -p -v -k -s \ - ./bin/* \ - /usr/lib/gdk-pixbuf-*/*/*/* \ - /usr/lib/gio/modules/libgvfsdbus.so - rm -rf ./sharun-aio ./rofi ./usr - - # AppRun - cat > ./AppRun <<-'EOF' - #!/bin/sh - CURRENTDIR="$(dirname "$(readlink -f "$0")")" - - BIN="${ARGV0#./}" - unset ARGV0 - DATADIR="${XDG_DATA_HOME:-$HOME/.local/share}" - - export XDG_DATA_DIRS="$DATADIR:$XDG_DATA_DIRS:/usr/local/share:/usr/share" - export PATH="$CURRENTDIR/bin:$PATH" - - if [ ! -d "$DATADIR"/rofi/themes ]; then - mkdir -p "$DATADIR"/rofi || exit 1 - cp -rn "$CURRENTDIR"/share/rofi/themes "$DATADIR"/rofi/themes || exit 1 - fi - - if [ "$1" = "rofi-theme-selector" ]; then - shift - exec "$CURRENTDIR/bin/rofi-theme-selector" "$@" - elif [ -f "$CURRENTDIR/bin/$BIN" ]; then - exec "$CURRENTDIR/bin/$BIN" "$@" - else - exec "$CURRENTDIR/bin/rofi" "$@" - fi - EOF - - chmod a+x ./AppRun - ./sharun -g -) - -export VERSION="$(./AppDir/AppRun -v | awk -F'[- ]' '{print $2; exit}')" -echo "$VERSION" > ~/version - -# turn appdir into appimage -wget --retry-connrefused --tries=30 "$URUNTIME" -O ./uruntime -wget --retry-connrefused --tries=30 "$URUNTIME_LITE" -O ./uruntime-lite -chmod +x ./uruntime* - -# Keep the mount point (speeds up launch time) -sed -i 's|URUNTIME_MOUNT=[0-9]|URUNTIME_MOUNT=0|' ./uruntime-lite - -# Add udpate info to runtime -echo "Adding update information \"$UPINFO\" to runtime..." -./uruntime-lite --appimage-addupdinfo "$UPINFO" - -echo "Generating AppImage..." -./uruntime \ - --appimage-mkdwarfs -f \ - --set-owner 0 --set-group 0 \ - --no-history --no-create-timestamp \ - --compression zstd:level=22 -S26 -B8 \ - --header uruntime-lite \ - -i ./AppDir \ - -o ./rofi-"$VERSION"-anylinux-"$ARCH".AppImage +VERSION="$(cat ~/version)" +SHARUN="https://raw.githubusercontent.com/pkgforge-dev/Anylinux-AppImages/refs/heads/execv-hook/useful-tools/quick-sharun.sh" +URUNTIME="https://raw.githubusercontent.com/pkgforge-dev/Anylinux-AppImages/refs/heads/main/useful-tools/uruntime2appimage.sh" +UPDATER="https://raw.githubusercontent.com/pkgforge-dev/Anylinux-AppImages/refs/heads/main/useful-tools/self-updater.bg.hook" + +export UPINFO="gh-releases-zsync|${GITHUB_REPOSITORY%/*}|${GITHUB_REPOSITORY#*/}|latest|*$ARCH.AppImage.zsync" +export OUTNAME=rofi-"$VERSION"-anylinux-"$ARCH".AppImage +export DESKTOP=/usr/share/applications/rofi.desktop +export ICON=/usr/share/icons/hicolor/scalable/apps/rofi.svg +export URUNTIME_PRELOAD=1 # really needed here +export EXEC_WRAPPER=1 # needed here since this will launch other processes + +# ADD LIBRARIES +wget --retry-connrefused --tries=30 "$SHARUN" -O ./quick-sharun +chmod +x ./quick-sharun +./quick-sharun /usr/bin/rofi* +echo 'unset ARGV0' > ./AppDir/.env + +# MAKE APPIMAGE WITH URUNTIME +wget --retry-connrefused --tries=30 "$URUNTIME" -O ./uruntime2appimage +chmod +x ./uruntime2appimage +./uruntime2appimage # make appbundle UPINFO="$(echo "$UPINFO" | sed 's#.AppImage.zsync#*.AppBundle.zsync#g')" @@ -106,11 +41,10 @@ echo "Generating [dwfs]AppBundle..." --output-to ./rofi-"$VERSION"-anylinux-"$ARCH".dwfs.AppBundle echo "Generating zsync file..." -zsyncmake ./*.AppImage -u ./*.AppImage zsyncmake ./*.AppBundle -u ./*.AppBundle mkdir -p ./dist -mv -v ./*.AppImage* ./dist +mv -v ./*.AppImage* ./dist mv -v ./*.AppBundle* ./dist echo "All Done!" From 125690a2bcae3e21c9d26093d184d3db7b1a39ee Mon Sep 17 00:00:00 2001 From: Samuel <36420837+Samueru-sama@users.noreply.github.com> Date: Sun, 24 Aug 2025 08:16:53 -0400 Subject: [PATCH 4/5] Create AppRun --- AppDir/AppRun | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 AppDir/AppRun diff --git a/AppDir/AppRun b/AppDir/AppRun new file mode 100644 index 0000000..90a4829 --- /dev/null +++ b/AppDir/AppRun @@ -0,0 +1,39 @@ +#!/bin/sh + +set -e + +CURRENTDIR="$(cd "${0%/*}" && echo "$PWD")" +BIN="${ARGV0:-$0}" +BIN="${BIN##*/}" +DATADIR="${XDG_DATA_HOME:-$HOME/.local/share}" +unset ARGV0 + +export XDG_DATA_DIRS="$DATADIR:$XDG_DATA_DIRS:/usr/local/share:/usr/share" +export PATH="$CURRENTDIR/bin:$PATH" + +if [ ! -d "$DATADIR"/rofi/themes ]; then + mkdir -p "$DATADIR"/rofi + cp -r "$CURRENTDIR"/share/rofi/themes "$DATADIR"/rofi/themes +fi + +# additional scripts can be placed in the top level bin dir +# those with a name that ends up .hook will be executed in teh current shell +# while those that end with bg.hook will be executed in the background +for hook in "$CURRENTDIR"/bin/*.hook; do + [ -x "$hook" ] || continue + case "$hook" in + *.bg.hook) >&2 echo "exec bg hook: $hook"; "$hook" &;; + *.hook) >&2 echo "exec hook: $hook"; "$hook" ;; + esac +done + +# Check if ARGV0 matches any bundled binary, fallback to $1, then main bin +if [ -f "$CURRENTDIR"/bin/"$BIN" ]; then + exec "$CURRENTDIR"/bin/"$BIN" "$@" +elif [ -f "$CURRENTDIR"/bin/"$1" ]; then + BIN="$1" + shift + exec "$CURRENTDIR"/bin/"$BIN" "$@" +else + exec "$CURRENTDIR"/bin/rofi "$@" +fi From d6e26f9d047d87bef4ac75815d28f6596b83cbe1 Mon Sep 17 00:00:00 2001 From: Samuel <36420837+Samueru-sama@users.noreply.github.com> Date: Sun, 24 Aug 2025 08:27:47 -0400 Subject: [PATCH 5/5] flip order --- AppDir/AppRun | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AppDir/AppRun b/AppDir/AppRun index 90a4829..82d497b 100644 --- a/AppDir/AppRun +++ b/AppDir/AppRun @@ -28,12 +28,12 @@ for hook in "$CURRENTDIR"/bin/*.hook; do done # Check if ARGV0 matches any bundled binary, fallback to $1, then main bin -if [ -f "$CURRENTDIR"/bin/"$BIN" ]; then - exec "$CURRENTDIR"/bin/"$BIN" "$@" -elif [ -f "$CURRENTDIR"/bin/"$1" ]; then +if [ -f "$CURRENTDIR"/bin/"$1" ]; then BIN="$1" shift exec "$CURRENTDIR"/bin/"$BIN" "$@" +elif [ -f "$CURRENTDIR"/bin/"$BIN" ]; then + exec "$CURRENTDIR"/bin/"$BIN" "$@" else exec "$CURRENTDIR"/bin/rofi "$@" fi