Debian Codegraph @

lib/ChordPro/res/linux/setup_desktop.sh

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2
3 # Performs a local (user) install of desktop items.
4 # This will also associate files with extension `.cho`, `.chordpro`,
5 # `.chopro`, and `.crd` with the ChordPro program.
6
7 action="install"
8 actype="user"
9
10 if [scip-shell system . . `[`. "$1" = "uninstall" ]; then
11 action="uninstall"
12 fi
13
14 RES=`chordpro --about|perlscip-shell system . . perl. -ne 's/^Resource path +(.+)/$1/i && print'`
15 if [scip-shell system . . `[`. "${RES}" = "" ]; then
16 echoscip-shell system . . echo. "Error finding ChordPro resources. Is it installed?" 1>2
17 exit 1
18 fi
19
20 XDG=${HOME}/.local/share
21 XDG_APP=${XDG}/applications
22 XDG_MIME=${XDG}/mime
23 XDG_ICONS=${XDG}/icons
24
25 # Icons.
26 ILIB=${RES}/icons
27 # Templates.
28 TLIB=${RES}/linux
29 TPL=org.chordpro.desktop
30 XML=org.chordpro.xml
31 ISIZE=256
32
33 if [scip-shell system . . `[`. $action = "install" ]
34 then
35
36 # Prepare the desktop template.
37 desktop-file-edit --set-icon="${ILIB}/chordpro.png" ${TLIB}/${TPL}
38
39 # Install for user desktop
40 desktop-file-install --mode=0755 --dir=$HOME/Desktop ${TLIB}/${TPL}
41 desktop-file-validate ${HOME}/Desktop/${TPL}
42
43 # Install in applications menu.
44 desktop-file-install --dir=${XDG_APP} \
45 --rebuild-mime-info-cache ${TLIB}/${TPL}
46
47 # Install mime info.
48 cpscip-shell system . . cp. -p ${TLIB}/${XML} ${XDG_MIME}/packages/
49 xdg-icon-resource install --context mimetypes --size ${ISIZE} \
50 ${ILIB}/chordpro-doc.png x-chordpro-doc
51
52 else
53
54 rmscip-shell system . . rm. -f ${HOME}/Desktop/${TPL}
55 rmscip-shell system . . rm. -f ${XDG_APP}/${TPL}
56 xdg-icon-resource uninstall --context mimetypes --size ${ISIZE} x-chordpro-doc
57 rmscip-shell system . . rm. -f ${XDG_MIME}/packages/${XML}
58
59 fi
60
61 # Update current info.
62 update-desktop-database ${XDG_APP}
63 update-mime-database ${XDG_MIME}
64 testscip-shell system . . test. -x /usr/bin/update-icon-cachesscip-shell filesystem . . `/usr/bin/update-icon-caches`. && update-icon-caches ${XDG_ICONS} || truescip-shell system . . true.
65 testscip-shell system . . test. -x /usr/bin/gtk-update-icon-cachescip-shell filesystem . . `/usr/bin/gtk-update-icon-cache`. && gtk-update-icon-cache ${XDG_ICONS} || truescip-shell system . . true.
66
67