Skip to content

Commit ec45d3f

Browse files
committed
Refactor install.sh output to print dependency information for Windows WSL
1 parent 58a5a5d commit ec45d3f

File tree

1 file changed

+47
-26
lines changed

1 file changed

+47
-26
lines changed

install.sh

Lines changed: 47 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,19 @@ prefix_arg="$prefix_arg_array[-1]"
4545
help_arg="$help_arg_array[-1]"
4646
zcompdir_arg="$zcompdir_arg_array[-1]"
4747
noupdaterc_arg="$noupdaterc_arg_array[-1]"
48-
machine="$(uname -s)"
48+
unamestr="$(uname -a)"
49+
case "${unamestr}" in
50+
Linux*)
51+
if [[ "$unamestr" =~ ^.*[Mm]icrosoft.*$ ]]; then
52+
machine="WSL"
53+
else
54+
machine="Linux"
55+
fi
56+
;;
57+
Darwin*) machine="Darwin";;
58+
*BSD*) machine="BSD";;
59+
*) machine="UNKNOWN:${unamestr}";;
60+
esac
4961

5062
function printhelp {
5163
read -r -d '' VAR <<-'EOF'
@@ -259,33 +271,42 @@ if ! command -v less &>/dev/null; then
259271
echo "DEPENDS: Command 'less' not found, arttime will default to 'more'.\n Though installing 'less' is recommended for better experience."
260272
fi
261273

262-
if [[ $machine =~ ^.*(Linux|BSD).*$ ]]; then
263-
if ! command -v notify-send &>/dev/null; then
264-
echo "DEPENDS: If you want desktop notifications, you need notify-send."
265-
fi
266-
if command -v paplay &>/dev/null; then
267-
if pulseaudio --check &>/dev/null; then
268-
pulserunning="1"
269-
else
270-
pulserunning="0"
274+
case "${machine}" in
275+
"Linux"|"BSD")
276+
if ! command -v notify-send &>/dev/null; then
277+
echo "DEPENDS: If you want desktop notifications, you need notify-send."
271278
fi
272-
fi
273-
if command -v pw-play &>/dev/null; then
274-
if {pactl info 2>/dev/null | grep "Server Name" 2>/dev/null | grep "PipeWire" &>/dev/null}; then
275-
piperunning="1"
276-
else
277-
piperunning="0"
279+
if command -v paplay &>/dev/null; then
280+
if pulseaudio --check &>/dev/null; then
281+
pulserunning="1"
282+
else
283+
pulserunning="0"
284+
fi
278285
fi
279-
fi
280-
if command -v ogg123 &>/dev/null; then
281-
vorbisinstalled="1"
282-
fi
283-
if [[ $pulserunning != "1" && $piperunning != "1" && $vorbisinstalled != "1" ]]; then
284-
echo "DEPENDS: If you want desktop sounds, you need one of: 1) pulseaudio daemon\n running, or 2) pipewire daemon running, or 3) vorbis-tools."
285-
fi
286-
elif [[ $machine =~ ^Darwin.*$ ]]; then
287-
echo "Note: Notification settings on macOS are not fully in control of an application.\n To check if you have desired notification settings, open following link.\n https://github.com/poetaman/arttime/issues/11"
288-
fi
286+
if command -v pw-play &>/dev/null; then
287+
if {pactl info 2>/dev/null | grep "Server Name" 2>/dev/null | grep "PipeWire" &>/dev/null}; then
288+
piperunning="1"
289+
else
290+
piperunning="0"
291+
fi
292+
fi
293+
if command -v ogg123 &>/dev/null; then
294+
vorbisinstalled="1"
295+
fi
296+
if [[ $pulserunning != "1" && $piperunning != "1" && $vorbisinstalled != "1" ]]; then
297+
echo "DEPENDS: If you want desktop sounds, you need one of: 1) pulseaudio daemon\n running, or 2) pipewire daemon running, or 3) vorbis-tools."
298+
fi
299+
;;
300+
"Darwin")
301+
echo "Note: Notification settings on macOS are not fully in control of an application.\n To check if you have desired notification settings, open following link.\n https://github.com/poetaman/arttime/issues/11"
302+
;;
303+
"WSL")
304+
if ! command -v wsl-notify-send.exe &>/dev/null; then
305+
echo "DEPENDS: If you want desktop notifications, you need wsl-notify-send.exe\n Install it from https://github.com/stuartleeks/wsl-notify-send"
306+
fi
307+
;;
308+
*) ;;
309+
esac
289310

290311
# Check if path to arttime excutable is on user's $PATH
291312
if [[ ":$PATH:" == *":$bindir:"* ]]; then

0 commit comments

Comments
 (0)