Krolyxon
Commit de9a285

Branches

Refs →

nsxivde9a285

Add desktop and icon rules to Makefile, document icon installation (#80)

Author
Guilherme Rugai Freire
Date
2021-09-22 23:17 -0300
Committer
GitHub · 2021-09-23 02:17 +0000
Parent
9e22f32
Commit
de9a285ff2d1d31e87a70003588595e443c7fabd

+40 −16

3 files changed

  1. M Makefile +28 −2
  2. M README.md +12 −2
  3. D icon/Makefile +0 −12
M Makefile View
@@ -17,6 +17,9 @@ AUTORELOAD = inotify
1717 # CFLAGS, any optimization flags goes here
1818 CFLAGS ?= -std=c99 -Wall -pedantic
1919
20+# icons that will be installed via `make icon`
21+ICONS = 16x16.png 32x32.png 48x48.png 64x64.png 128x128.png
22+
2023 ifeq ($(HAVE_LIBEXIF), 1)
2124 OPTIONAL_LIBS += -lexif
2225 else
@@ -37,7 +40,7 @@ LDLIBS = -lImlib2 -lX11 -lXft -lfontconfig $(OPTIONAL_LIBS)
3740 OBJS = autoreload_$(AUTORELOAD).o commands.o image.o main.o options.o \
3841 thumbs.o util.o window.o
3942
40−.PHONY: all clean install uninstall
43+.PHONY: all clean install uninstall icon
4144 .SUFFIXES:
4245 .SUFFIXES: .c .o
4346
@@ -78,6 +81,27 @@ version.h: Makefile .git/index
7881 clean:
7982 $(RM) *.o nsxiv
8083
84+desktop:
85+ @echo "INSTALL nsxiv.desktop"
86+ mkdir -p $(DESTDIR)$(PREFIX)/share/applications
87+ cp nsxiv.desktop $(DESTDIR)$(PREFIX)/share/applications
88+
89+icon:
90+ @echo "INSTALL icon"
91+ for f in $(ICONS); do \
92+ dir="$(DESTDIR)$(PREFIX)/share/icons/hicolor/$${f%.png}/apps"; \
93+ mkdir -p "$$dir"; \
94+ cp "icon/$$f" "$$dir/nsxiv.png"; \
95+ chmod 644 "$$dir/nsxiv.png"; \
96+ done
97+
98+icon_cleanup:
99+ @echo "REMOVE icon"
100+ for f in $(ICONS); do \
101+ dir="$(DESTDIR)$(PREFIX)/share/icons/hicolor/$${f%.png}/apps"; \
102+ rm -f "$$dir/nsxiv.png"; \
103+ done
104+
81105 install: all
82106 @echo "INSTALL bin/nsxiv"
83107 install -Dt $(DESTDIR)$(PREFIX)/bin nsxiv
@@ -89,11 +113,13 @@ install: all
89113 @echo "INSTALL share/nsxiv/"
90114 install -Dt $(DESTDIR)$(DOCPREFIX)/examples examples/*
91115
92−uninstall:
116+uninstall: icon_cleanup
93117 @echo "REMOVE bin/nsxiv"
94118 rm -f $(DESTDIR)$(PREFIX)/bin/nsxiv
95119 @echo "REMOVE nsxiv.1"
96120 rm -f $(DESTDIR)$(MANPREFIX)/man1/nsxiv.1
121+ @echo "REMOVE nsxiv.desktop"
122+ rm -f $(DESTDIR)$(PREFIX)/share/applications/nsxiv.desktop
97123 @echo "REMOVE share/nsxiv/"
98124 rm -rf $(DESTDIR)$(DOCPREFIX)
99125
M README.md View
@@ -79,9 +79,19 @@ Installing nsxiv:
7979
8080 # make install
8181
82−Please note, that this requires root privileges.
82+Installing desktop entry:
83+
84+ # make desktop
85+
86+Installing icons:
87+
88+ # make icon
89+
90+Please note, that these requires root privileges.
8391 By default, nsxiv is installed using the prefix "/usr/local", so the full path
84−of the executable will be "/usr/local/bin/nsxiv".
92+of the executable will be "/usr/local/bin/nsxiv", the `.desktop` entry will be
93+"/usr/local/share/applications/nsxiv.desktop" and the icon path will be
94+"/usr/local/share/icons/hicolor/{size}/apps/nsxiv.png".
8595
8696 You can install nsxiv into a directory of your choice by changing this command to:
8797
D icon/Makefile View
@@ -1,12 +0,0 @@
1−PREFIX = /usr/local
2−ICONS = 16x16.png 32x32.png 48x48.png 64x64.png 128x128.png
3−
4−all:
5−
6−install:
7− for f in $(ICONS); do \
8− dir="$(DESTDIR)$(PREFIX)/share/icons/hicolor/$${f%.png}/apps"; \
9− mkdir -p "$$dir"; \
10− cp "$$f" "$$dir/nsxiv.png"; \
11− chmod 644 "$$dir/nsxiv.png"; \
12− done