-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall-marktext.sh
More file actions
executable file
·134 lines (106 loc) · 2.81 KB
/
install-marktext.sh
File metadata and controls
executable file
·134 lines (106 loc) · 2.81 KB
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
#!/bin/bash
# --- External Functions ---
source lib/notify_lib.sh 2>/dev/null || true
source lib/check_libfuse.sh 2>/dev/null || true
# --- Variables ---
INSTALL_DIR="$HOME/.local/bin"
DESKTOP_DIR="$HOME/.local/share/applications"
APPNAME="marktext"
# --- Functions ---
help() {
cat << EOF
Usage: $0 [option] [version]
Options:
-h Show this help message
-i VERSION Install MarkText version VERSION
-u Uninstall MarkText
Examples:
$0 -i 0.17.1
$0 -u
EOF
exit 1
}
install() {
VERSION="$1"
if [ -z "$VERSION" ]; then
notify "You must specify a version to install." "error"
help
fi
notify "Installing MarkText ${VERSION}" "heading"
check_libfuse || return 1
# Si hay versiones previas, eliminarlas
EXISTING=$(ls "$INSTALL_DIR"/marktext-*-x86_64.AppImage 2>/dev/null)
if [ -n "$EXISTING" ]; then
notify "Previous MarkText version found. Removing..."
uninstall
fi
URL="https://github.com/marktext/marktext/releases/download/v$VERSION/marktext-x86_64.AppImage"
FILENAME="marktext-$VERSION-x86_64.AppImage"
mkdir -p "$INSTALL_DIR"
notify "Downloading MarkText $VERSION..."
wget -O "$INSTALL_DIR/$FILENAME" "$URL" || { echo "Download failed"; exit 1; }
chmod +x "$INSTALL_DIR/$FILENAME"
# Create symlink
ln -sf "$INSTALL_DIR/$FILENAME" "$INSTALL_DIR/$APPNAME"
# Create desktop file
mkdir -p "$DESKTOP_DIR"
DESKTOP_FILE="$DESKTOP_DIR/$APPNAME.desktop"
cat > "$DESKTOP_FILE" << EOF
[Desktop Entry]
Name=MarkText
Comment=Next generation markdown editor
Exec=$INSTALL_DIR/$FILENAME %F
Terminal=false
Type=Application
Icon=marktext
Categories=Office;TextEditor;Utility;
MimeType=text/markdown;
Keywords=marktext;
StartupWMClass=marktext
Actions=NewWindow;
[Desktop Action NewWindow]
Name=New Window
Exec=$INSTALL_DIR/$FILENAME --new-window %F
Icon=marktext
EOF
notify "MarkText $VERSION installed successfully!" "success"
}
uninstall() {
# Check if any AppImage exists
APPIMAGE=$(ls "$INSTALL_DIR"/marktext-*-x86_64.AppImage 2>/dev/null)
if [ -z "$APPIMAGE" ]; then
notify "MarkText is not installed in $INSTALL_DIR" "info"
exit 1
fi
# Remove AppImage
rm -f "$INSTALL_DIR"/marktext-*-x86_64.AppImage
# Remove symlink
rm -f "$INSTALL_DIR/$APPNAME"
# Remove desktop file
rm -f "$DESKTOP_DIR/$APPNAME.desktop"
notify "MarkText uninstalled successfully." "success"
}
main() {
if [ $# -eq 0 ]; then
help
fi
case "$1" in
-h)
help
;;
-i)
install "$2"
;;
-u)
uninstall
;;
-a)
upgrade "$2"
;;
*)
echo "Unknown option: $1"
help
;;
esac
}
main "$@"