irs/src/bin/noise

53 lines
1.3 KiB
Text
Raw Normal View History

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-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-17 22:09:16 +02:00
notify (mpc --host $mpdHost 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
notify $"Switching to:\n(mpc --host $mpdHost 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
notify $"Switching to:\n(mpc --host $mpdHost 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
notify $"Toggling playback of:\n(mpc --host $mpdHost current)"
2024-09-17 13:40:50 +02:00
}