From 9578307c7a4464843c809fa336091b4b2a348682 Mon Sep 17 00:00:00 2001 From: stormdragon2976 Date: Sun, 29 Jan 2023 19:45:43 -0500 Subject: [PATCH] It's alive! Well, sort of, added a -p flag to post, be warned, thar be spam in them thar outputs. --- ratatoskr.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/ratatoskr.sh b/ratatoskr.sh index 72abcc5..20b84d6 100755 --- a/ratatoskr.sh +++ b/ratatoskr.sh @@ -62,7 +62,7 @@ get_oauth_token() { # Post music with -M flag post_music() { - curl -vS --oauth2-bearer "${oauth_token}" \ + curl -sS --oauth2-bearer "${oauth_token}" \ -d "$(playerctl metadata -f 'album={{album}}')" \ -d "$(playerctl metadata -f 'artist={{artist}}')" \ -d "$(playerctl metadata -f 'title={{title}}')" \ @@ -71,6 +71,16 @@ post_music() { } +# Post status with -p flag, command line. +post_status() { + curl -sS --oauth2-bearer "${oauth_token}" \ + -d "content=${content_type:-text/markdown}" \ + -d "status=${@}" \ + "${instanceURL}/api/v1/statuses" + exit 0 +} + + # Variable initialization configPath="${XDG_CONFIG_HOME:-$HOME/.config}/ratatoskr" # Path for settings, usually ~/.config/ratatoskr configFile="default.conf" # The default config file, eventually will support multiple accounts. @@ -87,6 +97,7 @@ declare -A command=( [C]="Recreate default configuration file. Acquire new oauth token." [h]="Help, show usage information for ${0##*/}." [M]="Post the currently playing music track, requires playerctl." + [p:]="Post from the command line, e.g. ${0##*/} -p \"hello world\"" ) # if the default file doesn't exist, create it @@ -106,6 +117,7 @@ while getopts "${args}" i ; do C) get_oauth_token;; h) help;; M) post_music;; + p) post_status "${OPTARG}";; esac done