It's alive! Well, sort of, added a -p flag to post, be warned, thar be spam in them thar outputs.

This commit is contained in:
stormdragon2976 2023-01-29 19:45:43 -05:00
parent 82ee21407d
commit 9578307c7a
1 changed files with 13 additions and 1 deletions

View File

@ -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