about summary refs log tree commit diff stats
path: root/modules/by-name/i3/i3status-rust/scripts
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-05-20 21:22:09 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-05-20 21:22:09 +0200
commitfd9177b6cc728115999fb78e1266108210b2cb6d (patch)
tree184a4b2ca5879fd70ea94229f817ef5b8c09fd2d /modules/by-name/i3/i3status-rust/scripts
parentpkgs/{i3bar-river,i3status-rust}: Init (diff)
downloadnixos-config-fd9177b6cc728115999fb78e1266108210b2cb6d.zip
modules/{i3bar-river,i3status-rust}: Init
Diffstat (limited to '')
-rwxr-xr-xmodules/by-name/i3/i3status-rust/scripts/mpd_song_name.sh32
1 files changed, 32 insertions, 0 deletions
diff --git a/modules/by-name/i3/i3status-rust/scripts/mpd_song_name.sh b/modules/by-name/i3/i3status-rust/scripts/mpd_song_name.sh
new file mode 100755
index 00000000..28921520
--- /dev/null
+++ b/modules/by-name/i3/i3status-rust/scripts/mpd_song_name.sh
@@ -0,0 +1,32 @@
+#!/usr/bin/env dash
+
+# nixos-config - My current NixOS configuration
+#
+# Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+# This file is part of my nixos-config.
+#
+# You should have received a copy of the License along with this program.
+# If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
+
+while true; do
+    state="$(mpc status '%state%')"
+
+    if [ "$state" = "playing" ]; then
+        song="$(mpc --format '[[%artist% - ]%title%]|[%file%]' current)"
+        progress="$(mpc status "%currenttime%/%totaltime%")"
+
+        echo "$song :: $progress"
+    else
+        # The song has stopped, we are done displaying it.
+        echo ""
+
+        # Wait for a new song. (Or in this case for a new event.)
+        mpc idle
+    fi
+
+    sleep 1
+done
+
+# vim: ft=sh