Regenerated
This commit is contained in:
+343
-346
File diff suppressed because it is too large
Load Diff
+6
-9
@@ -3109,21 +3109,16 @@ ShellRoot {
|
||||
** =generated/.config/scripts/media.sh=
|
||||
Providing an media
|
||||
#+BEGIN_SRC sh :tangle generated/.config/scripts/media.sh :shebang "#!/usr/bin/env bash" :noweb yes :mkdirp yes :eval never
|
||||
#!/usr/bin/env bash
|
||||
player=$(playerctl -l 2>/dev/null | head -n1)
|
||||
|
||||
if [ -z "$player" ]; then
|
||||
jq -c -n '{text: "", tooltip: "", class: "inactive"}'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
status=$(playerctl --player="$player" status 2>/dev/null)
|
||||
|
||||
if [ "$status" != "Playing" ] && [ "$status" != "Paused" ]; then
|
||||
jq -c -n '{text: "", tooltip: "", class: "inactive"}'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
artist=$(playerctl --player="$player" metadata artist 2>/dev/null)
|
||||
title=$(playerctl --player="$player" metadata title 2>/dev/null)
|
||||
album=$(playerctl --player="$player" metadata album 2>/dev/null)
|
||||
@@ -3131,9 +3126,11 @@ art=$(playerctl --player="$player" metadata mpris:artUrl 2>/dev/null)
|
||||
length=$(playerctl --player="$player" metadata mpris:length 2>/dev/null)
|
||||
position=$(playerctl --player="$player" position 2>/dev/null)
|
||||
|
||||
# Progress percentage
|
||||
if [ -n "$length" ] && [ "$length" -gt 0 ] 2>/dev/null; then
|
||||
progress=$(echo "scale=0; $position * 1000000 / $length * 100 / 100" | bc)
|
||||
# Progress percentage — pure bash, no bc needed
|
||||
if [ -n "$length" ] && [ -n "$position" ] && [ "$length" -gt 0 ] 2>/dev/null; then
|
||||
# position is in seconds (float), length is in microseconds
|
||||
pos_us=$(echo "$position" | awk '{printf "%d", $1 * 1000000}')
|
||||
progress=$(( pos_us * 100 / length ))
|
||||
else
|
||||
progress=0
|
||||
fi
|
||||
@@ -3162,7 +3159,7 @@ tooltip="${artist}\n${title}\n${album}"
|
||||
if [ -n "$device" ]; then
|
||||
tooltip="${tooltip}\n ${device}"
|
||||
fi
|
||||
tooltip="${tooltip}\n$(printf '%.0f' "$progress")%"
|
||||
tooltip="${tooltip}\n${progress}%"
|
||||
|
||||
jq -c -n \
|
||||
--arg text "${icon}${text}" \
|
||||
|
||||
@@ -1,20 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
# --- This file has been auto-generated. For permanent changes alter the appropriate block in the README.org. ---
|
||||
#!/usr/bin/env bash
|
||||
player=$(playerctl -l 2>/dev/null | head -n1)
|
||||
|
||||
if [ -z "$player" ]; then
|
||||
jq -c -n '{text: "", tooltip: "", class: "inactive"}'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
status=$(playerctl --player="$player" status 2>/dev/null)
|
||||
|
||||
if [ "$status" != "Playing" ] && [ "$status" != "Paused" ]; then
|
||||
jq -c -n '{text: "", tooltip: "", class: "inactive"}'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
artist=$(playerctl --player="$player" metadata artist 2>/dev/null)
|
||||
title=$(playerctl --player="$player" metadata title 2>/dev/null)
|
||||
album=$(playerctl --player="$player" metadata album 2>/dev/null)
|
||||
@@ -22,9 +17,11 @@ art=$(playerctl --player="$player" metadata mpris:artUrl 2>/dev/null)
|
||||
length=$(playerctl --player="$player" metadata mpris:length 2>/dev/null)
|
||||
position=$(playerctl --player="$player" position 2>/dev/null)
|
||||
|
||||
# Progress percentage
|
||||
if [ -n "$length" ] && [ "$length" -gt 0 ] 2>/dev/null; then
|
||||
progress=$(echo "scale=0; $position * 1000000 / $length * 100 / 100" | bc)
|
||||
# Progress percentage — pure bash, no bc needed
|
||||
if [ -n "$length" ] && [ -n "$position" ] && [ "$length" -gt 0 ] 2>/dev/null; then
|
||||
# position is in seconds (float), length is in microseconds
|
||||
pos_us=$(echo "$position" | awk '{printf "%d", $1 * 1000000}')
|
||||
progress=$(( pos_us * 100 / length ))
|
||||
else
|
||||
progress=0
|
||||
fi
|
||||
@@ -53,7 +50,7 @@ tooltip="${artist}\n${title}\n${album}"
|
||||
if [ -n "$device" ]; then
|
||||
tooltip="${tooltip}\n ${device}"
|
||||
fi
|
||||
tooltip="${tooltip}\n$(printf '%.0f' "$progress")%"
|
||||
tooltip="${tooltip}\n${progress}%"
|
||||
|
||||
jq -c -n \
|
||||
--arg text "${icon}${text}" \
|
||||
|
||||
Reference in New Issue
Block a user