]> glassweightruler.freedombox.rocks Git - xdg-ninja.git/blobdiff - xdg-ninja.sh
Check for missing XDG vars
[xdg-ninja.git] / xdg-ninja.sh
index 5fd12615f654adbd6a4914669f982cbd0a0aa0f7..20695582af077a8ad02b06dc76a44bd3ab905215 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 USE_GLOW=true
 if ! command -v glow &>/dev/null; then
@@ -43,6 +43,27 @@ for i in "$@"; do
     fi
 done
 
+if [[ -z "${XDG_DATA_HOME}" ]]; then
+    printf '\e[1;36m%s\e[1;0m\n' "The \$XDG_DATA_HOME enviornment variable is not set, make sure to add it to your shell's configuration before setting any of the other enviornment variables!"
+    printf '\e[1;36m    ⤷ \e[1mThe recommended value is: \e[1;3m$HOME/.local/share\e[1;0m\n'
+fi
+if [[ -z "${XDG_CONFIG_HOME}" ]]; then
+    printf '\e[1;36m%s\e[1;0m\n' "The \$XDG_CONFIG_HOME enviornment variable is not set, make sure to add it to your shell's configuration before setting any of the other enviornment variables!"
+    printf '\e[1;36m    ⤷ \e[1mThe recommended value is: \e[1;3m$HOME/.config\e[1;0m\n'
+fi
+if [[ -z "${XDG_STATE_HOME}" ]]; then
+    printf '\e[1;36m%s\e[1;0m\n' "The \$XDG_STATE_HOME enviornment variable is not set, make sure to add it to your shell's configuration before setting any of the other enviornment variables!"
+    printf '\e[1;36m    ⤷ \e[1mThe recommended value is: \e[1;3m$HOME/.local/state\e[1;0m\n'
+fi
+if [[ -z "${XDG_CACHE_HOME}" ]]; then
+    printf '\e[1;36m%s\e[1;0m\n' "The \$XDG_CACHE_HOME enviornment variable is not set, make sure to add it to your shell's configuration before setting any of the other enviornment variables!"
+    printf '\e[1;36m    ⤷ \e[1mThe recommended value is: \e[1;3m$HOME/.cache\e[1;0m\n'
+fi
+if [[ -z "${XDG_RUNTIME_DIR}" ]]; then
+    printf '\e[1;36m%s\e[1;0m\n' "The \$XDG_RUNTIME_DIR enviornment variable is not set, make sure to add it to your shell's configuration before setting any of the other enviornment variables!"
+    printf '\e[1;36m    ⤷ \e[1mThe recommended value is: \e[1;3m/run/user/$UID\e[1;0m\n'
+fi
+
 if ! command -v jq &>/dev/null; then
     echo "jq is needed to run this script, but it wasn't found. Please install it to be able to use this script."
     exit
@@ -155,7 +176,7 @@ check_program() {
 enumerate_programs() {
     echo -e "\e[1;3mStarting to check your \e[1;36m\$HOME.\e[1;0m"
     echo -e ""
-    for prog_filename in ./programs/*; do
+       for prog_filename in "$(dirname "${BASH_SOURCE[0]}")"/programs/*; do
         check_program "$(cat "$prog_filename")"
     done
     echo -e "\e[1;3mDone checking your \e[1;36m\$HOME.\e[1;0m"