Skip to content

Commit

Permalink
Use Homebrew bash, sed, mktemp on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
doctorfree committed Jun 27, 2024
1 parent 185fa55 commit e102e8c
Show file tree
Hide file tree
Showing 67 changed files with 204 additions and 156 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ The Asciiville project includes many curated Ascii Art galleries.
These include hundreds of high resolution Ascii Art files created
by Asciiville author and artist, Dr. Ronald Joe Record. The Asciiville
package, when installed, provides the following Ascii Art galleries
located in the default Ascii Art Gallery folder `/usr/share/asciiville/art/`:
located in the default Ascii Art Gallery folder `/usr/share/asciiville/art/`
(`/usr/local/share/asciiville/art/` on `macOS`):

```
Art - A collection of fine art transformed into Ascii Art
Expand Down
2 changes: 1 addition & 1 deletion bin/any2ascii
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#
## @file any2ascii
## @brief Convert from any audio/video or image format to Ascii
Expand Down
2 changes: 1 addition & 1 deletion bin/asciibrow
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#
# asciibrow - frontend using mpv/socli/w3m for opening urls
#
Expand Down
2 changes: 1 addition & 1 deletion bin/asciisplash
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#
# asciisplash - display Asciiville splash screens using ASCIImatics
#
Expand Down
88 changes: 50 additions & 38 deletions bin/asciiville
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# _ _ _ _ __ __
# / \ (_) (_) (_) [ | [ |
# / _ \ .--. .---. __ __ _ __ __ | | | | .---.
Expand Down Expand Up @@ -93,11 +93,11 @@ CONFIG="${HOME}/.config/asciiville/config"

# Backwards compatibility with older Asciiville config
[ -d "${ARTDIR}" ] || {
LOC_ARTDIR=$(echo "${ARTDIR}" | sed -e "s%/usr/%/usr/local/%")
LOC_ARTDIR=$(echo "${ARTDIR}" | ${SED} -e "s%/usr/%/usr/local/%")
[ -d "${LOC_ARTDIR}" ] && ARTDIR="${LOC_ARTDIR}"
}
[ -d "${MUSEDIR}" ] || {
LOC_MUSEDIR=$(echo "${MUSEDIR}" | sed -e "s%/usr/%/usr/local/%")
LOC_MUSEDIR=$(echo "${MUSEDIR}" | ${SED} -e "s%/usr/%/usr/local/%")
[ -d "${LOC_MUSEDIR}" ] && MUSEDIR="${LOC_MUSEDIR}"
}
saved_art_size=${art_font_size}
Expand Down Expand Up @@ -702,7 +702,7 @@ add_fullscreen() {
[ "${have_wmctrl}" ] && {
[ "${have_xprop}" ] && {
# The things a man must do
win_id=$(wmctrl -lp | grep $(xprop -root | grep _NET_ACTIVE_WINDOW | head -1 | awk '{print $5}' | sed 's/,//' | sed 's/^0x/0x0/') | awk ' { print $1 } ')
win_id=$(wmctrl -lp | grep $(xprop -root | grep _NET_ACTIVE_WINDOW | head -1 | awk '{print $5}' | ${SED} 's/,//' | ${SED} 's/^0x/0x0/') | awk ' { print $1 } ')
[ "${win_id}" ] && xprop -id ${win_id} | grep _NET_WM_STATE | grep FULLSCREEN >/dev/null && isfull=1
}
[ "${isfull}" ] || {
Expand Down Expand Up @@ -777,10 +777,10 @@ show_art_file() {
num_exp='^[0-9]+$'
termname=unknown
myppid=$(ps -e | grep ${PPID} | awk ' { print $1 } ')
myppid=$(echo ${myppid} | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
myppid=$(echo ${myppid} | ${SED} -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
if [[ ${myppid} =~ ${num_exp} ]]; then
parent=$(ps -o ppid= -p ${myppid})
parent=$(echo ${parent} | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
parent=$(echo ${parent} | ${SED} -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
if [[ ${parent} =~ ${num_exp} ]]; then
termname=$(ps -e | grep ${parent} | awk ' { print $4 } ')
fi
Expand Down Expand Up @@ -883,10 +883,10 @@ play_show() {
num_exp='^[0-9]+$'
termname=unknown
myppid=$(ps -e | grep ${PPID} | awk ' { print $1 } ')
myppid=$(echo ${myppid} | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
myppid=$(echo ${myppid} | ${SED} -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
if [[ ${myppid} =~ ${num_exp} ]]; then
parent=$(ps -o ppid= -p ${myppid})
parent=$(echo ${parent} | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
parent=$(echo ${parent} | ${SED} -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
if [[ ${parent} =~ ${num_exp} ]]; then
termname=$(ps -e | grep ${parent} | awk ' { print $4 } ')
fi
Expand Down Expand Up @@ -2414,7 +2414,7 @@ show_art_menu() {
break
;;
*"Art Slideshow",* | *,*"Art Slideshow")
gallery_name=$(echo ${opt} | sed -e "s/ Art Slideshow//")
gallery_name=$(echo ${opt} | ${SED} -e "s/ Art Slideshow//")
play_slide_show "${gallery_name}"
break
;;
Expand Down Expand Up @@ -2488,8 +2488,8 @@ show_art_menu() {
fi
audarg="-P -S ${SONG}"
else
ASCSPLASH=$(echo ${ASCSPLASH} | sed -e "s# -a##" -e "s# -s ${SONG}##")
ASCSPLASH_TMUX=$(echo ${ASCSPLASH_TMUX} | sed -e "s# -a##" -e "s# -s ${SONG}##")
ASCSPLASH=$(echo ${ASCSPLASH} | ${SED} -e "s# -a##" -e "s# -s ${SONG}##")
ASCSPLASH_TMUX=$(echo ${ASCSPLASH_TMUX} | ${SED} -e "s# -a##" -e "s# -s ${SONG}##")
audarg=
fi
break
Expand Down Expand Up @@ -2540,7 +2540,7 @@ show_art_menu() {
if [ "${RECORD}" ]; then
ASCSPLASH_TMUX="${ASCSPLASH_TMUX} -R"
else
ASCSPLASH_TMUX=$(echo ${ASCSPLASH_TMUX} | sed -e "s/ -R//")
ASCSPLASH_TMUX=$(echo ${ASCSPLASH_TMUX} | ${SED} -e "s/ -R//")
fi
break
;;
Expand Down Expand Up @@ -2784,20 +2784,20 @@ show_animation_menu() {
export DISPLAY=""
if [ "${AUDIO}" ]; then
if [ "${custom_song}" ]; then
bash ${TOOLSBIN}/bb-tmux -a -s "${SONG}"
${BASH} ${TOOLSBIN}/bb-tmux -a -s "${SONG}"
else
bash ${TOOLSBIN}/bb-tmux -a
${BASH} ${TOOLSBIN}/bb-tmux -a
fi
else
bash ${TOOLSBIN}/bb-tmux
${BASH} ${TOOLSBIN}/bb-tmux
fi
skip_it_so=1
export DISPLAY="${SAVED_DISPLAY}"
break
;;
"Fluid"*,* | *,"Fluid"*)
COMMAND="bash -m ${TOP}/bin/show_endo"
COMMAND_TMUX="bash -m ${TOP}/bin/show_endo"
COMMAND="${BASH} -m ${TOP}/bin/show_endo"
COMMAND_TMUX="${BASH} -m ${TOP}/bin/show_endo"
ASCSPLASH="${COMMAND}"
ASCSPLASH_TMUX="${COMMAND_TMUX}"
# trap -- '' SIGINT
Expand Down Expand Up @@ -2925,8 +2925,8 @@ show_animation_menu() {
fi
audarg="-P -S ${SONG}"
else
ASCSPLASH=$(echo ${ASCSPLASH} | sed -e "s# -a##" -e "s# -s ${SONG}##")
ASCSPLASH_TMUX=$(echo ${ASCSPLASH_TMUX} | sed -e "s# -a##" -e "s# -s ${SONG}##")
ASCSPLASH=$(echo ${ASCSPLASH} | ${SED} -e "s# -a##" -e "s# -s ${SONG}##")
ASCSPLASH_TMUX=$(echo ${ASCSPLASH_TMUX} | ${SED} -e "s# -a##" -e "s# -s ${SONG}##")
audarg=
fi
skip_it_so=1
Expand All @@ -2942,7 +2942,7 @@ show_animation_menu() {
if [ "${RECORD}" ]; then
ASCSPLASH_TMUX="${ASCSPLASH_TMUX} -R"
else
ASCSPLASH_TMUX=$(echo ${ASCSPLASH_TMUX} | sed -e "s/ -R//")
ASCSPLASH_TMUX=$(echo ${ASCSPLASH_TMUX} | ${SED} -e "s/ -R//")
fi
skip_it_so=1
break
Expand Down Expand Up @@ -3092,7 +3092,7 @@ show_journal_menu() {
uses_tilda=
[ "${first}" == "~" ] && {
uses_tilda=1
jloc=$(echo ${jloc} | sed -e "s/~//")
jloc=$(echo ${jloc} | ${SED} -e "s/~//")
}
if [ "${uses_tilda}" ]; then
file ${HOME}${jloc} | grep -i terminator >/dev/null && encrypted=1
Expand Down Expand Up @@ -3354,9 +3354,13 @@ show_main_menu() {
[ "${have_bb}" ] && options+=("AAlib Demo (Curses) [c]")
[ "${have_mapscii}" ] && options+=("Mapscii World Map [w]")
[ "${have_curl}" ] && options+=("Phase of the Moon [p]")
options+=("Run ${show_comm} in ${show_term} [C]")
if [ "${show_term}" == "Current" ]; then
options+=("Run ${show_comm} in ${show_term} [C]")
else
options+=("Run ${show_comm} in ${show_term} [C]")
fi
[ "${have_ddgr}" ] && options+=("Search the Web [s]")
[ "${have_curl}" ] && [ -x ${TOOLSBIN}/pokefetch ] && {
[ "${have_curl}" ] && [ -f ${TOOLSBIN}/pokefetch ] && {
check_display
[ $? -eq 0 ] && options+=("Show a Pokemon [P]")
}
Expand Down Expand Up @@ -3498,19 +3502,19 @@ show_main_menu() {
SAVED_DISPLAY="${DISPLAY}"
export DISPLAY=""
if [ "${AUDIO}" ]; then
bash ${TOOLSBIN}/bb-tmux -a
${BASH} ${TOOLSBIN}/bb-tmux -a
else
bash ${TOOLSBIN}/bb-tmux
${BASH} ${TOOLSBIN}/bb-tmux
fi
skip_it_so=1
export DISPLAY="${SAVED_DISPLAY}"
break
;;
"AAlib Demo (X11)",* | *,"AAlib Demo (X11)" | "x",* | *,"x")
if [ "${AUDIO}" ]; then
bash ${TOOLSBIN}/bb-tmux -a
${BASH} ${TOOLSBIN}/bb-tmux -a
else
bash ${TOOLSBIN}/bb-tmux
${BASH} ${TOOLSBIN}/bb-tmux
fi
skip_it_so=1
break
Expand All @@ -3522,7 +3526,7 @@ show_main_menu() {
break
;;
"Show a Pok"*,* | *,"Show a Pok"* | "P",* | *,"P")
${TOOLSBIN}/pokefetch
${BASH} -c ${TOOLSBIN}/pokefetch
read -p "Press Enter to continue" answer
skip_it_so=1
break
Expand Down Expand Up @@ -3551,7 +3555,7 @@ show_main_menu() {
break
;;
"Mapscii"*,* | *,"Mapscii"* | "w",* | *,"w")
mapscii
mapscii 2>/dev/null
skip_it_so=1
break
;;
Expand Down Expand Up @@ -3646,7 +3650,7 @@ show_main_menu() {
if [ "${RECORD}" ]; then
COMMAND_TMUX="${COMMAND_TMUX} -r"
else
COMMAND_TMUX=$(echo ${COMMAND_TMUX} | sed -e "s/ -r//")
COMMAND_TMUX=$(echo ${COMMAND_TMUX} | ${SED} -e "s/ -r//")
fi
skip_it_so=1
break
Expand All @@ -3667,8 +3671,8 @@ show_main_menu() {
fi
audarg="-P -S ${SONG}"
else
ASCSPLASH=$(echo ${ASCSPLASH} | sed -e "s# -a##" -e "s# -s ${SONG}##")
ASCSPLASH_TMUX=$(echo ${ASCSPLASH_TMUX} | sed -e "s# -a##" -e "s# -s ${SONG}##")
ASCSPLASH=$(echo ${ASCSPLASH} | ${SED} -e "s# -a##" -e "s# -s ${SONG}##")
ASCSPLASH_TMUX=$(echo ${ASCSPLASH_TMUX} | ${SED} -e "s# -a##" -e "s# -s ${SONG}##")
audarg=
fi
skip_it_so=1
Expand Down Expand Up @@ -3974,9 +3978,9 @@ set_show_term() {

init_vars() {
MTITLE="Asciiville"
COMMAND_TMUX="bash ${TOOLSBIN}/btop-tmux"
COMMAND_TMUX="${BASH} ${TOOLSBIN}/btop-tmux"
ASCSPLASH="asciisplash"
ASCSPLASH_TMUX="bash ${TOOLSBIN}/asciisplash-tmux"
ASCSPLASH_TMUX="${BASH} ${TOOLSBIN}/asciisplash-tmux"
[ "${AUDIO}" ] && [ "${have_mplayer}" ] && {
ASCSPLASH="${ASCSPLASH} -a"
ASCSPLASH_TMUX="${ASCSPLASH_TMUX} -a"
Expand Down Expand Up @@ -4035,6 +4039,14 @@ have_tilix=$(type -p tilix)
VENV_DIR="${HOME}/.venv"
[ -f ${VENV_DIR}/bin/activate ] && source ${VENV_DIR}/bin/activate

BASH=bash
SED=sed
[ "${darwin}" ] && {
have_gsed=$(type -p gsed)
[ "${have_gsed}" ] && SED=gsed
[ -x /opt/homebrew/bin/bash ] && BASH=/opt/homebrew/bin/bash
}

FULLSCREEN=
init_vars
# Without any arguments, bring up interactive dialog menu
Expand Down Expand Up @@ -4233,11 +4245,11 @@ while getopts "Aabc:CdD:E:fFgGiIjJkKlL:mMn:NpP:rRSs:tTUvV:wWxXyYzZu" flag; do
COMMAND="${OPTARG}"
case "${COMMAND}" in
endo | Endo)
[ "${have_endo}" ] && bash -m ${TOP}/bin/show_endo
[ "${have_endo}" ] && ${BASH} -m ${TOP}/bin/show_endo
exit 0
;;
maps | Maps)
[ "${have_mapscii}" ] && mapscii
[ "${have_mapscii}" ] && mapscii 2>/dev/null
exit 0
;;
moon | Moon)
Expand Down Expand Up @@ -4271,8 +4283,8 @@ while getopts "Aabc:CdD:E:fFgGiIjJkKlL:mMn:NpP:rRSs:tTUvV:wWxXyYzZu" flag; do
check_display
[ $? -eq 0 ] && {
[ "${have_curl}" ] && {
[ -x ${TOOLSBIN}/pokefetch ] && {
${TOOLSBIN}/pokefetch
[ -f ${TOOLSBIN}/pokefetch ] && {
${BASH} -c ${TOOLSBIN}/pokefetch
exit 0
}
}
Expand Down
Loading

0 comments on commit e102e8c

Please sign in to comment.