You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
784 B
Plaintext
36 lines
784 B
Plaintext
1 year ago
|
#!/bin/env nu
|
||
|
|
||
|
use cntfy.nu
|
||
|
|
||
|
# Checks for package updates
|
||
|
def main [
|
||
|
--ntfy: bool
|
||
|
] {
|
||
1 year ago
|
if ( is-admin ) == false {
|
||
|
error make {
|
||
1 year ago
|
msg: "This script needs to be run as root"
|
||
|
}
|
||
|
}
|
||
1 year ago
|
pacman -Sy
|
||
|
|
||
1 year ago
|
let updates = ( checkupdates | split row "\n" )
|
||
|
let update_count = ( $updates | length )
|
||
|
|
||
|
if $update_count > 0 {
|
||
|
echo $"($update_count) package[s] need to be updated"
|
||
|
|
||
|
if $ntfy {
|
||
|
mut update_msg = "";
|
||
|
|
||
|
if $update_count > 20 {
|
||
|
$update_msg = ( $updates
|
||
|
| first 19
|
||
|
| append $"... And ($update_count - 19) more"
|
||
|
| str join "\n" )
|
||
|
} else {
|
||
|
$update_msg = ( $updates | str join "\n" )
|
||
|
}
|
||
1 year ago
|
cntfy publish --title $"($update_count) package[s] need to be updated" updates $update_msg
|
||
1 year ago
|
}
|
||
|
}
|
||
|
}
|