about summary refs log tree commit diff stats
path: root/modules/by-name/i3/i3status-rust/scripts/mpd_song_name.sh
blob: 28921520f3bedff01bcdc998159c901faa03a8f1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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