2024-09-17 13:40:50 +02:00
|
|
|
#!/usr/bin/env nu
|
|
|
|
|
2024-09-17 22:09:16 +02:00
|
|
|
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'
|
2024-09-21 15:54:02 +02:00
|
|
|
let current = mpc --host $mpdHost current
|
2024-09-17 22:09:16 +02:00
|
|
|
|
2024-09-17 13:40:50 +02:00
|
|
|
def notify [message: string] {
|
2024-09-17 22:09:16 +02:00
|
|
|
do { mpc --host $mpdHost -f "%file%" current | xargs -I{} mpc --host $mpdHost albumart {} } | save -f /tmp/mpc_current.png
|
2024-09-17 14:09:58 +02:00
|
|
|
notify-send "Noise" $"($message)" -i /tmp/mpc_current.png
|
2024-09-17 13:40:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Displays the currently playing song
|
|
|
|
def main [] {
|
2024-09-21 15:54:02 +02:00
|
|
|
mpc --host $mpdHost
|
|
|
|
notify $current
|
|
|
|
}
|
|
|
|
|
|
|
|
# Lists currently playing son
|
|
|
|
def "main tail" [] {
|
|
|
|
while true { mpc --host $mpdHost idle player | ignore; mpc --host partitacastellum current}
|
2024-09-17 13:40:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Skips to next song
|
|
|
|
def "main next" [] {
|
2024-09-17 22:09:16 +02:00
|
|
|
mpc --host $mpdHost next
|
2024-09-21 15:54:02 +02:00
|
|
|
notify $"Switching to:\n($current)"
|
2024-09-17 13:40:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Moves back a song in the que
|
|
|
|
def "main prev" [] {
|
2024-09-17 22:09:16 +02:00
|
|
|
mpc --host $mpdHost prev
|
2024-09-21 15:54:02 +02:00
|
|
|
notify $"Switching to:\n($current)"
|
2024-09-17 13:40:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Shuffles the current que
|
|
|
|
def "main shuffle" [] {
|
2024-09-17 22:09:16 +02:00
|
|
|
mpc --host $mpdHost shuffle
|
2024-09-17 13:40:50 +02:00
|
|
|
notify $"Shuffling que..."
|
|
|
|
}
|
|
|
|
|
|
|
|
# Stops playing the current que
|
|
|
|
def "main stop" [] {
|
2024-09-17 22:09:16 +02:00
|
|
|
mpc --host $mpdHost stop
|
|
|
|
notify $"Stopping playback of:\n(mpc --host $mpdHost toggle)"
|
2024-09-17 13:40:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Starts playing the current que
|
|
|
|
def "main start" [] {
|
2024-09-17 22:09:16 +02:00
|
|
|
mpc --host $mpdHost start
|
|
|
|
notify $"Starting playback of:\n(mpc --host $mpdHost toggle)"
|
2024-09-17 13:40:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Toggles playback of the current que
|
|
|
|
def "main toggle" [] {
|
2024-09-17 22:09:16 +02:00
|
|
|
mpc --host $mpdHost toggle
|
2024-09-21 15:54:02 +02:00
|
|
|
notify $"Toggling playback of:\n($current)"
|
|
|
|
}
|
|
|
|
|
|
|
|
def "main search" [...query: string] {
|
|
|
|
mpc --host $mpdHost search any $"(echo ...$query | str join ' ')"
|
|
|
|
}
|
|
|
|
|
|
|
|
def "main insert" [] {
|
|
|
|
$in | mpc insert --host $mpdHost
|
|
|
|
}
|
|
|
|
|
|
|
|
def "main add" [] {
|
|
|
|
$in | mpc add --host $mpdHost
|
|
|
|
}
|
|
|
|
|
|
|
|
def "main crossfade" [ time?: int ] {
|
|
|
|
match ($time | is-empty) {
|
|
|
|
true => { mpc --host $mpdHost crossfade }
|
|
|
|
false => { mpc --host $mpdHost crossfade $time }
|
|
|
|
}
|
2024-09-17 13:40:50 +02:00
|
|
|
}
|