Fixed stdin reading and added update command

This commit is contained in:
Nox Sluijtman 2025-01-08 14:39:40 +01:00
parent c74906fb77
commit d2428f4d54
Signed by: Egg
SSH key fingerprint: SHA256:2sG9X3C7Xvq2svGumz1/k7cm8l4G9+qAtAeugqB4J9M

View file

@ -1,4 +1,4 @@
#!/usr/bin/env nu
#!/usr/bin/env -S nu --stdin
let configPath = $"($env.XDG_CONFIG_HOME? | default $"($env.HOME)/.config")/irs.toml"
let config = if ($configPath | path exists) { open $configPath }
@ -98,6 +98,13 @@ def "main start" [--no-icon(-n) # Disables icon in notification
notify $"Starting playback of:\n(getCurrent $host)" (not $no_icon) $host
}
# Update the mpd database
def "main update" [--host(-H): string # mpd host
] {
let host = getHost $host
mpc update --host $host
}
# Toggles playback of the current que
def "main toggle" [--no-icon(-n) # Disables icon in notification
--host(-H): string # mpd host
@ -121,9 +128,10 @@ def "main insert" [ --host(-H): string # mpd host
, ...uri: string # URI to insert
] {
let host = getHost $host
let input = $in | to text
match ($uri | is-empty) {
true => { $in | mpc insert --host $host }
false => {mpc insert --host $host $uri }
true => { $input | mpc insert --host $host }
false => { ($uri | to text) | mpc insert --host $host }
}
}
@ -132,9 +140,10 @@ def "main add" [ --host(-H): string # mpd host
, ...uri: string # URI to add
] {
let host = getHost $host
let input = $in | to text
match ($uri | is-empty) {
true => { $in | mpc add --host $host }
false => { mpc add --host $host $uri }
true => { $input | mpc add --host $host }
false => { ($uri | to text) | mpc add --host $host }
}
}