Host parameter
This commit is contained in:
parent
910e0b54c0
commit
decb091842
|
@ -3,13 +3,12 @@
|
||||||
let configPath = $"($env.XDG_CONFIG_HOME? | default $"($env.HOME)/.config")/irs.toml"
|
let configPath = $"($env.XDG_CONFIG_HOME? | default $"($env.HOME)/.config")/irs.toml"
|
||||||
let config = if ($configPath | path exists) { open $configPath }
|
let config = if ($configPath | path exists) { open $configPath }
|
||||||
|
|
||||||
let mpdHost = if ($config == nothing) { $config.noise.host? | default 'localhost' } else { 'localhost' }
|
let mpdHost = if ($config | is-empty) { 'localhost' } else { $config.noise.host? | default 'localhost' }
|
||||||
let current = mpc --host $mpdHost current
|
|
||||||
|
|
||||||
def notify [message: string, display_icon:bool] {
|
def notify [message: string, display_icon:bool, host] {
|
||||||
match $display_icon {
|
match $display_icon {
|
||||||
true => {
|
true => {
|
||||||
do { mpc --host $mpdHost -f "%file%" current | xargs -I{} mpc --host $mpdHost albumart {} } | save -f /tmp/mpc_current.png
|
do { mpc --host $host -f "%file%" current | xargs -I{} mpc --host $host albumart {} } | save -f /tmp/mpc_current.png
|
||||||
notify-send "Noise" $"($message)" -i /tmp/mpc_current.png
|
notify-send "Noise" $"($message)" -i /tmp/mpc_current.png
|
||||||
}
|
}
|
||||||
false => {
|
false => {
|
||||||
|
@ -18,90 +17,126 @@ def notify [message: string, display_icon:bool] {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def getHost [ host?: string ] {
|
||||||
|
match ($host | is-empty) {
|
||||||
|
true => $mpdHost
|
||||||
|
false => $host
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def getCurrent [ host: string ] {
|
||||||
|
mpc current --host $host
|
||||||
|
}
|
||||||
|
|
||||||
# Displays the currently playing song
|
# Displays the currently playing song
|
||||||
def main [--no-icon(-n) # Disables icon in notification
|
def main [--no-icon(-n) # Disables icon in notification
|
||||||
|
--host(-H): string # mpd host
|
||||||
] {
|
] {
|
||||||
mpc --host $mpdHost
|
let host = getHost $host
|
||||||
notify $current (not $no_icon)
|
mpc --host $host
|
||||||
|
notify $"(getCurrent $host)" (not $no_icon) $host
|
||||||
}
|
}
|
||||||
|
|
||||||
# Displays the currently playing song and only the current song
|
# Displays the currently playing song and only the current song
|
||||||
def "main current" [--no-icon(-n) # Disables icon in notification
|
def "main current" [--no-icon(-n) # Disables icon in notification
|
||||||
|
--host(-H): string # mpd host
|
||||||
] {
|
] {
|
||||||
mpc --host $mpdHost current
|
let host = getHost $host
|
||||||
notify $current (not $no_icon)
|
notify $"(getCurrent $host)" (not $no_icon) $host
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Lists currently playing song
|
# Lists currently playing song
|
||||||
def "main tail" [] {
|
def "main tail" [ --host(-H): string # mpd host
|
||||||
while true { mpc --host $mpdHost idle playlist | ignore; mpc --host $mpdHost current}
|
] {
|
||||||
|
let host = getHost $host
|
||||||
|
while true { mpc --host $host idle player | ignore; mpc --host $host current}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Skips to next song
|
# Skips to next song
|
||||||
def "main next" [--no-icon(-n) # Disables icon in notification
|
def "main next" [--no-icon(-n) # Disables icon in notification
|
||||||
|
--host(-H): string # mpd host
|
||||||
] {
|
] {
|
||||||
mpc --host $mpdHost next
|
let host = getHost $host
|
||||||
notify $"Switching to:\n($current)" (not $no_icon)
|
mpc --host $host next
|
||||||
|
notify $"Switching to:\n(getCurrent $host)" (not $no_icon) $host
|
||||||
}
|
}
|
||||||
|
|
||||||
# Moves back a song in the que
|
# Moves back a song in the que
|
||||||
def "main prev" [--no-icon(-n) # Disables icon in notification
|
def "main prev" [--no-icon(-n) # Disables icon in notification
|
||||||
|
--host(-H): string # mpd host
|
||||||
] {
|
] {
|
||||||
mpc --host $mpdHost prev
|
let host = getHost $host
|
||||||
notify $"Switching to:\n($current)" (not $no_icon)
|
mpc --host $host
|
||||||
|
notify $"Switching to:\n(getCurrent $host)" (not $no_icon) $host
|
||||||
}
|
}
|
||||||
|
|
||||||
# Shuffles the current que
|
# Shuffles the current que
|
||||||
def "main shuffle" [--no-icon(-n) # Disables icon in notification
|
def "main shuffle" [--no-icon(-n) # Disables icon in notification
|
||||||
|
--host(-H): string # mpd host
|
||||||
] {
|
] {
|
||||||
|
let host = getHost $host
|
||||||
mpc --host $mpdHost shuffle
|
mpc --host $mpdHost shuffle
|
||||||
notify $"Shuffling que..." (not $no_icon)
|
notify $"Shuffling que..." (not $no_icon) $host
|
||||||
}
|
}
|
||||||
|
|
||||||
# Stops playing the current que
|
# Stops playing the current que
|
||||||
def "main stop" [--no-icon(-n) # Disables icon in notification
|
def "main stop" [--no-icon(-n) # Disables icon in notification
|
||||||
|
--host(-H): string # mpd host
|
||||||
] {
|
] {
|
||||||
mpc --host $mpdHost stop
|
let host = getHost $host
|
||||||
notify $"Stopping playback of:\n(mpc --host $mpdHost toggle)" (not $no_icon)
|
mpc --host $host stop
|
||||||
|
notify $"Stopping playback of:\n(getCurrent $host)" (not $no_icon) $host
|
||||||
}
|
}
|
||||||
|
|
||||||
# Starts playing the current que
|
# Starts playing the current que
|
||||||
def "main start" [--no-icon(-n) # Disables icon in notification
|
def "main start" [--no-icon(-n) # Disables icon in notification
|
||||||
|
--host(-H): string # mpd host
|
||||||
] {
|
] {
|
||||||
mpc --host $mpdHost start
|
let host = getHost $host
|
||||||
notify $"Starting playback of:\n(mpc --host $mpdHost toggle)" (not $no_icon)
|
mpc --host $host start
|
||||||
|
notify $"Starting playback of:\n(getCurrent $host)" (not $no_icon) $host
|
||||||
}
|
}
|
||||||
|
|
||||||
# Toggles playback of the current que
|
# Toggles playback of the current que
|
||||||
def "main toggle" [--no-icon(-n) # Disables icon in notification
|
def "main toggle" [--no-icon(-n) # Disables icon in notification
|
||||||
|
--host(-H): string # mpd host
|
||||||
] {
|
] {
|
||||||
mpc --host $mpdHost toggle
|
let host = getHost $host
|
||||||
notify $"Toggling playback of:\n($current)" (not $no_icon)
|
mpc --host $host toggle
|
||||||
|
notify $"Toggling playback of:\n(getCurrent $host)" (not $no_icon) $host
|
||||||
}
|
}
|
||||||
|
|
||||||
# Searches 'mpd' database querying all fields by default
|
# Searches 'mpd' database querying all fields by default
|
||||||
def "main search" [--field(-f): string=any # Field to query
|
def "main search" [--field(-f): string=any # Field to query
|
||||||
, ...query: string # Search query
|
, ...query: string # Search query
|
||||||
|
, --host(-H): string # mpd host
|
||||||
] {
|
] {
|
||||||
mpc --host $mpdHost search ($field) $"(echo ...$query | str join ' ')"
|
let host = getHost $host
|
||||||
|
mpc --host $host search ($field) $"(echo ...$query | str join ' ')"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Insert uri after currently playing song
|
# Insert uri after currently playing song
|
||||||
def "main insert" [] {
|
def "main insert" [ --host(-H): string # mpd host
|
||||||
$in | mpc insert --host $mpdHost
|
] {
|
||||||
|
let host = getHost $host
|
||||||
|
$in | mpc insert --host $host
|
||||||
}
|
}
|
||||||
|
|
||||||
# Adds uri to the end of current que
|
# Adds uri to the end of current que
|
||||||
def "main add" [] {
|
def "main add" [ --host(-H): string # mpd host
|
||||||
$in | mpc add --host $mpdHost
|
] {
|
||||||
|
let host = getHost $host
|
||||||
|
$in | mpc add --host $host
|
||||||
}
|
}
|
||||||
|
|
||||||
# Direct wrapper around 'mpc crossfade'
|
# Direct wrapper around 'mpc crossfade'
|
||||||
def "main crossfade" [ time?: int # Time in seconds
|
def "main crossfade" [ time?: int # Time in seconds
|
||||||
|
--host(-H): string # mpd host
|
||||||
] {
|
] {
|
||||||
|
let host = getHost $host
|
||||||
match ($time | is-empty) {
|
match ($time | is-empty) {
|
||||||
true => { mpc --host $mpdHost crossfade }
|
true => { mpc --host $host crossfade }
|
||||||
false => { mpc --host $mpdHost crossfade $time }
|
false => { mpc --host $host crossfade $time }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue