-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathubuntu-shortcut-creator.sh
More file actions
executable file
·173 lines (155 loc) · 5.65 KB
/
ubuntu-shortcut-creator.sh
File metadata and controls
executable file
·173 lines (155 loc) · 5.65 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#!/bin/bash
# Copyright (c) 2018-2025 Conceal Network & Conceal Devs
#
# This script is to be used on Linux Ubuntu system after completing the build as per README.md
# or after downloading and extracting the release zip from github.
# it will create shortcut with Icon.
#
# If you have already installed the application manually, you can run this script to update the shortcut.
# sudo is required since the .desktop file will be written in ~/.local/share/applications/
# Also make sure this script is executable, otherwise run 'chmod 755 ubuntu-shortcut-creator.sh'
#
# run with: sudo ./ubuntu-shortcut-creator.sh
# Define colors for terminal output
if [[ "$TERM" =~ xterm* ]] || [[ "$TERM" =~ screen* ]] || [[ "$TERM" =~ tmux* ]]; then
# Colors for xterm-compatible terminals
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
ORANGE='\033[0;33m'
BOLD='\033[1m'
NC='\033[0m' # No Color
else
# No colors for other terminals
RED=''
GREEN=''
YELLOW=''
ORANGE=''
BOLD=''
NC=''
fi
NEED_QT_DEPENDENCY=false
# Detect distribution and package manager
if command -v apt >/dev/null 2>&1; then
DISTRO="debian"
PKG_MANAGER="apt"
PKG_CHECK="dpkg -l"
PKG_NAME="libqt5charts5"
elif command -v pacman >/dev/null 2>&1; then
DISTRO="arch"
PKG_MANAGER="pacman"
PKG_CHECK="pacman -Q"
PKG_NAME="qt5-charts"
else
DISTRO="unknown"
PKG_MANAGER="unknown"
PKG_CHECK=""
PKG_NAME=""
fi
# Check if Qt dependencies are actually needed
if [ "$DISTRO" != "unknown" ]; then
if ! $PKG_CHECK | grep -q "$PKG_NAME"; then
NEED_QT_DEPENDENCY=true
fi
fi
# Function to install Qt dependencies
install_qt_dependencies() {
if [ "$NEED_QT_DEPENDENCY" = true ]; then
echo -e "${YELLOW}${BOLD}Qt Charts is more likely needed for this release version.${NC}"
read -p "$(echo -e "${BOLD}Confirm install? (Y/n)${NC} ")" -n 1 -r
echo
if [[ $REPLY =~ ^[Nn]$ ]]; then
echo -e "${YELLOW}Qt dependency installation skipped by user${NC}"
else
echo -e "${YELLOW}${BOLD}Checking for Qt dependencies...${NC}"
if [ "$DISTRO" = "debian" ]; then
echo -e "${ORANGE}Installing Qt5 Charts package (includes all necessary Qt5 libraries)...${NC}"
apt-get update -qq
apt install -y -qq libqt5charts5
echo -e "${GREEN}Qt5 Charts package installed successfully${NC}"
elif [ "$DISTRO" = "arch" ]; then
echo -e "${ORANGE}Installing Qt5 Charts package (includes all necessary Qt5 libraries)...${NC}"
pacman -S -q qt5-charts
echo -e "${GREEN}Qt5 Charts package installed successfully${NC}"
else
echo -e "${YELLOW}${BOLD}Warning: Could not install Qt dependencies automatically.${NC}"
echo -e "Please install Qt5 Charts package for your distribution."
echo -e "The application may not work without it."
fi
fi
fi
}
# Check if script is run as sudo
if [ "$EUID" -ne 0 ]; then
echo -e "${RED}${BOLD}Error: This script needs to be run as sudo.${NC}"
echo -e "Please run: ${BOLD}sudo $0${NC}"
exit 1
fi
# Get the actual user who ran the script with sudo
REAL_USER=${SUDO_USER:-$USER}
REAL_HOME=$(getent passwd "$REAL_USER" | cut -d: -f6)
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
# Create user applications directory if it doesn't exist
mkdir -p "${REAL_HOME}/.local/share/applications"
# Define paths
DESKTOP_FILE="${REAL_HOME}/.local/share/applications/conceal-desktop.desktop"
# Check if desktop file already exists
# incase the user installed manually the desktop file, we need to install the dependencies
if [ -f "$DESKTOP_FILE" ]; then
echo -e "${YELLOW}${BOLD}Desktop file already exists.${NC}"
read -p "$(echo -e "${BOLD}Do you want to overwrite it? (y/n)${NC} ")" -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo -e "${YELLOW}Operation cancelled${NC}"
install_qt_dependencies
sleep 1
exit 1
fi
echo -e "${ORANGE}Overwriting existing desktop file...${NC}"
fi
BINARY_PATH_BUILD="${SCRIPT_DIR}/bin/conceal-desktop"
BINARY_PATH_RELEASE="${SCRIPT_DIR}/conceal-desktop"
# Check if binary exists
if [ -f "$BINARY_PATH_BUILD" ]; then
BINARY_PATH="$BINARY_PATH_BUILD"
ICON_PATH="${SCRIPT_DIR}/src/images/conceal.png"
NEED_QT_DEPENDENCY=false
echo -e "${ORANGE}Detected: Manual build case${NC}"
elif [ -f "$BINARY_PATH_RELEASE" ]; then
BINARY_PATH="$BINARY_PATH_RELEASE"
ICON_PATH="${SCRIPT_DIR}/icon/conceal.png"
NEED_QT_DEPENDENCY=true
echo -e "${ORANGE}Detected: Release zip case${NC}"
else
echo -e "${RED}${BOLD}Error: Binary not found at:${NC}"
echo -e " ${RED}$BINARY_PATH_BUILD${NC} (manual build)"
echo -e " ${RED}$BINARY_PATH_RELEASE${NC} (release zip)"
exit 1
fi
# Check if icon exists
if [ ! -f "$ICON_PATH" ]; then
echo -e "${RED}${BOLD}Error: Icon not found at $ICON_PATH${NC}"
exit 1
fi
echo -e "${ORANGE}Using binary: ${BOLD}$BINARY_PATH${NC}"
echo -e "${ORANGE}Using icon: ${BOLD}$ICON_PATH${NC}"
# Create desktop file
echo -e "${ORANGE}Creating desktop shortcut...${NC}"
cat > "$DESKTOP_FILE" << EOF
[Desktop Entry]
Encoding=UTF-8
Name=Conceal Desktop
Comment=Conceal Desktop
Exec=$BINARY_PATH
Terminal=false
Type=Application
Icon=$ICON_PATH
MimeType=x-scheme-handler/concealwallet;
Categories=Office;Finance;Cryptocurrency;
EOF
# Set proper ownership
chown ${REAL_USER}:${REAL_USER} "$DESKTOP_FILE"
# Install Qt dependencies if confirmed
install_qt_dependencies
echo -e "${GREEN}${BOLD}Desktop shortcut created successfully at $DESKTOP_FILE${NC}"
echo -e "${GREEN}You should now be able to find Conceal Desktop in your Applications menu${NC}"