From 2d671ea750b8bb6bac6bf6a85008d992721a3de9 Mon Sep 17 00:00:00 2001 From: Marty Sluijtman Date: Tue, 17 Sep 2024 22:09:16 +0200 Subject: [PATCH] Host option --- src/bin/noise | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/bin/noise b/src/bin/noise index cd27b5e..af6620b 100755 --- a/src/bin/noise +++ b/src/bin/noise @@ -1,47 +1,52 @@ #!/usr/bin/env nu +let configPath = $"($env.XDG_CONFIG_HOME? | default $"($env.HOME)/.config")/irs.toml" +let config = if ($configPath | path exists) { open $configPath } + +let mpdHost = $config.noise.host? | default 'localhost:6600' + def notify [message: string] { - do { mpc -f "%file%" current | xargs -I{} mpc albumart {} } | save -f /tmp/mpc_current.png + do { mpc --host $mpdHost -f "%file%" current | xargs -I{} mpc --host $mpdHost albumart {} } | save -f /tmp/mpc_current.png notify-send "Noise" $"($message)" -i /tmp/mpc_current.png } # Displays the currently playing song def main [] { - notify (mpc current) + notify (mpc --host $mpdHost current) } # Skips to next song def "main next" [] { - mpc next - notify $"Switching to:\n(mpc current)" + mpc --host $mpdHost next + notify $"Switching to:\n(mpc --host $mpdHost current)" } # Moves back a song in the que def "main prev" [] { - mpc prev - notify $"Switching to:\n(mpc current)" + mpc --host $mpdHost prev + notify $"Switching to:\n(mpc --host $mpdHost current)" } # Shuffles the current que def "main shuffle" [] { - mpc shuffle + mpc --host $mpdHost shuffle notify $"Shuffling que..." } # Stops playing the current que def "main stop" [] { - mpc stop - notify $"Stopping playback of:\n(mpc toggle)" + mpc --host $mpdHost stop + notify $"Stopping playback of:\n(mpc --host $mpdHost toggle)" } # Starts playing the current que def "main start" [] { - mpc start - notify $"Starting playback of:\n(mpc toggle)" + mpc --host $mpdHost start + notify $"Starting playback of:\n(mpc --host $mpdHost toggle)" } # Toggles playback of the current que def "main toggle" [] { - mpc toggle - notify $"Toggling playback of:\n(mpc current)" + mpc --host $mpdHost toggle + notify $"Toggling playback of:\n(mpc --host $mpdHost current)" }