|
| 1 | + |
| 2 | +# #################################################### |
| 3 | +# Author : Rahul Singh |
| 4 | +# URL : https://github.com/codecliff/softdrink |
| 5 | +# License : MIT |
| 6 | +# email : codecliff@users.noreply.github.com |
| 7 | +# Disclaimer: No warranties, stated or implied. |
| 8 | +# Description : |
| 9 | +# This File is part of softdrink project |
| 10 | +# A personal attempt to create directory shortcuts |
| 11 | +# for Gnome and Nautilus file browser |
| 12 | +# (Acknowledgment: This project has heavily used LLMs |
| 13 | +# viz. Phind, Bard and ChatGPT ) |
| 14 | +# ##################################################### |
| 15 | + |
| 16 | +# ##################################################### |
| 17 | +# Start development build with this file |
| 18 | +# Not needed for install |
| 19 | +# Version number update to be done in configure.ac |
| 20 | +# ##################################################### |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | +# SHELL = /bin/bash |
| 25 | +SUBDIRS = src |
| 26 | + |
| 27 | +EXTRA_DIST = assets |
| 28 | + |
| 29 | +AUTOMAKE_OPTIONS = foreign |
| 30 | + |
| 31 | + |
| 32 | +# in if - else, use \ as make takes each line as separate command |
| 33 | +# indents are very important for scoping |
| 34 | +# use double $$ for shell variables |
| 35 | +# also, no comments inside the hook |
| 36 | +# target rah_os_dep_target is run conditional on os type |
| 37 | + |
| 38 | + |
| 39 | +###### Prepare different stuff for Ubuntu vs others ######### |
| 40 | +# OS (Ubuntu / Fedora Linux etc) |
| 41 | +RAH_OS = $(shell grep -oP '^NAME.\"\K.*(?=\")' /etc/os-release) |
| 42 | + |
| 43 | +# Demarcate diferent targets for different OSs |
| 44 | +rah_os_dep_target = $(if $(filter Ubuntu,$(RAH_OS)),rah_ubuntu_hook,rah_nonubuntu_hook) |
| 45 | + |
| 46 | + |
| 47 | + |
| 48 | +# Define os-specific parts |
| 49 | +rah_ubuntu_hook: |
| 50 | + @echo "OS is Ubuntu" |
| 51 | + @echo "Installing custom mime for all users" |
| 52 | + sudo cp ./assets/application-x-jump_ubuntu.xml /usr/share/mime/packages/application-x-jump.xml |
| 53 | + sudo update-icon-caches /usr/share/icons |
| 54 | + sudo update-icon-caches /usr/share/icons/hicolor |
| 55 | + |
| 56 | +rah_nonubuntu_hook: |
| 57 | + @echo "OS Not Ubuntu" |
| 58 | + sudo cp ./assets/application-x-jump_others.xml /usr/share/mime/packages/application-x-jump.xml |
| 59 | + @echo " Resorting to gtk-update-icon-cache \n" |
| 60 | + sudo gtk-update-icon-cache -tf /usr/share/icons |
| 61 | + sudo gtk-update-icon-cache -tf /usr/share/icons/hicolor |
| 62 | + |
| 63 | + |
| 64 | +# to call these parts, run this |
| 65 | +rah_conditional_hook: $(rah_os_dep_target) |
| 66 | + |
| 67 | +################## Installation ######################## |
| 68 | +install-exec-hook: |
| 69 | + @echo "Going to install custom mime and icons for all users" |
| 70 | + @echo "Installing .desktop file for all users" |
| 71 | + sudo cp ./assets/softdrink.desktop /usr/share/applications/ |
| 72 | + sudo chmod 755 /usr/share/applications/softdrink.desktop |
| 73 | + |
| 74 | + @echo "Installing icon for all users" |
| 75 | + sudo cp ./assets/softdrink.svg /usr/share/icons/softdrink.svg |
| 76 | + sudo chmod 644 /usr/share/icons/softdrink.svg |
| 77 | + sudo cp ./assets/softdrink.png /usr/share/icons/softdrink.png |
| 78 | + sudo chmod 644 /usr/share/icons/softdrink.png |
| 79 | + |
| 80 | + sudo cp ./assets/softdrink.svg /usr/share/icons/hicolor/scalable/mimetypes/application-x-jump.svg |
| 81 | + sudo chmod 644 /usr/share/icons/hicolor/scalable/mimetypes/application-x-jump.svg |
| 82 | + |
| 83 | + $(MAKE) rah_conditional_hook |
| 84 | + |
| 85 | + @echo "Updating mime and desktop databases etc:" |
| 86 | + sudo update-mime-database /usr/share/mime |
| 87 | + sudo update-desktop-database /usr/share/applications |
| 88 | + |
| 89 | + @echo "Done with install-exec-hook" |
| 90 | + |
| 91 | + |
| 92 | + |
| 93 | +################## Unisntallation ######################## |
| 94 | +uninstall-hook: |
| 95 | + |
| 96 | + @echo "Removing custom mime for all users" |
| 97 | + |
| 98 | + sudo rm -f /usr/share/mime/packages/application-x-jump.xml |
| 99 | + sudo rm -f /usr/share/mime/application/x-jump.xml |
| 100 | + |
| 101 | + @echo "Removing softdrink.desktop file for all users" |
| 102 | + sudo rm -f /usr/share/applications/softdrink.desktop |
| 103 | + |
| 104 | + @echo "Removing scalable icon for all users" |
| 105 | + sudo rm -f /usr/share/icons/softdrink.svg |
| 106 | + sudo rm -f /usr/share/icons/softdrink.png |
| 107 | + sudo rm -f /usr/share/icons/hicolor/scalable/mimetypes/application-x-jump.svg |
| 108 | + |
| 109 | + @echo "Updating mime databases etc:" |
| 110 | + sudo update-mime-database /usr/share/mime |
| 111 | + sudo update-desktop-database /usr/share/applications |
| 112 | + |
| 113 | + sudo update-icon-caches /usr/share/icons |
| 114 | + @if [ $$? -ne 0 ]; then \ |
| 115 | + @echo " Resorting to gtk-update-icon-cache \n;" \ |
| 116 | + sudo gtk-update-icon-cache -tf /usr/share/icons; \ |
| 117 | + sudo gtk-update-icon-cache -tf /usr/share/icons/hicolor; \ |
| 118 | + fi |
| 119 | + |
| 120 | + @echo "Done with uninstall-hook" |
| 121 | + |
| 122 | + |
| 123 | + |
| 124 | + |
| 125 | + |
| 126 | + |
| 127 | + |
| 128 | + |
0 commit comments