It would be cool if this worked in a systemd service...
This commit is contained in:
parent
1e0abd2d61
commit
e6743ce3f8
|
@ -1,20 +1,42 @@
|
|||
#!/usr/bin/env nu
|
||||
|
||||
# Documentation for notify
|
||||
def notify [message: string, prefix?: string] {
|
||||
notify-send $"Flatpak updater ($prefix)" $message
|
||||
#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..."
|
||||
notify "Starting unattended flatpak update..." "normal"
|
||||
let flatpak_status = do { flatpak update -y } | complete
|
||||
if $flatpak_status != 0 {
|
||||
if $flatpak_status.exit_code != 0 {
|
||||
if $flatpak_status.stderr != "" {
|
||||
notify $flatpak_status.stderr "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."
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue