-
Notifications
You must be signed in to change notification settings - Fork 0
/
polybar-appimage.sh
112 lines (95 loc) · 2.88 KB
/
polybar-appimage.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
#!/bin/sh
set -eu
export ARCH="$(uname -m)"
export APPIMAGE_EXTRACT_AND_RUN=1
APP=polybar
REPO="https://github.com/polybar/polybar"
ICON="https://user-images.githubusercontent.com/36028424/39958898-230ddeec-563c-11e8-8318-d658c63ddf22.png"
UPINFO="gh-releases-zsync|$(echo $GITHUB_REPOSITORY | tr '/' '|')|latest|*$ARCH.AppImage.zsync"
APPIMAGETOOL="https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage"
LIB4BN="https://raw.githubusercontent.com/VHSgunzo/sharun/refs/heads/main/lib4bin"
# CREATE DIRECTORIES
mkdir -p ./"$APP"/AppDir
cd ./"$APP"/AppDir
# DOWNLOAD AND BUILD POLYBAR
CURRENTDIR="$(readlink -f "$(dirname "$0")")" # DO NOT MOVE THIS
CXXFLAGS='-O3'
git clone --recursive "$REPO" polybar
( cd polybar
mkdir build
cd build
cmake -DENABLE_ALSA=ON ..
make -j$(nproc)
make install DESTDIR="$CURRENTDIR"
)
rm -rf ./polybar
# ADD LIBRARIES
mkdir ./usr/lib
mv ./usr ./shared
wget "$LIB4BN" -O ./lib4bin
chmod +x ./lib4bin
./lib4bin -p -v -r -s ./shared/bin/*
rm -f ./lib4bin
# Patch polybar binary so that it finds its default "/etc" config in the AppDir
sed -i 's|/etc|././|g' ./shared/bin/polybar
ln -s ./etc/polybar ./polybar
# AppRun
cat >> ./AppRun << 'EOF'
#!/usr/bin/env sh
CURRENTDIR="$(dirname "$(readlink -f "$0")")"
export PATH="$CURRENTDIR/bin:$PATH"
BIN="${ARGV0#./}"
unset ARGV0
[ -z "$APPIMAGE" ] && APPIMAGE="$0"
[ ! -f "$CURRENTDIR/bin/$BIN" ] && BIN=polybar
# we patched a relative path in polybar, so we cd here
cd "$CURRENTDIR"
if [ "$1" = "--bars" ]; then
shift
for bar in "$@"; do
exec "$CURRENTDIR/bin/polybar" "$bar" &
done
elif [ "$1" = '--msg' ]; then
shift
exec "$CURRENTDIR"/bin/polybar-msg "$@"
else
exec "$CURRENTDIR/bin/$BIN" "$@"
echo "AppImage commands:"
echo " \"$APPIMAGE --msg\" Launches polybar-msg"
echo " \"$APPIMAGE --bars bar1 bar2 bar3\" Launches multiple bars"
echo ""
echo "You can also symlink the appimage with the name polybar-msg"
echo "and by launching that symlink it will automatically run"
echo "polybar-msg without having to pass any extra arguments"
echo "AppImage also supports the \"--bars\" flag which lets you"
echo "run multiple polybar instances with a single command"
fi
EOF
chmod +x ./AppRun
./sharun -g
VERSION="$(./bin/polybar --version | awk 'FNR==1 {print $2}')"
# Desktop
cat >> ./"$APP.desktop" << 'EOF'
[Desktop Entry]
Type=Application
Name=polybar
Icon=polybar
Exec=polybar
Categories=System
Hidden=true
EOF
# Icon
wget "$ICON" -O ./polybar.png || touch ./polybar.png
ln -s polybar.png ./.DirIcon
# MAKE APPIMAGE USING FUSE3 COMPATIBLE APPIMAGETOOL
cd ..
wget -q "$APPIMAGETOOL" -O ./appimagetool
chmod +x ./appimagetool
echo "Making appimage..."
./appimagetool --comp zstd \
--mksquashfs-opt -Xcompression-level --mksquashfs-opt 22 \
-n -u "$UPINFO" "$PWD"/AppDir "$PWD"/"$APP"-"$VERSION"-anylinux-"$ARCH".AppImage
mv ./*.AppImage* ..
cd ..
rm -rf ./"$APP"
echo "All Done!"