From 96103a757f43c194860fffa7f52f9a65576fee40 Mon Sep 17 00:00:00 2001 From: Muhammad Herdiansyah Date: Tue, 20 Jun 2017 15:14:45 +0700 Subject: [PATCH 1/6] Misc: Removed Makefile and added install script --- Makefile | 20 -------------------- install.sh | 31 +++++++++++++++++++++++++++++++ neofetch | 38 ++++++++------------------------------ 3 files changed, 39 insertions(+), 50 deletions(-) delete mode 100644 Makefile create mode 100755 install.sh diff --git a/Makefile b/Makefile deleted file mode 100644 index b7d4105f..00000000 --- a/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -PREFIX = /usr - -all: - @echo Run \'make install\' to install Neofetch - -install: - mkdir -p $(DESTDIR)$(PREFIX)/bin - mkdir -p $(DESTDIR)$(PREFIX)/share/man/man1 - mkdir -p $(DESTDIR)/etc/neofetch - mkdir -p $(DESTDIR)$(PREFIX)/share/neofetch/ascii/distro - cp -p neofetch $(DESTDIR)$(PREFIX)/bin/neofetch - cp -p neofetch.1 $(DESTDIR)$(PREFIX)/share/man/man1/neofetch.1 - cp -p config/config $(DESTDIR)/etc/neofetch/config - cp -p ascii/distro/* $(DESTDIR)$(PREFIX)/share/neofetch/ascii/distro - -uninstall: - rm -f $(DESTDIR)$(PREFIX)/bin/neofetch - rm -f $(DESTDIR)$(PREFIX)/share/man/man1/neofetch.1 - rm -f -r $(DESTDIR)$(PREFIX)/share/neofetch - rm -f -r $(DESTDIR)/etc/neofetch diff --git a/install.sh b/install.sh new file mode 100755 index 00000000..99a7baa9 --- /dev/null +++ b/install.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +while [[ "$1" ]]; do + case "$1" in + "--destdir") DESTDIR="$2" ;; + "--bindir") BINDIR="$2" ;; + "--confdir") CONFDIR="$2" ;; + "--prefix") PREFIX="$2" ;; + "--asciidir") ASCIIDIR="$2" ;; + "--mandir") MANDIR="$2" ;; + esac + shift +done + +[[ -z "$BINDIR" ]] && BINDIR="/usr/bin" +[[ -z "$CONFDIR" ]] && CONFDIR="/etc/neofetch" +[[ -z "$ASCIIDIR" ]] && ASCIIDIR="/usr/share/neofetch/ascii/distro" +[[ -z "$MANDIR" ]] && MANDIR="/usr/share/man/man1" + +mkdir -p "${DESTDIR}""${PREFIX}""${BINDIR}" +mkdir -p "${DESTDIR}""${PREFIX}""${CONFDIR}" +mkdir -p "${DESTDIR}""${PREFIX}""${ASCIIDIR}" +mkdir -p "${DESTDIR}""${PREFIX}""${MANDIR}" + +sed -i -e "s|CONFDIR|/${PREFIX}${CONFDIR}|g" neofetch +sed -i -e "s|ASCIIDIR|/${PREFIX}${ASCIIDIR}|g" neofetch + +cp -p neofetch "${DESTDIR}""${PREFIX}""${BINDIR}" +cp -p config/config "${DESTDIR}""${PREFIX}""${CONFDIR}" +cp -p ascii/distro/* "${DESTDIR}""${PREFIX}""${ASCIIDIR}" +cp -p neofetch.1 "${DESTDIR}""${PREFIX}""${MANDIR}" diff --git a/neofetch b/neofetch index f53ff1c7..1627499f 100755 --- a/neofetch +++ b/neofetch @@ -2171,18 +2171,9 @@ get_ascii() { [[ "$image_source" =~ \.(png|jpg|jpe|jpeg|gif)$ ]] && \ err "Image: Source is image file but ascii backend was selected. Using distro ascii." - if [[ -d "/usr/share/neofetch/ascii/distro" ]]; then - ascii_dir="/usr/share/neofetch/ascii/distro" - - elif [[ -d "/usr/local/share/neofetch/ascii/distro" ]]; then - ascii_dir="/usr/local/share/neofetch/ascii/distro" - - elif [[ -d "/data/data/com.termux/files/usr/share/neofetch/ascii/distro" ]]; then - ascii_dir="/data/data/com.termux/files/usr/share/neofetch/ascii/distro" - - elif [[ -d "/boot/home/config/non-packaged/share/neofetch/ascii/distro" ]]; then - ascii_dir="/boot/home/config/non-packaged/share/neofetch/ascii/distro" - + # Note: ASCIIDIR here is a placeholder -- it will be replaced with your ASCII directory. + if [[ -d "ASCIIDIR" ]]; then + ascii_dir="ASCIIDIR" else [[ -z "$script_dir" ]] && script_dir="$(get_full_path "$0")" ascii_dir="${script_dir%/*}/ascii/distro" @@ -3565,18 +3556,9 @@ get_full_path() { } get_default_config() { - if [[ -f "/etc/neofetch/config" ]]; then - default_config="/etc/neofetch/config" - - elif [[ -f "/usr/local/etc/neofetch/config" ]]; then - default_config="/usr/local/etc/neofetch/config" - - elif [[ -f "/data/data/com.termux/files/usr/etc/neofetch/config" ]]; then - default_config="/data/data/com.termux/files/usr/etc/neofetch/config" - - elif [[ -f "/boot/home/config/non-packaged/etc/neofetch/config" ]]; then - default_config="/boot/home/config/non-packaged/etc/neofetch/config" - + # Note: CONFDIR here is a placeholder -- it will be replaced with your configuration directory. + if [[ -f "CONFDIR/config" ]]; then + default_config="CONFDIR/config" else [[ -z "$script_dir" ]] && script_dir="$(get_full_path "$0")" default_config="${script_dir%/*}/config/config" @@ -3604,12 +3586,8 @@ get_user_config() { if [[ -f "${XDG_CONFIG_HOME}/neofetch/config" ]]; then config_file="${XDG_CONFIG_HOME}/neofetch/config" - elif [[ -f "/etc/neofetch/config" ]]; then - cp "/etc/neofetch/config" "${XDG_CONFIG_HOME}/neofetch" - config_file="${XDG_CONFIG_HOME}/neofetch/config" - - elif [[ -f "/usr/local/etc/neofetch/config" ]]; then - cp "/usr/local/share/neofetch/config" "${XDG_CONFIG_HOME}/neofetch" + elif [[ -f "CONFDIR/config" ]]; then + cp "CONFDIR/config" "${XDG_CONFIG_HOME}/neofetch" config_file="${XDG_CONFIG_HOME}/neofetch/config" else From 8665cbb4eb4c1338a4ff018e304411c0cb2f3e5d Mon Sep 17 00:00:00 2001 From: Muhammad Herdiansyah Date: Tue, 20 Jun 2017 18:28:19 +0700 Subject: [PATCH 2/6] Misc: Different behaviors if PREFIX is empty --- install.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index 99a7baa9..1daf9901 100755 --- a/install.sh +++ b/install.sh @@ -12,10 +12,16 @@ while [[ "$1" ]]; do shift done -[[ -z "$BINDIR" ]] && BINDIR="/usr/bin" +if [[ -z "$PREFIX" ]]; then + [[ -z "$BINDIR" ]] && BINDIR="/usr/bin" + [[ -z "$ASCIIDIR" ]] && ASCIIDIR="/usr/share/neofetch/ascii/distro" + [[ -z "$MANDIR" ]] && MANDIR="/usr/share/man/man1" +else + [[ -z "$BINDIR" ]] && BINDIR="/bin" + [[ -z "$ASCIIDIR" ]] && ASCIIDIR="/share/neofetch/ascii/distro" + [[ -z "$MANDIR" ]] && MANDIR="/share/man/man1" +fi [[ -z "$CONFDIR" ]] && CONFDIR="/etc/neofetch" -[[ -z "$ASCIIDIR" ]] && ASCIIDIR="/usr/share/neofetch/ascii/distro" -[[ -z "$MANDIR" ]] && MANDIR="/usr/share/man/man1" mkdir -p "${DESTDIR}""${PREFIX}""${BINDIR}" mkdir -p "${DESTDIR}""${PREFIX}""${CONFDIR}" From 29ae56d87abadfe28bde9ddbf0a08eccbc853386 Mon Sep 17 00:00:00 2001 From: Muhammad Herdiansyah Date: Tue, 20 Jun 2017 18:39:35 +0700 Subject: [PATCH 3/6] Misc: Delete the leading slash --- install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 1daf9901..9b9975cd 100755 --- a/install.sh +++ b/install.sh @@ -28,8 +28,8 @@ mkdir -p "${DESTDIR}""${PREFIX}""${CONFDIR}" mkdir -p "${DESTDIR}""${PREFIX}""${ASCIIDIR}" mkdir -p "${DESTDIR}""${PREFIX}""${MANDIR}" -sed -i -e "s|CONFDIR|/${PREFIX}${CONFDIR}|g" neofetch -sed -i -e "s|ASCIIDIR|/${PREFIX}${ASCIIDIR}|g" neofetch +sed -i -e "s|CONFDIR|${PREFIX}${CONFDIR}|g" neofetch +sed -i -e "s|ASCIIDIR|${PREFIX}${ASCIIDIR}|g" neofetch cp -p neofetch "${DESTDIR}""${PREFIX}""${BINDIR}" cp -p config/config "${DESTDIR}""${PREFIX}""${CONFDIR}" From 062dbcda9ab588cd74bc9583b5676494e74c8069 Mon Sep 17 00:00:00 2001 From: Muhammad Herdiansyah Date: Sat, 24 Jun 2017 23:44:55 +0700 Subject: [PATCH 4/6] Installscript: Use POSIX-compliant sh instead of bash --- install.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/install.sh b/install.sh index 9b9975cd..ed2af281 100755 --- a/install.sh +++ b/install.sh @@ -1,6 +1,6 @@ -#!/usr/bin/env bash +#!/bin/sh -while [[ "$1" ]]; do +while [ "$1" ]; do case "$1" in "--destdir") DESTDIR="$2" ;; "--bindir") BINDIR="$2" ;; @@ -12,16 +12,16 @@ while [[ "$1" ]]; do shift done -if [[ -z "$PREFIX" ]]; then - [[ -z "$BINDIR" ]] && BINDIR="/usr/bin" - [[ -z "$ASCIIDIR" ]] && ASCIIDIR="/usr/share/neofetch/ascii/distro" - [[ -z "$MANDIR" ]] && MANDIR="/usr/share/man/man1" +if [ -z "$PREFIX" ]; then + [ -z "$BINDIR" ] && BINDIR="/usr/bin" + [ -z "$ASCIIDIR" ] && ASCIIDIR="/usr/share/neofetch/ascii/distro" + [ -z "$MANDIR" ] && MANDIR="/usr/share/man/man1" else - [[ -z "$BINDIR" ]] && BINDIR="/bin" - [[ -z "$ASCIIDIR" ]] && ASCIIDIR="/share/neofetch/ascii/distro" - [[ -z "$MANDIR" ]] && MANDIR="/share/man/man1" + [ -z "$BINDIR" ] && BINDIR="/bin" + [ -z "$ASCIIDIR" ] && ASCIIDIR="/share/neofetch/ascii/distro" + [ -z "$MANDIR" ] && MANDIR="/share/man/man1" fi -[[ -z "$CONFDIR" ]] && CONFDIR="/etc/neofetch" +[ -z "$CONFDIR" ] && CONFDIR="/etc/neofetch" mkdir -p "${DESTDIR}""${PREFIX}""${BINDIR}" mkdir -p "${DESTDIR}""${PREFIX}""${CONFDIR}" From ca78d52d5fcc9cd8da9755a27aacadda9783aefd Mon Sep 17 00:00:00 2001 From: Muhammad Herdiansyah Date: Wed, 28 Jun 2017 02:00:14 +0700 Subject: [PATCH 5/6] Misc: Remove comments --- neofetch | 2 -- 1 file changed, 2 deletions(-) diff --git a/neofetch b/neofetch index 1627499f..d11b4461 100755 --- a/neofetch +++ b/neofetch @@ -2171,7 +2171,6 @@ get_ascii() { [[ "$image_source" =~ \.(png|jpg|jpe|jpeg|gif)$ ]] && \ err "Image: Source is image file but ascii backend was selected. Using distro ascii." - # Note: ASCIIDIR here is a placeholder -- it will be replaced with your ASCII directory. if [[ -d "ASCIIDIR" ]]; then ascii_dir="ASCIIDIR" else @@ -3556,7 +3555,6 @@ get_full_path() { } get_default_config() { - # Note: CONFDIR here is a placeholder -- it will be replaced with your configuration directory. if [[ -f "CONFDIR/config" ]]; then default_config="CONFDIR/config" else From a31a445e9f2f12343ea5e9e6e629c85a9d480770 Mon Sep 17 00:00:00 2001 From: Muhammad Herdiansyah Date: Sat, 1 Jul 2017 17:19:38 +0700 Subject: [PATCH 6/6] Installscript: Update with latest config filename --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index ed2af281..7f8fded5 100755 --- a/install.sh +++ b/install.sh @@ -32,6 +32,6 @@ sed -i -e "s|CONFDIR|${PREFIX}${CONFDIR}|g" neofetch sed -i -e "s|ASCIIDIR|${PREFIX}${ASCIIDIR}|g" neofetch cp -p neofetch "${DESTDIR}""${PREFIX}""${BINDIR}" -cp -p config/config "${DESTDIR}""${PREFIX}""${CONFDIR}" +cp -p config/config.conf "${DESTDIR}""${PREFIX}""${CONFDIR}" cp -p ascii/distro/* "${DESTDIR}""${PREFIX}""${ASCIIDIR}" cp -p neofetch.1 "${DESTDIR}""${PREFIX}""${MANDIR}"