-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
68 lines (65 loc) · 1.99 KB
/
Makefile
File metadata and controls
68 lines (65 loc) · 1.99 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
.SILENT: all setup uninstall update_database associate trusted _create_dirs
SHELL := /usr/bin/env bash
APPS_FOLDER = $(HOME)/.local/share/applications
BASIC_MIME_FOLDER = $(HOME)/.local/share/mime/
MIMES_FOLDER = $(BASIC_MIME_FOLDER)packages
IS_ROOT = $(shell id -u)
LAUNCHER_FILE = "$(APPS_FOLDER)/ProgramPackLauncher.desktop"
MIME_FILE = "$(MIMES_FOLDER)/x-programpack-extension.xml"
CACHE_DIR = ~/.cache
CACHE_FILE = $(CACHE_DIR)/programpack_mime_set.flag
define DATA
[Added Associations]
custom-mime/custom-programpack-mime-type=ProgramPackLauncher.desktop
endef
export DATA
all: setup update_database associate
_create_dirs:
echo 'Creating directories...'
mkdir -p "$(APPS_FOLDER)"
echo 'Apps directory created'
mkdir -p "$(MIMES_FOLDER)"
echo 'Mimetypes directory created'
echo 'Directories created'
setup:
echo 'Starting...'
$(MAKE) _create_dirs
cp "desktop/ProgramPackLauncher.desktop" "$(LAUNCHER_FILE)"
echo 'Application .desktop file copied'
cp "mimetype/programpack-extension.xml" "$(MIME_FILE)"
echo 'Mimetype copied'
$(MAKE) trusted
echo 'Done!"'
uninstall:
echo 'Starting to uninstall...'
$(MAKE) _create_dirs
rm -f "$(LAUNCHER_FILE)"
rm -f "$(MIME_FILE)"
rm -f "$(CACHE_FILE)"
echo 'Successfully uninstalled'
update_database:
echo 'Updating database(s)...'
update-mime-database $(BASIC_MIME_FOLDER)
if [ $(IS_ROOT) == 0 ]; then \
update-mime-database /usr/share/mime; \
echo 'Is root: updated the /usr/share/mime database'; \
else \
echo "Not root: didn't update the /usr/share/mime database"; \
fi
echo "Database(s) updated"
associate:
echo 'Associating types...'
if [ -f $(CACHE_FILE) ]; then \
echo 'Type have been already associated'; \
else \
echo "$$DATA">>"$(APPS_FOLDER)/mimeapps.list"; \
mkdir -p $(CACHE_DIR); \
touch $(CACHE_FILE); \
fi
echo 'Type associated'
trusted:
echo 'Making file trusted...'
gio set "$(LAUNCHER_FILE)" 'metadata::trusted' yes || true
echo 'Making file executable...'
chmod 777 "$(LAUNCHER_FILE)"
echo 'File should be trusted now'