aboutsummaryrefslogtreecommitdiff
path: root/bin/player
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2024-01-04 11:23:50 -0300
committerEuAndreh <eu@euandre.org>2024-01-04 11:23:55 -0300
commit07455024c72c3aa0bacf8338b82d3a0b8a96a9b0 (patch)
treec3e7074928e2783d9e97001f45e2a3522d52ba76 /bin/player
parentetc/sh/rc: Fix "c" alias to use the correct command (diff)
downloaddotfiles-07455024c72c3aa0bacf8338b82d3a0b8a96a9b0.tar.gz
dotfiles-07455024c72c3aa0bacf8338b82d3a0b8a96a9b0.tar.xz
re "s|echo \"\\\$|printf '%s\\\n' \"\$|g"
Replace all cases where `echo` was given a variable as its first argument, even on cases where we always know what the variable's content look like.
Diffstat (limited to 'bin/player')
-rwxr-xr-xbin/player14
1 files changed, 7 insertions, 7 deletions
diff --git a/bin/player b/bin/player
index b83e8c0..129942e 100755
--- a/bin/player
+++ b/bin/player
@@ -83,24 +83,24 @@ CURRENT_PLAYER="$(cat "$CURRENT_PLAYER_PATH" ||:)"
AVAILABLE_PLAYERS="$(playerctl --list-all | LANG=POSIX.UTF-8 sort)"
pick_first() {
- echo "$AVAILABLE_PLAYERS" | head -n1
+ printf '%s\n' "$AVAILABLE_PLAYERS" | head -n1
}
next_player() {
if [ -z "$CURRENT_PLAYER" ]; then
pick_first
- elif ! echo "$AVAILABLE_PLAYERS" | grep -q "$CURRENT_PLAYER"; then
+ elif ! printf '%s\n' "$AVAILABLE_PLAYERS" | grep -q "$CURRENT_PLAYER"; then
# Unknown $CURRENT_PLAYER, pick anyone
pick_first
else
- INDEX="$(echo "$AVAILABLE_PLAYERS" | grep -n "$CURRENT_PLAYER" | cut -d: -f1)"
- LENGTH="$(echo "$AVAILABLE_PLAYERS" | wc -l)"
+ INDEX="$(printf '%s\n' "$AVAILABLE_PLAYERS" | grep -n "$CURRENT_PLAYER" | cut -d: -f1)"
+ LENGTH="$(printf '%s\n' "$AVAILABLE_PLAYERS" | wc -l)"
if [ "$INDEX" = "$LENGTH" ]; then
# Reached the end of the $AVAILABLE_PLAYERS list, wrapping
pick_first
else
# Get the next player instead
- echo "$AVAILABLE_PLAYERS" | awk -v idx="$INDEX" 'NR == idx+1 {print}'
+ printf '%s\n' "$AVAILABLE_PLAYERS" | awk -v idx="$INDEX" 'NR == idx+1 {print}'
fi
fi
}
@@ -146,14 +146,14 @@ case "$ACTION" in
;;
rotate)
PLAYER="$(next_player)"
- echo "$PLAYER" > "$CURRENT_PLAYER_PATH"
+ printf '%s\n' "$PLAYER" > "$CURRENT_PLAYER_PATH"
notify-send -t 1000 -- \
"$(printf '%s' "$PLAYER" | format_player_name)" \
'current MPRIS target'
;;
synopsis)
printf '%s: %s\n' \
- "$(echo "$CURRENT_PLAYER" | format_player_name)" \
+ "$(printf '%s\n' "$CURRENT_PLAYER" | format_player_name)" \
"$(formatted_player_title)"
;;
*)