From 463be0695506d60c89592dad03378b0d4168c0a6 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Thu, 1 Feb 2024 00:46:39 -0500 Subject: [PATCH] Created a uniform interface accross all session scripts --- session/src/xmd | 13 +++++++++++-- session/src/xmd-end-session | 11 ++++++++++- session/src/xmd-load-wallpaper | 1 + session/src/xmd-load-xresources | 26 +++++++++++++++++++++++--- session/src/xmd-run-startup-items | 13 +++++++++++-- 5 files changed, 56 insertions(+), 8 deletions(-) diff --git a/session/src/xmd b/session/src/xmd index 2722045..e6c4165 100755 --- a/session/src/xmd +++ b/session/src/xmd @@ -1,5 +1,14 @@ #!/bin/sh +name=`basename "$0"` + +usage() { + echo "Usage: $name" >&2 + exit 2 +} + +[ "$#" -gt 0 ] && usage + # basic Xmd environment variables export XMD_SESSION_PID="$$" export XMD_USERDIR="${HOME}/.Xmd" @@ -23,7 +32,7 @@ appDefaults="${XMD_USERDIR}/app-defaults" if [ -d "$appDefaults" ]; then export XAPPLRESDIR="$appDefaults" else - echo "!!! cant find $appDefaults" + echo "$name cant find $appDefaults" >&2 fi xmd-load-wallpaper @@ -33,7 +42,7 @@ if [ -d "$startupDir" ]; then export XMD_STARTUPDIR="$startupDir" xmd-run-startup-items else - echo "!!! cant find $startupDir" + echo "$name cant find $startupDir" >&2 fi sleep infinity diff --git a/session/src/xmd-end-session b/session/src/xmd-end-session index cb0c4da..6604dff 100755 --- a/session/src/xmd-end-session +++ b/session/src/xmd-end-session @@ -1,7 +1,16 @@ #!/bin/sh +name=`basename "$0"` + +usage() { + echo "Usage: $name" >&2 + exit 2 +} + +[ "$#" -gt 0 ] && usage + if [ -z "$XMD_SESSION_PID" ]; then - echo "ERR session is not running (\$XMD_SESSION_PID not set)" + echo "$name: session is not running (\$XMD_SESSION_PID not set)" >&2 exit 1 fi diff --git a/session/src/xmd-load-wallpaper b/session/src/xmd-load-wallpaper index 5ebef03..8c24e63 100755 --- a/session/src/xmd-load-wallpaper +++ b/session/src/xmd-load-wallpaper @@ -21,6 +21,7 @@ usage() { [ "$#" -gt 0 ] && usage +echo $configFilePath if type "$configFilePath" > /dev/null; then color="black" diff --git a/session/src/xmd-load-xresources b/session/src/xmd-load-xresources index f7feb0a..6d0b4a2 100755 --- a/session/src/xmd-load-xresources +++ b/session/src/xmd-load-xresources @@ -1,10 +1,30 @@ #!/bin/sh -xrdb -remove - +name=`basename "$0"` xResources="${XMD_USERDIR}/Xresources" + +isInstalled() { + type "$1" > /dev/null +} + +mustHaveInstalled() { + if ! isInstalled "$1"; then + echo "$name: $1 is not installed" >&2 + exit 1 + fi +} + +usage() { + echo "Usage: $name" >&2 + exit 2 +} + +[ "$#" -gt 0 ] && usage + +cd ~ if [ -r "$xResources" ]; then + mustHaveInstalled xrdb xrdb -cpp /usr/bin/cpp < "$xResources" else - echo "!!! can't find $xResources" + echo "$name: can't find $xResources" >&2 fi diff --git a/session/src/xmd-run-startup-items b/session/src/xmd-run-startup-items index 9cb94c9..e9d7955 100755 --- a/session/src/xmd-run-startup-items +++ b/session/src/xmd-run-startup-items @@ -1,10 +1,19 @@ #!/bin/sh +name=`basename "$0"` + +usage() { + echo "Usage: $name" >&2 + exit 2 +} + +[ "$#" -gt 0 ] && usage + if [ -z "$XMD_STARTUPDIR" ]; then - echo "!!! \$XMD_STARTUPDIR not set" + echo "$name \$XMD_STARTUPDIR not set" >&2 exit 1 fi -for item in $XMD_STARTUPDIR/*; do +for item in "$XMD_STARTUPDIR"/*; do if [ -x "$item" ]; then "$item" & fi