mirror of
https://github.com/mitchell/dotfiles.git
synced 2025-12-17 12:27:22 +00:00
Simplify and cleanup push functions
This commit is contained in:
parent
9d68c0103e
commit
e0ae2e0257
5 changed files with 25 additions and 43 deletions
25
.config/fish/functions/push.fish
Normal file
25
.config/fish/functions/push.fish
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
function push -a message -d 'Send a push notification to your phone via pushover (optional delay as second arg)'
|
||||
argparse 'u/url=' 'p/priority=' -- $argv
|
||||
|
||||
set -l host (cat /etc/hostname)
|
||||
|
||||
if test -z "$_flag_p"
|
||||
set _flag_p '0'
|
||||
end
|
||||
|
||||
set payload \
|
||||
"{
|
||||
\"token\": \"$pushover_token\",
|
||||
\"user\": \"$pushover_user\",
|
||||
\"title\": \"Push from $host\",
|
||||
\"url\": \"$_flag_u\",
|
||||
\"priority\": $_flag_p,
|
||||
\"message\": \"$message\"
|
||||
}"
|
||||
|
||||
curl \
|
||||
-X POST \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d "$payload" \
|
||||
https://api.pushover.net/1/messages.json
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue