46 lines
1.4 KiB
Plaintext
Executable file
46 lines
1.4 KiB
Plaintext
Executable file
#!/usr/bin/env nu
|
|
|
|
# Documentation for notify
|
|
#def notify [message: string, prefix?: string] {
|
|
# notify-send $"Flatpak updater ($prefix)" $message
|
|
#}
|
|
|
|
def notify [message: string, urgency: string, prefix?: string] {
|
|
notify-send $"Flatpak updater ($prefix)" $message -u $urgency
|
|
}
|
|
#def update_flatpaks [] {
|
|
# notify "Starting unattended flatpak update..."
|
|
# let flatpak_status = do { flatpak update -y } | complete
|
|
# if $flatpak_status != 0 {
|
|
# if $flatpak_status.stderr != "" {
|
|
# notify $flatpak_status.stderr "stderr"
|
|
# } else {
|
|
# notify "Unattended update complete.\nConsider restarting presently running flatpaks."
|
|
# }
|
|
# }
|
|
#}
|
|
|
|
def update_flatpaks [] {
|
|
notify "Starting unattended flatpak update..." "normal"
|
|
let flatpak_status = do { flatpak update -y } | complete
|
|
if $flatpak_status.exit_code != 0 {
|
|
if $flatpak_status.stderr != "" {
|
|
notify $flatpak_status.stderr "critical" "stderr"
|
|
}
|
|
if $flatpak_status.stdout != "" {
|
|
notify $flatpak_status.stdout "normal" "stdout"
|
|
}
|
|
} else {
|
|
notify $"Unattended update complete.\nConsider restarting presently running flatpaks:\n\n(running_flatpaks)" "normal"
|
|
}
|
|
}
|
|
|
|
def running_flatpaks [] {
|
|
flatpak ps --columns="application" | lines | uniq | str join "\n"
|
|
}
|
|
|
|
# Documentation for main
|
|
def main [] {
|
|
update_flatpaks
|
|
}
|